Yaxun Liu | b34ec82 | 2017-04-11 17:24:23 +0000 | [diff] [blame] | 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(4) global i32 0 |
| 5 | // CHECK-DAG: @foo = common global i32 0 |
| 6 | int foo; |
| 7 | |
| 8 | // PIZ-DAG: @ban = common addrspace(4) global [10 x i32] zeroinitializer |
| 9 | // CHECK-DAG: @ban = common global [10 x i32] zeroinitializer |
| 10 | int ban[10]; |
| 11 | |
| 12 | // PIZ-DAG: @A = common addrspace(4) global i32 addrspace(4)* null |
| 13 | // PIZ-DAG: @B = common addrspace(4) global i32 addrspace(4)* null |
| 14 | // CHECK-DAG: @A = common global i32* null |
| 15 | // CHECK-DAG: @B = common global i32* null |
| 16 | int *A; |
| 17 | int *B; |
| 18 | |
| 19 | // COM-LABEL: define i32 @test1() |
| 20 | // PIZ: load i32, i32 addrspace(4)* @foo |
| 21 | // CHECK: load i32, i32* @foo |
| 22 | int test1() { return foo; } |
| 23 | |
| 24 | // COM-LABEL: define i32 @test2(i32 %i) |
| 25 | // PIZ: load i32, i32 addrspace(4)* |
| 26 | // PIZ-NEXT: ret i32 |
| 27 | // CHECK: load i32, i32* |
| 28 | // CHECK-NEXT: ret i32 |
| 29 | int test2(int i) { return ban[i]; } |
| 30 | |
| 31 | // COM-LABEL: define void @test3() |
| 32 | // PIZ: load i32 addrspace(4)*, i32 addrspace(4)* addrspace(4)* @B |
| 33 | // PIZ: load i32, i32 addrspace(4)* |
| 34 | // PIZ: load i32 addrspace(4)*, i32 addrspace(4)* addrspace(4)* @A |
| 35 | // PIZ: store i32 {{.*}}, i32 addrspace(4)* |
| 36 | // CHECK: load i32*, i32** @B |
| 37 | // CHECK: load i32, i32* |
| 38 | // CHECK: load i32*, i32** @A |
| 39 | // CHECK: store i32 {{.*}}, i32* |
| 40 | void test3() { |
| 41 | *A = *B; |
| 42 | } |
| 43 | |
| 44 | // PIZ-LABEL: define void @test4(i32 addrspace(4)* %a) |
| 45 | // PIZ: %[[a_addr:.*]] = alloca i32 addrspace(4)* |
| 46 | // PIZ: store i32 addrspace(4)* %a, i32 addrspace(4)** %[[a_addr]] |
| 47 | // PIZ: %[[r0:.*]] = load i32 addrspace(4)*, i32 addrspace(4)** %[[a_addr]] |
| 48 | // PIZ: %[[arrayidx:.*]] = getelementptr inbounds i32, i32 addrspace(4)* %[[r0]] |
| 49 | // PIZ: store i32 0, i32 addrspace(4)* %[[arrayidx]] |
| 50 | // CHECK-LABEL: define void @test4(i32* %a) |
| 51 | // CHECK: %[[a_addr:.*]] = alloca i32*, align 4, addrspace(5) |
| 52 | // CHECK: store i32* %a, i32* addrspace(5)* %[[a_addr]] |
| 53 | // CHECK: %[[r0:.*]] = load i32*, i32* addrspace(5)* %[[a_addr]] |
| 54 | // CHECK: %[[arrayidx:.*]] = getelementptr inbounds i32, i32* %[[r0]] |
| 55 | // CHECK: store i32 0, i32* %[[arrayidx]] |
| 56 | void test4(int *a) { |
| 57 | a[0] = 0; |
| 58 | } |