[docs] Add LICENSE.txt to the root of the mono-repo
[llvm-project.git] / clang / test / CodeGenOpenCL / amdgcn-automatic-variable.cl
blob88754c7a35d7f45715c3dfbfa0f559f5a7447795
1 // RUN: %clang_cc1 -no-opaque-pointers -O0 -cl-std=CL1.2 -triple amdgcn---amdgizcl -emit-llvm %s -o - | FileCheck -check-prefixes=CHECK,CL12 %s
2 // RUN: %clang_cc1 -no-opaque-pointers -O0 -cl-std=CL2.0 -triple amdgcn---amdgizcl -emit-llvm %s -o - | FileCheck -check-prefixes=CHECK,CL20 %s
4 // CL12-LABEL: define{{.*}} void @func1(i32 addrspace(5)* noundef %x)
5 // CL20-LABEL: define{{.*}} void @func1(i32* noundef %x)
6 void func1(int *x) {
7 // CL12: %[[x_addr:.*]] = alloca i32 addrspace(5)*{{.*}}addrspace(5)
8 // CL12: store i32 addrspace(5)* %x, i32 addrspace(5)* addrspace(5)* %[[x_addr]]
9 // CL12: %[[r0:.*]] = load i32 addrspace(5)*, i32 addrspace(5)* addrspace(5)* %[[x_addr]]
10 // CL12: store i32 1, i32 addrspace(5)* %[[r0]]
11 // CL20: %[[x_addr:.*]] = alloca i32*{{.*}}addrspace(5)
12 // CL20: store i32* %x, i32* addrspace(5)* %[[x_addr]]
13 // CL20: %[[r0:.*]] = load i32*, i32* addrspace(5)* %[[x_addr]]
14 // CL20: store i32 1, i32* %[[r0]]
15 *x = 1;
18 // CHECK-LABEL: define{{.*}} void @func2()
19 void 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 i32 addrspace(5)*, align 4, addrspace(5)
24 // CL12: %lp2 = alloca i32 addrspace(5)*, align 4, addrspace(5)
25 // CL20: %lp1 = alloca i32*, align 8, addrspace(5)
26 // CL20: %lp2 = alloca i32*, align 8, addrspace(5)
27 // CHECK: %lvc = alloca i32, align 4, addrspace(5)
29 // CHECK: store i32 1, i32 addrspace(5)* %lv1
30 int lv1;
31 lv1 = 1;
32 // CHECK: store i32 2, i32 addrspace(5)* %lv2
33 int lv2 = 2;
35 // CHECK: %[[arrayidx:.*]] = getelementptr inbounds [100 x i32], [100 x i32] addrspace(5)* %la, i64 0, i64 0
36 // CHECK: store i32 3, i32 addrspace(5)* %[[arrayidx]], align 4
37 int la[100];
38 la[0] = 3;
40 // CL12: store i32 addrspace(5)* %lv1, i32 addrspace(5)* addrspace(5)* %lp1, align 4
41 // CL20: %[[r0:.*]] = addrspacecast i32 addrspace(5)* %lv1 to i32*
42 // CL20: store i32* %[[r0]], i32* addrspace(5)* %lp1, align 8
43 int *lp1 = &lv1;
45 // CHECK: %[[arraydecay:.*]] = getelementptr inbounds [100 x i32], [100 x i32] addrspace(5)* %la, i64 0, i64 0
46 // CL12: store i32 addrspace(5)* %[[arraydecay]], i32 addrspace(5)* addrspace(5)* %lp2, align 4
47 // CL20: %[[r1:.*]] = addrspacecast i32 addrspace(5)* %[[arraydecay]] to i32*
48 // CL20: store i32* %[[r1]], i32* addrspace(5)* %lp2, align 8
49 int *lp2 = la;
51 // CL12: call void @func1(i32 addrspace(5)* noundef %lv1)
52 // CL20: %[[r2:.*]] = addrspacecast i32 addrspace(5)* %lv1 to i32*
53 // CL20: call void @func1(i32* noundef %[[r2]])
54 func1(&lv1);
56 // CHECK: store i32 4, i32 addrspace(5)* %lvc
57 // CHECK: store i32 4, i32 addrspace(5)* %lv1
58 const int lvc = 4;
59 lv1 = lvc;
62 // CHECK-LABEL: define{{.*}} void @func3()
63 // CHECK: %a = alloca [16 x [1 x float]], align 4, addrspace(5)
64 // CHECK: %[[CAST:.+]] = bitcast [16 x [1 x float]] addrspace(5)* %a to i8 addrspace(5)*
65 // CHECK: call void @llvm.memset.p5i8.i64(i8 addrspace(5)* align 4 %[[CAST]], i8 0, i64 64, i1 false)
66 void func3(void) {
67 float a[16][1] = {{0.}};