Mercurial > hg > CbC > CbC_llvm
comparison 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 |
comparison
equal
deleted
inserted
replaced
232:70dce7da266c | 236:c4bab56944e8 |
---|---|
1 // RUN: %clang_cc1 %s -emit-llvm -o - -O0 -ffake-address-space-map -triple i686-pc-darwin | FileCheck -enable-var-scope -check-prefixes=ALL,X86 %s | 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 |
2 // RUN: %clang_cc1 %s -emit-llvm -o - -O0 -triple amdgcn | FileCheck -enable-var-scope -check-prefixes=ALL,AMDGCN %s | 2 // RUN: %clang_cc1 -no-opaque-pointers %s -emit-llvm -o - -O0 -triple amdgcn | FileCheck -enable-var-scope -check-prefixes=ALL,AMDGCN %s |
3 // RUN: %clang_cc1 %s -emit-llvm -o - -cl-std=CL2.0 -O0 -triple amdgcn | FileCheck -enable-var-scope -check-prefixes=ALL,AMDGCN,AMDGCN20 %s | 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 |
4 // RUN: %clang_cc1 %s -emit-llvm -o - -cl-std=CL1.2 -O0 -triple spir-unknown-unknown-unknown | FileCheck -enable-var-scope -check-prefixes=SPIR %s | 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 |
5 // RUN: %clang_cc1 %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 | 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 |
6 // RUN: %clang_cc1 %s -emit-llvm -o - -cl-std=CL3.0 -O0 -triple amdgcn | FileCheck -enable-var-scope -check-prefixes=ALL,AMDGCN %s | 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 |
7 | 7 |
8 typedef int int2 __attribute__((ext_vector_type(2))); | 8 typedef int int2 __attribute__((ext_vector_type(2))); |
9 | 9 |
10 typedef struct { | 10 typedef struct { |
11 int cells[9]; | 11 int cells[9]; |
43 | 43 |
44 #if (__OPENCL_C_VERSION__ == 200) || (__OPENCL_C_VERSION__ >= 300 && defined(__opencl_c_program_scope_global_variables)) | 44 #if (__OPENCL_C_VERSION__ == 200) || (__OPENCL_C_VERSION__ >= 300 && defined(__opencl_c_program_scope_global_variables)) |
45 struct LargeStructOneMember g_s; | 45 struct LargeStructOneMember g_s; |
46 #endif | 46 #endif |
47 | 47 |
48 // X86-LABEL: define{{.*}} void @foo(%struct.Mat4X4* noalias sret(%struct.Mat4X4) align 4 %agg.result, %struct.Mat3X3* byval(%struct.Mat3X3) align 4 %in) | 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) |
49 // AMDGCN-LABEL: define{{.*}} %struct.Mat4X4 @foo([9 x i32] %in.coerce) | 49 // AMDGCN-LABEL: define{{.*}} %struct.Mat4X4 @foo([9 x i32] %in.coerce) |
50 Mat4X4 __attribute__((noinline)) foo(Mat3X3 in) { | 50 Mat4X4 __attribute__((noinline)) foo(Mat3X3 in) { |
51 Mat4X4 out; | 51 Mat4X4 out; |
52 return out; | 52 return out; |
53 } | 53 } |
63 // AMDGCN: call void @llvm.memcpy.p1i8.p5i8.i64(i8 addrspace(1)* | 63 // AMDGCN: call void @llvm.memcpy.p1i8.p5i8.i64(i8 addrspace(1)* |
64 kernel void ker(global Mat3X3 *in, global Mat4X4 *out) { | 64 kernel void ker(global Mat3X3 *in, global Mat4X4 *out) { |
65 out[0] = foo(in[1]); | 65 out[0] = foo(in[1]); |
66 } | 66 } |
67 | 67 |
68 // X86-LABEL: define{{.*}} void @foo_large(%struct.Mat64X64* noalias sret(%struct.Mat64X64) align 4 %agg.result, %struct.Mat32X32* byval(%struct.Mat32X32) align 4 %in) | 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) |
69 // AMDGCN-LABEL: define{{.*}} void @foo_large(%struct.Mat64X64 addrspace(5)* noalias sret(%struct.Mat64X64) align 4 %agg.result, %struct.Mat32X32 addrspace(5)* byval(%struct.Mat32X32) align 4 %in) | 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) |
70 Mat64X64 __attribute__((noinline)) foo_large(Mat32X32 in) { | 70 Mat64X64 __attribute__((noinline)) foo_large(Mat32X32 in) { |
71 Mat64X64 out; | 71 Mat64X64 out; |
72 return out; | 72 return out; |
73 } | 73 } |
74 | 74 |
86 // AMDGCN-LABEL: define{{.*}} void @FuncOneMember(<2 x i32> %u.coerce) | 86 // AMDGCN-LABEL: define{{.*}} void @FuncOneMember(<2 x i32> %u.coerce) |
87 void FuncOneMember(struct StructOneMember u) { | 87 void FuncOneMember(struct StructOneMember u) { |
88 u.x = (int2)(0, 0); | 88 u.x = (int2)(0, 0); |
89 } | 89 } |
90 | 90 |
91 // AMDGCN-LABEL: define{{.*}} void @FuncOneLargeMember(%struct.LargeStructOneMember addrspace(5)* byval(%struct.LargeStructOneMember) align 8 %u) | 91 // AMDGCN-LABEL: define{{.*}} void @FuncOneLargeMember(%struct.LargeStructOneMember addrspace(5)* noundef byval(%struct.LargeStructOneMember) align 8 %u) |
92 // AMDGCN-NOT: addrspacecast | 92 // AMDGCN-NOT: addrspacecast |
93 // AMDGCN: store <2 x i32> %{{.*}}, <2 x i32> addrspace(5)* | 93 // AMDGCN: store <2 x i32> %{{.*}}, <2 x i32> addrspace(5)* |
94 void FuncOneLargeMember(struct LargeStructOneMember u) { | 94 void FuncOneLargeMember(struct LargeStructOneMember u) { |
95 u.x[0] = (int2)(0, 0); | 95 u.x[0] = (int2)(0, 0); |
96 } | 96 } |
97 | 97 |
98 // AMDGCN20-LABEL: define{{.*}} void @test_indirect_arg_globl() | 98 // AMDGCN20-LABEL: define{{.*}} void @test_indirect_arg_globl() |
99 // AMDGCN20: %[[byval_temp:.*]] = alloca %struct.LargeStructOneMember, align 8, addrspace(5) | 99 // AMDGCN20: %[[byval_temp:.*]] = alloca %struct.LargeStructOneMember, align 8, addrspace(5) |
100 // AMDGCN20: %[[r0:.*]] = bitcast %struct.LargeStructOneMember addrspace(5)* %[[byval_temp]] to i8 addrspace(5)* | 100 // AMDGCN20: %[[r0:.*]] = bitcast %struct.LargeStructOneMember addrspace(5)* %[[byval_temp]] to i8 addrspace(5)* |
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) | 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) |
102 // AMDGCN20: call void @FuncOneLargeMember(%struct.LargeStructOneMember addrspace(5)* byval(%struct.LargeStructOneMember) align 8 %[[byval_temp]]) | 102 // AMDGCN20: call void @FuncOneLargeMember(%struct.LargeStructOneMember addrspace(5)* noundef byval(%struct.LargeStructOneMember) align 8 %[[byval_temp]]) |
103 #if (__OPENCL_C_VERSION__ == 200) || (__OPENCL_C_VERSION__ >= 300 && defined(__opencl_c_program_scope_global_variables)) | 103 #if (__OPENCL_C_VERSION__ == 200) || (__OPENCL_C_VERSION__ >= 300 && defined(__opencl_c_program_scope_global_variables)) |
104 void test_indirect_arg_globl(void) { | 104 void test_indirect_arg_globl(void) { |
105 FuncOneLargeMember(g_s); | 105 FuncOneLargeMember(g_s); |
106 } | 106 } |
107 #endif | 107 #endif |
108 | 108 |
109 // AMDGCN-LABEL: define{{.*}} amdgpu_kernel void @test_indirect_arg_local() | 109 // AMDGCN-LABEL: define{{.*}} amdgpu_kernel void @test_indirect_arg_local() |
110 // AMDGCN: %[[byval_temp:.*]] = alloca %struct.LargeStructOneMember, align 8, addrspace(5) | 110 // AMDGCN: %[[byval_temp:.*]] = alloca %struct.LargeStructOneMember, align 8, addrspace(5) |
111 // AMDGCN: %[[r0:.*]] = bitcast %struct.LargeStructOneMember addrspace(5)* %[[byval_temp]] to i8 addrspace(5)* | 111 // AMDGCN: %[[r0:.*]] = bitcast %struct.LargeStructOneMember addrspace(5)* %[[byval_temp]] to i8 addrspace(5)* |
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) | 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) |
113 // AMDGCN: call void @FuncOneLargeMember(%struct.LargeStructOneMember addrspace(5)* byval(%struct.LargeStructOneMember) align 8 %[[byval_temp]]) | 113 // AMDGCN: call void @FuncOneLargeMember(%struct.LargeStructOneMember addrspace(5)* noundef byval(%struct.LargeStructOneMember) align 8 %[[byval_temp]]) |
114 kernel void test_indirect_arg_local(void) { | 114 kernel void test_indirect_arg_local(void) { |
115 local struct LargeStructOneMember l_s; | 115 local struct LargeStructOneMember l_s; |
116 FuncOneLargeMember(l_s); | 116 FuncOneLargeMember(l_s); |
117 } | 117 } |
118 | 118 |
119 // AMDGCN-LABEL: define{{.*}} void @test_indirect_arg_private() | 119 // AMDGCN-LABEL: define{{.*}} void @test_indirect_arg_private() |
120 // AMDGCN: %[[p_s:.*]] = alloca %struct.LargeStructOneMember, align 8, addrspace(5) | 120 // AMDGCN: %[[p_s:.*]] = alloca %struct.LargeStructOneMember, align 8, addrspace(5) |
121 // AMDGCN-NOT: @llvm.memcpy | 121 // AMDGCN-NOT: @llvm.memcpy |
122 // AMDGCN-NEXT: call void @FuncOneLargeMember(%struct.LargeStructOneMember addrspace(5)* byval(%struct.LargeStructOneMember) align 8 %[[p_s]]) | 122 // AMDGCN-NEXT: call void @FuncOneLargeMember(%struct.LargeStructOneMember addrspace(5)* noundef byval(%struct.LargeStructOneMember) align 8 %[[p_s]]) |
123 void test_indirect_arg_private(void) { | 123 void test_indirect_arg_private(void) { |
124 struct LargeStructOneMember p_s; | 124 struct LargeStructOneMember p_s; |
125 FuncOneLargeMember(p_s); | 125 FuncOneLargeMember(p_s); |
126 } | 126 } |
127 | 127 |
142 } | 142 } |
143 | 143 |
144 // AMDGCN-LABEL: define{{.*}} amdgpu_kernel void @KernelLargeOneMember( | 144 // AMDGCN-LABEL: define{{.*}} amdgpu_kernel void @KernelLargeOneMember( |
145 // AMDGCN: %[[U:.*]] = alloca %struct.LargeStructOneMember, align 8, addrspace(5) | 145 // AMDGCN: %[[U:.*]] = alloca %struct.LargeStructOneMember, align 8, addrspace(5) |
146 // AMDGCN: store %struct.LargeStructOneMember %u.coerce, %struct.LargeStructOneMember addrspace(5)* %[[U]], align 8 | 146 // AMDGCN: store %struct.LargeStructOneMember %u.coerce, %struct.LargeStructOneMember addrspace(5)* %[[U]], align 8 |
147 // AMDGCN: call void @FuncOneLargeMember(%struct.LargeStructOneMember addrspace(5)* byval(%struct.LargeStructOneMember) align 8 %[[U]]) | 147 // AMDGCN: call void @FuncOneLargeMember(%struct.LargeStructOneMember addrspace(5)* noundef byval(%struct.LargeStructOneMember) align 8 %[[U]]) |
148 kernel void KernelLargeOneMember(struct LargeStructOneMember u) { | 148 kernel void KernelLargeOneMember(struct LargeStructOneMember u) { |
149 FuncOneLargeMember(u); | 149 FuncOneLargeMember(u); |
150 } | 150 } |
151 | 151 |
152 // AMDGCN-LABEL: define{{.*}} void @FuncTwoMember(<2 x i32> %u.coerce0, <2 x i32> %u.coerce1) | 152 // AMDGCN-LABEL: define{{.*}} void @FuncTwoMember(<2 x i32> %u.coerce0, <2 x i32> %u.coerce1) |
153 void FuncTwoMember(struct StructTwoMember u) { | 153 void FuncTwoMember(struct StructTwoMember u) { |
154 u.y = (int2)(0, 0); | 154 u.y = (int2)(0, 0); |
155 } | 155 } |
156 | 156 |
157 // AMDGCN-LABEL: define{{.*}} void @FuncLargeTwoMember(%struct.LargeStructTwoMember addrspace(5)* byval(%struct.LargeStructTwoMember) align 8 %u) | 157 // AMDGCN-LABEL: define{{.*}} void @FuncLargeTwoMember(%struct.LargeStructTwoMember addrspace(5)* noundef byval(%struct.LargeStructTwoMember) align 8 %u) |
158 void FuncLargeTwoMember(struct LargeStructTwoMember u) { | 158 void FuncLargeTwoMember(struct LargeStructTwoMember u) { |
159 u.y[0] = (int2)(0, 0); | 159 u.y[0] = (int2)(0, 0); |
160 } | 160 } |
161 | 161 |
162 // AMDGCN-LABEL: define{{.*}} amdgpu_kernel void @KernelTwoMember | 162 // AMDGCN-LABEL: define{{.*}} amdgpu_kernel void @KernelTwoMember |
171 | 171 |
172 // AMDGCN-LABEL: define{{.*}} amdgpu_kernel void @KernelLargeTwoMember | 172 // AMDGCN-LABEL: define{{.*}} amdgpu_kernel void @KernelLargeTwoMember |
173 // AMDGCN-SAME: (%struct.LargeStructTwoMember %[[u_coerce:.*]]) | 173 // AMDGCN-SAME: (%struct.LargeStructTwoMember %[[u_coerce:.*]]) |
174 // AMDGCN: %[[u:.*]] = alloca %struct.LargeStructTwoMember, align 8, addrspace(5) | 174 // AMDGCN: %[[u:.*]] = alloca %struct.LargeStructTwoMember, align 8, addrspace(5) |
175 // AMDGCN: store %struct.LargeStructTwoMember %[[u_coerce]], %struct.LargeStructTwoMember addrspace(5)* %[[u]] | 175 // AMDGCN: store %struct.LargeStructTwoMember %[[u_coerce]], %struct.LargeStructTwoMember addrspace(5)* %[[u]] |
176 // AMDGCN: call void @FuncLargeTwoMember(%struct.LargeStructTwoMember addrspace(5)* byval(%struct.LargeStructTwoMember) align 8 %[[u]]) | 176 // AMDGCN: call void @FuncLargeTwoMember(%struct.LargeStructTwoMember addrspace(5)* noundef byval(%struct.LargeStructTwoMember) align 8 %[[u]]) |
177 kernel void KernelLargeTwoMember(struct LargeStructTwoMember u) { | 177 kernel void KernelLargeTwoMember(struct LargeStructTwoMember u) { |
178 FuncLargeTwoMember(u); | 178 FuncLargeTwoMember(u); |
179 } | 179 } |