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(i32 addrspace(5)* %x) 5// CL20-LABEL: define void @func1(i32* %x) 6void 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; 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 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) 28 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; 34 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; 39 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; 44 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; 50 51 // CL12: call void @func1(i32 addrspace(5)* %lv1) 52 // CL20: %[[r2:.*]] = addrspacecast i32 addrspace(5)* %lv1 to i32* 53 // CL20: call void @func1(i32* %[[r2]]) 54 func1(&lv1); 55 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; 60} 61 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) 66void func3(void) { 67 float a[16][1] = {{0.}}; 68} 69