2017-05-19 02:51:09 +08:00
|
|
|
// RUN: %clang_cc1 -O0 -cl-std=CL1.2 -triple amdgcn---amdgizcl -emit-llvm %s -o - | FileCheck -check-prefixes=CHECK,CL12 %s
|
|
|
|
// RUN: %clang_cc1 -O0 -cl-std=CL2.0 -triple amdgcn---amdgizcl -emit-llvm %s -o - | FileCheck -check-prefixes=CHECK,CL20 %s
|
|
|
|
|
2021-11-09 01:09:49 +08:00
|
|
|
// CL12-LABEL: define{{.*}} void @func1(i32 addrspace(5)* %x)
|
|
|
|
// CL20-LABEL: define{{.*}} void @func1(i32* %x)
|
2017-05-19 02:51:09 +08:00
|
|
|
void func1(int *x) {
|
|
|
|
// CL12: %[[x_addr:.*]] = alloca i32 addrspace(5)*{{.*}}addrspace(5)
|
|
|
|
// CL12: store i32 addrspace(5)* %x, i32 addrspace(5)* addrspace(5)* %[[x_addr]]
|
|
|
|
// CL12: %[[r0:.*]] = load i32 addrspace(5)*, i32 addrspace(5)* addrspace(5)* %[[x_addr]]
|
|
|
|
// CL12: store i32 1, i32 addrspace(5)* %[[r0]]
|
|
|
|
// CL20: %[[x_addr:.*]] = alloca i32*{{.*}}addrspace(5)
|
|
|
|
// CL20: store i32* %x, i32* addrspace(5)* %[[x_addr]]
|
|
|
|
// CL20: %[[r0:.*]] = load i32*, i32* addrspace(5)* %[[x_addr]]
|
|
|
|
// CL20: store i32 1, i32* %[[r0]]
|
|
|
|
*x = 1;
|
|
|
|
}
|
|
|
|
|
2020-12-31 16:27:11 +08:00
|
|
|
// CHECK-LABEL: define{{.*}} void @func2()
|
2017-05-19 02:51:09 +08:00
|
|
|
void func2(void) {
|
|
|
|
// CHECK: %lv1 = alloca i32, align 4, addrspace(5)
|
|
|
|
// CHECK: %lv2 = alloca i32, align 4, addrspace(5)
|
|
|
|
// CHECK: %la = alloca [100 x i32], align 4, addrspace(5)
|
|
|
|
// CL12: %lp1 = alloca i32 addrspace(5)*, align 4, addrspace(5)
|
|
|
|
// CL12: %lp2 = alloca i32 addrspace(5)*, align 4, addrspace(5)
|
2017-07-05 12:58:24 +08:00
|
|
|
// CL20: %lp1 = alloca i32*, align 8, addrspace(5)
|
|
|
|
// CL20: %lp2 = alloca i32*, align 8, addrspace(5)
|
2017-05-19 02:51:09 +08:00
|
|
|
// CHECK: %lvc = alloca i32, align 4, addrspace(5)
|
|
|
|
|
|
|
|
// CHECK: store i32 1, i32 addrspace(5)* %lv1
|
|
|
|
int lv1;
|
|
|
|
lv1 = 1;
|
|
|
|
// CHECK: store i32 2, i32 addrspace(5)* %lv2
|
|
|
|
int lv2 = 2;
|
|
|
|
|
|
|
|
// CHECK: %[[arrayidx:.*]] = getelementptr inbounds [100 x i32], [100 x i32] addrspace(5)* %la, i64 0, i64 0
|
|
|
|
// CHECK: store i32 3, i32 addrspace(5)* %[[arrayidx]], align 4
|
|
|
|
int la[100];
|
|
|
|
la[0] = 3;
|
|
|
|
|
|
|
|
// CL12: store i32 addrspace(5)* %lv1, i32 addrspace(5)* addrspace(5)* %lp1, align 4
|
|
|
|
// CL20: %[[r0:.*]] = addrspacecast i32 addrspace(5)* %lv1 to i32*
|
2017-07-05 12:58:24 +08:00
|
|
|
// CL20: store i32* %[[r0]], i32* addrspace(5)* %lp1, align 8
|
2017-05-19 02:51:09 +08:00
|
|
|
int *lp1 = &lv1;
|
|
|
|
|
2019-02-08 23:34:12 +08:00
|
|
|
// CHECK: %[[arraydecay:.*]] = getelementptr inbounds [100 x i32], [100 x i32] addrspace(5)* %la, i64 0, i64 0
|
2017-05-19 02:51:09 +08:00
|
|
|
// CL12: store i32 addrspace(5)* %[[arraydecay]], i32 addrspace(5)* addrspace(5)* %lp2, align 4
|
|
|
|
// CL20: %[[r1:.*]] = addrspacecast i32 addrspace(5)* %[[arraydecay]] to i32*
|
2017-07-05 12:58:24 +08:00
|
|
|
// CL20: store i32* %[[r1]], i32* addrspace(5)* %lp2, align 8
|
2017-05-19 02:51:09 +08:00
|
|
|
int *lp2 = la;
|
|
|
|
|
2021-11-09 01:09:49 +08:00
|
|
|
// CL12: call void @func1(i32 addrspace(5)* %lv1)
|
2017-05-19 02:51:09 +08:00
|
|
|
// CL20: %[[r2:.*]] = addrspacecast i32 addrspace(5)* %lv1 to i32*
|
2021-11-09 01:09:49 +08:00
|
|
|
// CL20: call void @func1(i32* %[[r2]])
|
2017-05-19 02:51:09 +08:00
|
|
|
func1(&lv1);
|
|
|
|
|
|
|
|
// CHECK: store i32 4, i32 addrspace(5)* %lvc
|
|
|
|
// CHECK: store i32 4, i32 addrspace(5)* %lv1
|
|
|
|
const int lvc = 4;
|
|
|
|
lv1 = lvc;
|
|
|
|
}
|
2017-10-24 01:49:26 +08:00
|
|
|
|
2020-12-31 16:27:11 +08:00
|
|
|
// CHECK-LABEL: define{{.*}} void @func3()
|
2017-10-24 01:49:26 +08:00
|
|
|
// CHECK: %a = alloca [16 x [1 x float]], align 4, addrspace(5)
|
|
|
|
// CHECK: %[[CAST:.+]] = bitcast [16 x [1 x float]] addrspace(5)* %a to i8 addrspace(5)*
|
Change memcpy/memove/memset to have dest and source alignment attributes (Step 1).
Summary:
Upstream LLVM is changing the the prototypes of the @llvm.memcpy/memmove/memset
intrinsics. This change updates the Clang tests for this change.
The @llvm.memcpy/memmove/memset intrinsics currently have an explicit argument
which is required to be a constant integer. It represents the alignment of the
dest (and source), and so must be the minimum of the actual alignment of the
two.
This change removes the alignment argument in favour of placing the alignment
attribute on the source and destination pointers of the memory intrinsic call.
For example, code which used to read:
call void @llvm.memcpy.p0i8.p0i8.i32(i8* %dest, i8* %src, i32 100, i32 4, i1 false)
will now read
call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %dest, i8* align 4 %src, i32 100, i1 false)
At this time the source and destination alignments must be the same (Step 1).
Step 2 of the change, to be landed shortly, will relax that contraint and allow
the source and destination to have different alignments.
llvm-svn: 322964
2018-01-20 01:12:54 +08:00
|
|
|
// CHECK: call void @llvm.memset.p5i8.i64(i8 addrspace(5)* align 4 %[[CAST]], i8 0, i64 64, i1 false)
|
2017-10-24 01:49:26 +08:00
|
|
|
void func3(void) {
|
|
|
|
float a[16][1] = {{0.}};
|
|
|
|
}
|