llvm-project
67 строк · 2.8 Кб
1// RUN: %clang_cc1 -O0 -cl-std=CL1.2 -triple amdgcn---amdgizcl -emit-llvm %s -o - | FileCheck -check-prefixes=CHECK,CL12 %s
2// RUN: %clang_cc1 -O0 -cl-std=CL2.0 -triple amdgcn---amdgizcl -emit-llvm %s -o - | FileCheck -check-prefixes=CHECK,CL20 %s
3
4// CL12-LABEL: define{{.*}} void @func1(ptr addrspace(5) noundef %x)
5// CL20-LABEL: define{{.*}} void @func1(ptr noundef %x)
6void func1(int *x) {
7// CL12: %[[x_addr:.*]] = alloca ptr addrspace(5){{.*}}addrspace(5)
8// CL12: store ptr addrspace(5) %x, ptr addrspace(5) %[[x_addr]]
9// CL12: %[[r0:.*]] = load ptr addrspace(5), ptr addrspace(5) %[[x_addr]]
10// CL12: store i32 1, ptr addrspace(5) %[[r0]]
11// CL20: %[[x_addr:.*]] = alloca ptr{{.*}}addrspace(5)
12// CL20: store ptr %x, ptr addrspace(5) %[[x_addr]]
13// CL20: %[[r0:.*]] = load ptr, ptr addrspace(5) %[[x_addr]]
14// CL20: store i32 1, ptr %[[r0]]
15*x = 1;
16}
17
18// CHECK-LABEL: define{{.*}} void @func2()
19void func2(void) {
20// CHECK: %lv1 = alloca i32, align 4, addrspace(5)
21// CHECK: %lv2 = alloca i32, align 4, addrspace(5)
22// CHECK: %la = alloca [100 x i32], align 4, addrspace(5)
23// CL12: %lp1 = alloca ptr addrspace(5), align 4, addrspace(5)
24// CL12: %lp2 = alloca ptr addrspace(5), align 4, addrspace(5)
25// CL20: %lp1 = alloca ptr, align 8, addrspace(5)
26// CL20: %lp2 = alloca ptr, align 8, addrspace(5)
27// CHECK: %lvc = alloca i32, align 4, addrspace(5)
28
29// CHECK: store i32 1, ptr addrspace(5) %lv1
30int lv1;
31lv1 = 1;
32// CHECK: store i32 2, ptr addrspace(5) %lv2
33int lv2 = 2;
34
35// CHECK: %[[arrayidx:.*]] = getelementptr inbounds [100 x i32], ptr addrspace(5) %la, i64 0, i64 0
36// CHECK: store i32 3, ptr addrspace(5) %[[arrayidx]], align 4
37int la[100];
38la[0] = 3;
39
40// CL12: store ptr addrspace(5) %lv1, ptr addrspace(5) %lp1, align 4
41// CL20: %[[r0:.*]] = addrspacecast ptr addrspace(5) %lv1 to ptr
42// CL20: store ptr %[[r0]], ptr addrspace(5) %lp1, align 8
43int *lp1 = &lv1;
44
45// CHECK: %[[arraydecay:.*]] = getelementptr inbounds [100 x i32], ptr addrspace(5) %la, i64 0, i64 0
46// CL12: store ptr addrspace(5) %[[arraydecay]], ptr addrspace(5) %lp2, align 4
47// CL20: %[[r1:.*]] = addrspacecast ptr addrspace(5) %[[arraydecay]] to ptr
48// CL20: store ptr %[[r1]], ptr addrspace(5) %lp2, align 8
49int *lp2 = la;
50
51// CL12: call void @func1(ptr addrspace(5) noundef %lv1)
52// CL20: %[[r2:.*]] = addrspacecast ptr addrspace(5) %lv1 to ptr
53// CL20: call void @func1(ptr noundef %[[r2]])
54func1(&lv1);
55
56// CHECK: store i32 4, ptr addrspace(5) %lvc
57// CHECK: store i32 4, ptr addrspace(5) %lv1
58const int lvc = 4;
59lv1 = lvc;
60}
61
62// CHECK-LABEL: define{{.*}} void @func3()
63// CHECK: %a = alloca [16 x [1 x float]], align 4, addrspace(5)
64// CHECK: call void @llvm.memset.p5.i64(ptr addrspace(5) align 4 %a, i8 0, i64 64, i1 false)
65void func3(void) {
66float a[16][1] = {{0.}};
67}
68