annotate clang/test/CodeGenOpenCL/addr-space-struct-arg.cl @ 236:c4bab56944e8 llvm-original

LLVM 16
author kono
date Wed, 09 Nov 2022 17:45:10 +0900
parents 5f17cb93ff66
children 1f2b6ac9f198
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
236
c4bab56944e8 LLVM 16
kono
parents: 223
diff changeset
1 // RUN: %clang_cc1 -no-opaque-pointers %s -emit-llvm -o - -O0 -ffake-address-space-map -triple i686-pc-darwin | FileCheck -enable-var-scope -check-prefixes=ALL,X86 %s
c4bab56944e8 LLVM 16
kono
parents: 223
diff changeset
2 // RUN: %clang_cc1 -no-opaque-pointers %s -emit-llvm -o - -O0 -triple amdgcn | FileCheck -enable-var-scope -check-prefixes=ALL,AMDGCN %s
c4bab56944e8 LLVM 16
kono
parents: 223
diff changeset
3 // RUN: %clang_cc1 -no-opaque-pointers %s -emit-llvm -o - -cl-std=CL2.0 -O0 -triple amdgcn | FileCheck -enable-var-scope -check-prefixes=ALL,AMDGCN,AMDGCN20 %s
c4bab56944e8 LLVM 16
kono
parents: 223
diff changeset
4 // RUN: %clang_cc1 -no-opaque-pointers %s -emit-llvm -o - -cl-std=CL1.2 -O0 -triple spir-unknown-unknown-unknown | FileCheck -enable-var-scope -check-prefixes=SPIR %s
c4bab56944e8 LLVM 16
kono
parents: 223
diff changeset
5 // RUN: %clang_cc1 -no-opaque-pointers %s -emit-llvm -o - -cl-std=CL3.0 -O0 -triple amdgcn -cl-ext=+__opencl_c_program_scope_global_variables | FileCheck -enable-var-scope -check-prefixes=ALL,AMDGCN,AMDGCN20 %s
c4bab56944e8 LLVM 16
kono
parents: 223
diff changeset
6 // RUN: %clang_cc1 -no-opaque-pointers %s -emit-llvm -o - -cl-std=CL3.0 -O0 -triple amdgcn | FileCheck -enable-var-scope -check-prefixes=ALL,AMDGCN %s
150
anatofuz
parents:
diff changeset
7
anatofuz
parents:
diff changeset
8 typedef int int2 __attribute__((ext_vector_type(2)));
anatofuz
parents:
diff changeset
9
anatofuz
parents:
diff changeset
10 typedef struct {
anatofuz
parents:
diff changeset
11 int cells[9];
anatofuz
parents:
diff changeset
12 } Mat3X3;
anatofuz
parents:
diff changeset
13
anatofuz
parents:
diff changeset
14 typedef struct {
anatofuz
parents:
diff changeset
15 int cells[16];
anatofuz
parents:
diff changeset
16 } Mat4X4;
anatofuz
parents:
diff changeset
17
anatofuz
parents:
diff changeset
18 typedef struct {
anatofuz
parents:
diff changeset
19 int cells[1024];
anatofuz
parents:
diff changeset
20 } Mat32X32;
anatofuz
parents:
diff changeset
21
anatofuz
parents:
diff changeset
22 typedef struct {
anatofuz
parents:
diff changeset
23 int cells[4096];
anatofuz
parents:
diff changeset
24 } Mat64X64;
anatofuz
parents:
diff changeset
25
anatofuz
parents:
diff changeset
26 struct StructOneMember {
anatofuz
parents:
diff changeset
27 int2 x;
anatofuz
parents:
diff changeset
28 };
anatofuz
parents:
diff changeset
29
anatofuz
parents:
diff changeset
30 struct StructTwoMember {
anatofuz
parents:
diff changeset
31 int2 x;
anatofuz
parents:
diff changeset
32 int2 y;
anatofuz
parents:
diff changeset
33 };
anatofuz
parents:
diff changeset
34
anatofuz
parents:
diff changeset
35 struct LargeStructOneMember {
anatofuz
parents:
diff changeset
36 int2 x[100];
anatofuz
parents:
diff changeset
37 };
anatofuz
parents:
diff changeset
38
anatofuz
parents:
diff changeset
39 struct LargeStructTwoMember {
anatofuz
parents:
diff changeset
40 int2 x[40];
anatofuz
parents:
diff changeset
41 int2 y[20];
anatofuz
parents:
diff changeset
42 };
anatofuz
parents:
diff changeset
43
223
5f17cb93ff66 LLVM13 (2021/7/18)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 221
diff changeset
44 #if (__OPENCL_C_VERSION__ == 200) || (__OPENCL_C_VERSION__ >= 300 && defined(__opencl_c_program_scope_global_variables))
150
anatofuz
parents:
diff changeset
45 struct LargeStructOneMember g_s;
anatofuz
parents:
diff changeset
46 #endif
anatofuz
parents:
diff changeset
47
236
c4bab56944e8 LLVM 16
kono
parents: 223
diff changeset
48 // X86-LABEL: define{{.*}} void @foo(%struct.Mat4X4* noalias sret(%struct.Mat4X4) align 4 %agg.result, %struct.Mat3X3* noundef byval(%struct.Mat3X3) align 4 %in)
221
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
49 // AMDGCN-LABEL: define{{.*}} %struct.Mat4X4 @foo([9 x i32] %in.coerce)
150
anatofuz
parents:
diff changeset
50 Mat4X4 __attribute__((noinline)) foo(Mat3X3 in) {
anatofuz
parents:
diff changeset
51 Mat4X4 out;
anatofuz
parents:
diff changeset
52 return out;
anatofuz
parents:
diff changeset
53 }
anatofuz
parents:
diff changeset
54
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
55 // ALL-LABEL: define {{.*}} void @ker
150
anatofuz
parents:
diff changeset
56 // Expect two mem copies: one for the argument "in", and one for
anatofuz
parents:
diff changeset
57 // the return value.
anatofuz
parents:
diff changeset
58 // X86: call void @llvm.memcpy.p0i8.p1i8.i32(i8*
anatofuz
parents:
diff changeset
59 // X86: call void @llvm.memcpy.p1i8.p0i8.i32(i8 addrspace(1)*
anatofuz
parents:
diff changeset
60
anatofuz
parents:
diff changeset
61 // AMDGCN: load [9 x i32], [9 x i32] addrspace(1)*
anatofuz
parents:
diff changeset
62 // AMDGCN: call %struct.Mat4X4 @foo([9 x i32]
anatofuz
parents:
diff changeset
63 // AMDGCN: call void @llvm.memcpy.p1i8.p5i8.i64(i8 addrspace(1)*
anatofuz
parents:
diff changeset
64 kernel void ker(global Mat3X3 *in, global Mat4X4 *out) {
anatofuz
parents:
diff changeset
65 out[0] = foo(in[1]);
anatofuz
parents:
diff changeset
66 }
anatofuz
parents:
diff changeset
67
236
c4bab56944e8 LLVM 16
kono
parents: 223
diff changeset
68 // X86-LABEL: define{{.*}} void @foo_large(%struct.Mat64X64* noalias sret(%struct.Mat64X64) align 4 %agg.result, %struct.Mat32X32* noundef byval(%struct.Mat32X32) align 4 %in)
c4bab56944e8 LLVM 16
kono
parents: 223
diff changeset
69 // AMDGCN-LABEL: define{{.*}} void @foo_large(%struct.Mat64X64 addrspace(5)* noalias sret(%struct.Mat64X64) align 4 %agg.result, %struct.Mat32X32 addrspace(5)* noundef byval(%struct.Mat32X32) align 4 %in)
150
anatofuz
parents:
diff changeset
70 Mat64X64 __attribute__((noinline)) foo_large(Mat32X32 in) {
anatofuz
parents:
diff changeset
71 Mat64X64 out;
anatofuz
parents:
diff changeset
72 return out;
anatofuz
parents:
diff changeset
73 }
anatofuz
parents:
diff changeset
74
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
75 // ALL-LABEL: define {{.*}} void @ker_large
150
anatofuz
parents:
diff changeset
76 // Expect two mem copies: one for the argument "in", and one for
anatofuz
parents:
diff changeset
77 // the return value.
anatofuz
parents:
diff changeset
78 // X86: call void @llvm.memcpy.p0i8.p1i8.i32(i8*
anatofuz
parents:
diff changeset
79 // X86: call void @llvm.memcpy.p1i8.p0i8.i32(i8 addrspace(1)*
anatofuz
parents:
diff changeset
80 // AMDGCN: call void @llvm.memcpy.p5i8.p1i8.i64(i8 addrspace(5)*
anatofuz
parents:
diff changeset
81 // AMDGCN: call void @llvm.memcpy.p1i8.p5i8.i64(i8 addrspace(1)*
anatofuz
parents:
diff changeset
82 kernel void ker_large(global Mat32X32 *in, global Mat64X64 *out) {
anatofuz
parents:
diff changeset
83 out[0] = foo_large(in[1]);
anatofuz
parents:
diff changeset
84 }
anatofuz
parents:
diff changeset
85
221
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
86 // AMDGCN-LABEL: define{{.*}} void @FuncOneMember(<2 x i32> %u.coerce)
150
anatofuz
parents:
diff changeset
87 void FuncOneMember(struct StructOneMember u) {
anatofuz
parents:
diff changeset
88 u.x = (int2)(0, 0);
anatofuz
parents:
diff changeset
89 }
anatofuz
parents:
diff changeset
90
236
c4bab56944e8 LLVM 16
kono
parents: 223
diff changeset
91 // AMDGCN-LABEL: define{{.*}} void @FuncOneLargeMember(%struct.LargeStructOneMember addrspace(5)* noundef byval(%struct.LargeStructOneMember) align 8 %u)
150
anatofuz
parents:
diff changeset
92 // AMDGCN-NOT: addrspacecast
anatofuz
parents:
diff changeset
93 // AMDGCN: store <2 x i32> %{{.*}}, <2 x i32> addrspace(5)*
anatofuz
parents:
diff changeset
94 void FuncOneLargeMember(struct LargeStructOneMember u) {
anatofuz
parents:
diff changeset
95 u.x[0] = (int2)(0, 0);
anatofuz
parents:
diff changeset
96 }
anatofuz
parents:
diff changeset
97
221
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
98 // AMDGCN20-LABEL: define{{.*}} void @test_indirect_arg_globl()
150
anatofuz
parents:
diff changeset
99 // AMDGCN20: %[[byval_temp:.*]] = alloca %struct.LargeStructOneMember, align 8, addrspace(5)
anatofuz
parents:
diff changeset
100 // AMDGCN20: %[[r0:.*]] = bitcast %struct.LargeStructOneMember addrspace(5)* %[[byval_temp]] to i8 addrspace(5)*
anatofuz
parents:
diff changeset
101 // AMDGCN20: call void @llvm.memcpy.p5i8.p1i8.i64(i8 addrspace(5)* align 8 %[[r0]], i8 addrspace(1)* align 8 bitcast (%struct.LargeStructOneMember addrspace(1)* @g_s to i8 addrspace(1)*), i64 800, i1 false)
236
c4bab56944e8 LLVM 16
kono
parents: 223
diff changeset
102 // AMDGCN20: call void @FuncOneLargeMember(%struct.LargeStructOneMember addrspace(5)* noundef byval(%struct.LargeStructOneMember) align 8 %[[byval_temp]])
223
5f17cb93ff66 LLVM13 (2021/7/18)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 221
diff changeset
103 #if (__OPENCL_C_VERSION__ == 200) || (__OPENCL_C_VERSION__ >= 300 && defined(__opencl_c_program_scope_global_variables))
150
anatofuz
parents:
diff changeset
104 void test_indirect_arg_globl(void) {
anatofuz
parents:
diff changeset
105 FuncOneLargeMember(g_s);
anatofuz
parents:
diff changeset
106 }
anatofuz
parents:
diff changeset
107 #endif
anatofuz
parents:
diff changeset
108
221
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
109 // AMDGCN-LABEL: define{{.*}} amdgpu_kernel void @test_indirect_arg_local()
150
anatofuz
parents:
diff changeset
110 // AMDGCN: %[[byval_temp:.*]] = alloca %struct.LargeStructOneMember, align 8, addrspace(5)
anatofuz
parents:
diff changeset
111 // AMDGCN: %[[r0:.*]] = bitcast %struct.LargeStructOneMember addrspace(5)* %[[byval_temp]] to i8 addrspace(5)*
anatofuz
parents:
diff changeset
112 // AMDGCN: call void @llvm.memcpy.p5i8.p3i8.i64(i8 addrspace(5)* align 8 %[[r0]], i8 addrspace(3)* align 8 bitcast (%struct.LargeStructOneMember addrspace(3)* @test_indirect_arg_local.l_s to i8 addrspace(3)*), i64 800, i1 false)
236
c4bab56944e8 LLVM 16
kono
parents: 223
diff changeset
113 // AMDGCN: call void @FuncOneLargeMember(%struct.LargeStructOneMember addrspace(5)* noundef byval(%struct.LargeStructOneMember) align 8 %[[byval_temp]])
150
anatofuz
parents:
diff changeset
114 kernel void test_indirect_arg_local(void) {
anatofuz
parents:
diff changeset
115 local struct LargeStructOneMember l_s;
anatofuz
parents:
diff changeset
116 FuncOneLargeMember(l_s);
anatofuz
parents:
diff changeset
117 }
anatofuz
parents:
diff changeset
118
221
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
119 // AMDGCN-LABEL: define{{.*}} void @test_indirect_arg_private()
150
anatofuz
parents:
diff changeset
120 // AMDGCN: %[[p_s:.*]] = alloca %struct.LargeStructOneMember, align 8, addrspace(5)
anatofuz
parents:
diff changeset
121 // AMDGCN-NOT: @llvm.memcpy
236
c4bab56944e8 LLVM 16
kono
parents: 223
diff changeset
122 // AMDGCN-NEXT: call void @FuncOneLargeMember(%struct.LargeStructOneMember addrspace(5)* noundef byval(%struct.LargeStructOneMember) align 8 %[[p_s]])
150
anatofuz
parents:
diff changeset
123 void test_indirect_arg_private(void) {
anatofuz
parents:
diff changeset
124 struct LargeStructOneMember p_s;
anatofuz
parents:
diff changeset
125 FuncOneLargeMember(p_s);
anatofuz
parents:
diff changeset
126 }
anatofuz
parents:
diff changeset
127
221
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
128 // AMDGCN-LABEL: define{{.*}} amdgpu_kernel void @KernelOneMember
150
anatofuz
parents:
diff changeset
129 // AMDGCN-SAME: (<2 x i32> %[[u_coerce:.*]])
anatofuz
parents:
diff changeset
130 // AMDGCN: %[[u:.*]] = alloca %struct.StructOneMember, align 8, addrspace(5)
anatofuz
parents:
diff changeset
131 // AMDGCN: %[[coerce_dive:.*]] = getelementptr inbounds %struct.StructOneMember, %struct.StructOneMember addrspace(5)* %[[u]], i32 0, i32 0
anatofuz
parents:
diff changeset
132 // AMDGCN: store <2 x i32> %[[u_coerce]], <2 x i32> addrspace(5)* %[[coerce_dive]]
anatofuz
parents:
diff changeset
133 // AMDGCN: call void @FuncOneMember(<2 x i32>
anatofuz
parents:
diff changeset
134 kernel void KernelOneMember(struct StructOneMember u) {
anatofuz
parents:
diff changeset
135 FuncOneMember(u);
anatofuz
parents:
diff changeset
136 }
anatofuz
parents:
diff changeset
137
anatofuz
parents:
diff changeset
138 // SPIR: call void @llvm.memcpy.p0i8.p1i8.i32
anatofuz
parents:
diff changeset
139 // SPIR-NOT: addrspacecast
anatofuz
parents:
diff changeset
140 kernel void KernelOneMemberSpir(global struct StructOneMember* u) {
anatofuz
parents:
diff changeset
141 FuncOneMember(*u);
anatofuz
parents:
diff changeset
142 }
anatofuz
parents:
diff changeset
143
221
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
144 // AMDGCN-LABEL: define{{.*}} amdgpu_kernel void @KernelLargeOneMember(
150
anatofuz
parents:
diff changeset
145 // AMDGCN: %[[U:.*]] = alloca %struct.LargeStructOneMember, align 8, addrspace(5)
anatofuz
parents:
diff changeset
146 // AMDGCN: store %struct.LargeStructOneMember %u.coerce, %struct.LargeStructOneMember addrspace(5)* %[[U]], align 8
236
c4bab56944e8 LLVM 16
kono
parents: 223
diff changeset
147 // AMDGCN: call void @FuncOneLargeMember(%struct.LargeStructOneMember addrspace(5)* noundef byval(%struct.LargeStructOneMember) align 8 %[[U]])
150
anatofuz
parents:
diff changeset
148 kernel void KernelLargeOneMember(struct LargeStructOneMember u) {
anatofuz
parents:
diff changeset
149 FuncOneLargeMember(u);
anatofuz
parents:
diff changeset
150 }
anatofuz
parents:
diff changeset
151
221
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
152 // AMDGCN-LABEL: define{{.*}} void @FuncTwoMember(<2 x i32> %u.coerce0, <2 x i32> %u.coerce1)
150
anatofuz
parents:
diff changeset
153 void FuncTwoMember(struct StructTwoMember u) {
anatofuz
parents:
diff changeset
154 u.y = (int2)(0, 0);
anatofuz
parents:
diff changeset
155 }
anatofuz
parents:
diff changeset
156
236
c4bab56944e8 LLVM 16
kono
parents: 223
diff changeset
157 // AMDGCN-LABEL: define{{.*}} void @FuncLargeTwoMember(%struct.LargeStructTwoMember addrspace(5)* noundef byval(%struct.LargeStructTwoMember) align 8 %u)
150
anatofuz
parents:
diff changeset
158 void FuncLargeTwoMember(struct LargeStructTwoMember u) {
anatofuz
parents:
diff changeset
159 u.y[0] = (int2)(0, 0);
anatofuz
parents:
diff changeset
160 }
anatofuz
parents:
diff changeset
161
221
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
162 // AMDGCN-LABEL: define{{.*}} amdgpu_kernel void @KernelTwoMember
150
anatofuz
parents:
diff changeset
163 // AMDGCN-SAME: (%struct.StructTwoMember %[[u_coerce:.*]])
anatofuz
parents:
diff changeset
164 // AMDGCN: %[[u:.*]] = alloca %struct.StructTwoMember, align 8, addrspace(5)
anatofuz
parents:
diff changeset
165 // AMDGCN: %[[LD0:.*]] = load <2 x i32>, <2 x i32> addrspace(5)*
anatofuz
parents:
diff changeset
166 // AMDGCN: %[[LD1:.*]] = load <2 x i32>, <2 x i32> addrspace(5)*
anatofuz
parents:
diff changeset
167 // AMDGCN: call void @FuncTwoMember(<2 x i32> %[[LD0]], <2 x i32> %[[LD1]])
anatofuz
parents:
diff changeset
168 kernel void KernelTwoMember(struct StructTwoMember u) {
anatofuz
parents:
diff changeset
169 FuncTwoMember(u);
anatofuz
parents:
diff changeset
170 }
anatofuz
parents:
diff changeset
171
221
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
172 // AMDGCN-LABEL: define{{.*}} amdgpu_kernel void @KernelLargeTwoMember
150
anatofuz
parents:
diff changeset
173 // AMDGCN-SAME: (%struct.LargeStructTwoMember %[[u_coerce:.*]])
anatofuz
parents:
diff changeset
174 // AMDGCN: %[[u:.*]] = alloca %struct.LargeStructTwoMember, align 8, addrspace(5)
anatofuz
parents:
diff changeset
175 // AMDGCN: store %struct.LargeStructTwoMember %[[u_coerce]], %struct.LargeStructTwoMember addrspace(5)* %[[u]]
236
c4bab56944e8 LLVM 16
kono
parents: 223
diff changeset
176 // AMDGCN: call void @FuncLargeTwoMember(%struct.LargeStructTwoMember addrspace(5)* noundef byval(%struct.LargeStructTwoMember) align 8 %[[u]])
150
anatofuz
parents:
diff changeset
177 kernel void KernelLargeTwoMember(struct LargeStructTwoMember u) {
anatofuz
parents:
diff changeset
178 FuncLargeTwoMember(u);
anatofuz
parents:
diff changeset
179 }