diff options
author | Zancanaro; Carlo <czan8762@plang3.cs.usyd.edu.au> | 2012-09-24 09:58:17 +1000 |
---|---|---|
committer | Zancanaro; Carlo <czan8762@plang3.cs.usyd.edu.au> | 2012-09-24 09:58:17 +1000 |
commit | 222e2a7620e6520ffaf4fc4e69d79c18da31542e (patch) | |
tree | 7bfbc05bfa3b41c8f9d2e56d53a0bc3e310df239 /clang/test/CodeGen/address-space.c | |
parent | 3d206f03985b50beacae843d880bccdc91a9f424 (diff) |
Add the clang library to the repo (with some of my changes, too).
Diffstat (limited to 'clang/test/CodeGen/address-space.c')
-rw-r--r-- | clang/test/CodeGen/address-space.c | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/clang/test/CodeGen/address-space.c b/clang/test/CodeGen/address-space.c new file mode 100644 index 0000000..04f88dc --- /dev/null +++ b/clang/test/CodeGen/address-space.c @@ -0,0 +1,44 @@ +// RUN: %clang_cc1 -emit-llvm < %s | FileCheck %s +// RUN: %clang_cc1 -emit-llvm < %s | grep 'load.*addrspace(2).. @A' +// RUN: %clang_cc1 -emit-llvm < %s | grep 'load.*addrspace(2).. @B' + + +// CHECK: @foo = common addrspace(1) global +int foo __attribute__((address_space(1))); + +// CHECK: @ban = common addrspace(1) global +int ban[10] __attribute__((address_space(1))); + +// CHECK: define i32 @test1() +// CHECK: load i32 addrspace(1)* @foo +int test1() { return foo; } + +// CHECK: define i32 @test2(i32 %i) +// CHECK: load i32 addrspace(1)* +// CHECK-NEXT: ret i32 +int test2(int i) { return ban[i]; } + +// Both A and B point into addrspace(2). +__attribute__((address_space(2))) int *A, *B; + +// CHECK: define void @test3() +// CHECK: load i32 addrspace(2)** @B +// CHECK: load i32 addrspace(2)* +// CHECK: load i32 addrspace(2)** @A +// CHECK: store i32 {{.*}}, i32 addrspace(2)* +void test3() { + *A = *B; +} + +// PR7437 +typedef struct { + float aData[1]; +} MyStruct; + +// CHECK: define void @test4( +// CHECK: call void @llvm.memcpy.p0i8.p2i8 +// CHECK: call void @llvm.memcpy.p2i8.p0i8 +void test4(MyStruct __attribute__((address_space(2))) *pPtr) { + MyStruct s = pPtr[0]; + pPtr[0] = s; +} |