1 // RUN: %clang_cc1 -triple x86_64-apple-darwin -emit-llvm < %s | FileCheck -check-prefixes=CHECK,X86,GIZ %s 2 // RUN: %clang_cc1 -triple amdgcn -emit-llvm < %s | FileCheck -check-prefixes=CHECK,PIZ %s 3 // RUN: %clang_cc1 -triple amdgcn---amdgiz -emit-llvm < %s | FileCheck -check-prefixes=CHECK,AMDGIZ,GIZ %s 4 5 // CHECK: @foo = common addrspace(1) global 6 int foo __attribute__((address_space(1))); 7 8 // CHECK: @ban = common addrspace(1) global 9 int ban[10] __attribute__((address_space(1))); 10 11 // CHECK: @a = common global 12 int a __attribute__((address_space(0))); 13 14 // CHECK-LABEL: define i32 @test1() 15 // CHECK: load i32, i32 addrspace(1)* @foo 16 int test1() { return foo; } 17 18 // CHECK-LABEL: define i32 @test2(i32 %i) 19 // CHECK: load i32, i32 addrspace(1)* 20 // CHECK-NEXT: ret i32 21 int test2(int i) { return ban[i]; } 22 23 // Both A and B point into addrspace(2). 24 __attribute__((address_space(2))) int *A, *B; 25 26 // CHECK-LABEL: define void @test3() 27 // X86: load i32 addrspace(2)*, i32 addrspace(2)** @B 28 // AMDGIZ: load i32 addrspace(2)*, i32 addrspace(2)** addrspacecast (i32 addrspace(2)* addrspace(1)* @B to i32 addrspace(2)**) 29 // PIZ: load i32 addrspace(2)*, i32 addrspace(2)* addrspace(4)* addrspacecast (i32 addrspace(2)* addrspace(1)* @B to i32 addrspace(2)* addrspace(4)*) 30 // CHECK: load i32, i32 addrspace(2)* 31 // X86: load i32 addrspace(2)*, i32 addrspace(2)** @A 32 // AMDGIZ: load i32 addrspace(2)*, i32 addrspace(2)** addrspacecast (i32 addrspace(2)* addrspace(1)* @A to i32 addrspace(2)**) 33 // PIZ: load i32 addrspace(2)*, i32 addrspace(2)* addrspace(4)* addrspacecast (i32 addrspace(2)* addrspace(1)* @A to i32 addrspace(2)* addrspace(4)*) 34 // CHECK: store i32 {{.*}}, i32 addrspace(2)* 35 void test3() { 36 *A = *B; 37 } 38 39 // PR7437 40 typedef struct { 41 float aData[1]; 42 } MyStruct; 43 44 // CHECK-LABEL: define void @test4( 45 // GIZ: call void @llvm.memcpy.p0i8.p2i8 46 // GIZ: call void @llvm.memcpy.p2i8.p0i8 47 // PIZ: call void @llvm.memcpy.p4i8.p2i8 48 // PIZ: call void @llvm.memcpy.p2i8.p4i8 49 void test4(MyStruct __attribute__((address_space(2))) *pPtr) { 50 MyStruct s = pPtr[0]; 51 pPtr[0] = s; 52 } 53