]> granicus.if.org Git - clang/commit
Use the dereferenceable attribute on C99 array parameters with static
authorHal Finkel <hfinkel@anl.gov>
Sat, 19 Jul 2014 01:41:07 +0000 (01:41 +0000)
committerHal Finkel <hfinkel@anl.gov>
Sat, 19 Jul 2014 01:41:07 +0000 (01:41 +0000)
commitec385646f412dfb73762b09b36cb7c0589677301
tree9dcf615ff9496f404340a495338867200b746ff8
parent4b691c5dee4751cd72c8b54a492a99cc88400df1
Use the dereferenceable attribute on C99 array parameters with static

In C99, an array parameter declarator might have the form:
  direct-declarator '[' 'static' type-qual-list[opt] assign-expr ']'

where the static keyword indicates that the caller will always provide a
pointer to the beginning of an array with at least the number of elements
specified by the assignment expression. For constant sizes, we can use the
new dereferenceable attribute to pass this information to the optimizer. For
VLAs, we don't know the size, but (for addrspace(0)) do know that the pointer
must be nonnull (and so we can use the nonnull attribute).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@213444 91177308-0d34-0410-b5e6-96231b3b80d8
lib/CodeGen/CGCall.cpp
test/CodeGen/vla.c