diff options
author | Hal Finkel <hfinkel@anl.gov> | 2014-07-19 01:41:07 +0000 |
---|---|---|
committer | Hal Finkel <hfinkel@anl.gov> | 2014-07-19 01:41:07 +0000 |
commit | 48d53e2c4c9131766e61fb52c7876fbcf9859463 (patch) | |
tree | 82adc871289f565e71d1207baa8f3e278664ae47 /clang/test | |
parent | 1b98ccc4e9576e86fb3e235bac3076472a84f875 (diff) | |
download | bcm5719-llvm-48d53e2c4c9131766e61fb52c7876fbcf9859463.tar.gz bcm5719-llvm-48d53e2c4c9131766e61fb52c7876fbcf9859463.zip |
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).
llvm-svn: 213444
Diffstat (limited to 'clang/test')
-rw-r--r-- | clang/test/CodeGen/vla.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/clang/test/CodeGen/vla.c b/clang/test/CodeGen/vla.c index 1757ef77879..e6cdd5d2a32 100644 --- a/clang/test/CodeGen/vla.c +++ b/clang/test/CodeGen/vla.c @@ -195,3 +195,12 @@ void test7(int a[b(0)]) { // CHECK-LABEL: define void @test7( // CHECK: call i32 @b(i8* null) } + +// Make sure we emit dereferenceable or nonnull when the static keyword is +// provided. +void test8(int a[static 3]) { } +// CHECK: define void @test8(i32* dereferenceable(12) %a) + +void test9(int n, int a[static n]) { } +// CHECK: define void @test9(i32 %n, i32* nonnull %a) + |