1 // RUN: %clang_cc1 -triple amdgcn -emit-llvm < %s | FileCheck -check-prefixes=PIZ,COM %s 2 // RUN: %clang_cc1 -triple amdgcn---amdgiz -emit-llvm < %s | FileCheck -check-prefixes=CHECK,COM %s 3 4 // PIZ-DAG: @foo = common addrspace(1) global i32 0 5 // CHECK-DAG: @foo = common addrspace(1) global i32 0 6 int foo; 7 8 // PIZ-DAG: @ban = common addrspace(1) global [10 x i32] zeroinitializer 9 // CHECK-DAG: @ban = common addrspace(1) global [10 x i32] zeroinitializer 10 int ban[10]; 11 12 // PIZ-DAG: @A = common addrspace(1) global i32 addrspace(4)* null 13 // PIZ-DAG: @B = common addrspace(1) global i32 addrspace(4)* null 14 // CHECK-DAG: @A = common addrspace(1) global i32* null 15 // CHECK-DAG: @B = common addrspace(1) global i32* null 16 int *A; 17 int *B; 18 19 // COM-LABEL: define i32 @test1() 20 // PIZ: load i32, i32 addrspace(4)* addrspacecast{{[^@]+}} @foo 21 // CHECK: load i32, i32* addrspacecast{{[^@]+}} @foo 22 int test1() { return foo; } 23 24 // COM-LABEL: define i32 @test2(i32 %i) 25 // COM: %[[addr:.*]] = getelementptr 26 // PIZ: load i32, i32 addrspace(4)* %[[addr]] 27 // PIZ-NEXT: ret i32 28 // CHECK: load i32, i32* %[[addr]] 29 // CHECK-NEXT: ret i32 30 int test2(int i) { return ban[i]; } 31 32 // COM-LABEL: define void @test3() 33 // PIZ: load i32 addrspace(4)*, i32 addrspace(4)* addrspace(4)* addrspacecast{{[^@]+}} @B 34 // PIZ: load i32, i32 addrspace(4)* 35 // PIZ: load i32 addrspace(4)*, i32 addrspace(4)* addrspace(4)* addrspacecast{{[^@]+}} @A 36 // PIZ: store i32 {{.*}}, i32 addrspace(4)* 37 // CHECK: load i32*, i32** addrspacecast{{.*}} @B 38 // CHECK: load i32, i32* 39 // CHECK: load i32*, i32** addrspacecast{{.*}} @A 40 // CHECK: store i32 {{.*}}, i32* 41 void test3() { 42 *A = *B; 43 } 44 45 // PIZ-LABEL: define void @test4(i32 addrspace(4)* %a) 46 // PIZ: %[[alloca:.*]] = alloca i32 addrspace(4)* 47 // PIZ: %[[a_addr:.*]] = addrspacecast{{.*}} %[[alloca]] to i32 addrspace(4)* addrspace(4)* 48 // PIZ: store i32 addrspace(4)* %a, i32 addrspace(4)* addrspace(4)* %[[a_addr]] 49 // PIZ: %[[r0:.*]] = load i32 addrspace(4)*, i32 addrspace(4)* addrspace(4)* %[[a_addr]] 50 // PIZ: %[[arrayidx:.*]] = getelementptr inbounds i32, i32 addrspace(4)* %[[r0]] 51 // PIZ: store i32 0, i32 addrspace(4)* %[[arrayidx]] 52 // CHECK-LABEL: define void @test4(i32* %a) 53 // CHECK: %[[alloca:.*]] = alloca i32*, align 8, addrspace(5) 54 // CHECK: %[[a_addr:.*]] = addrspacecast{{.*}} %[[alloca]] to i32** 55 // CHECK: store i32* %a, i32** %[[a_addr]] 56 // CHECK: %[[r0:.*]] = load i32*, i32** %[[a_addr]] 57 // CHECK: %[[arrayidx:.*]] = getelementptr inbounds i32, i32* %[[r0]] 58 // CHECK: store i32 0, i32* %[[arrayidx]] 59 void test4(int *a) { 60 a[0] = 0; 61 } 62