Skip to content

Commit 362d840

Browse files
dwoodwor-intelagainull
authored andcommitted
Fix translation of EnqueueKernel and block functions (#1857)
This specifies the right parameter types for EnqueueKernel and for block functions (with mangled names of the form {__*,}_block_invoke{_*,}{_kernel,}), so that SPIR-V code is generated for these as expected. This fixes a crash in the Intel OpenCL CPU backend, and likely other SPIR-V consumers. Original commit: KhronosGroup/SPIRV-LLVM-Translator@9a1cce0
1 parent 1c3f610 commit 362d840

File tree

4 files changed

+55
-39
lines changed

4 files changed

+55
-39
lines changed

llvm-spirv/lib/SPIRV/SPIRVTypeScavenger.cpp

+20
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
#include "llvm/IR/IntrinsicInst.h"
4848
#include "llvm/IR/NoFolder.h"
4949
#include "llvm/IR/Operator.h"
50+
#include "llvm/Support/Regex.h"
5051

5152
#define DEBUG_TYPE "type-scavenger"
5253

@@ -192,6 +193,10 @@ bool SPIRVTypeScavenger::typeIntrinsicCall(
192193
ArgTys.emplace_back(2, Type::getInt8Ty(Ctx));
193194
} else if (TargetFn->getName() == "__spirv_GetKernelNDrangeSubGroupCount__") {
194195
ArgTys.emplace_back(2, Type::getInt8Ty(Ctx));
196+
} else if (TargetFn->getName().starts_with("__spirv_EnqueueKernel__")) {
197+
ArgTys.emplace_back(4, TargetExtType::get(Ctx, "spirv.DeviceEvent"));
198+
ArgTys.emplace_back(5, TargetExtType::get(Ctx, "spirv.DeviceEvent"));
199+
ArgTys.emplace_back(7, Type::getInt8Ty(Ctx));
195200
} else
196201
return false;
197202

@@ -226,6 +231,21 @@ void SPIRVTypeScavenger::deduceFunctionType(Function &F) {
226231
DeducedTypes[Arg] = Ty;
227232
}
228233

234+
// The first non-sret argument of block_invoke functions is the block capture
235+
// struct, which should be passed as an i8*.
236+
static const Regex BlockInvokeRegex(
237+
"^(__.+)?_block_invoke(_[0-9]+)?(_kernel)?$");
238+
if (BlockInvokeRegex.match(F.getName())) {
239+
for (Argument *Arg : PointerArgs) {
240+
if (!Arg->hasAttribute(Attribute::StructRet)) {
241+
DeducedTypes[Arg] = Type::getInt8Ty(F.getContext());
242+
LLVM_DEBUG(dbgs() << "Arg " << Arg->getArgNo() << " of " << F.getName()
243+
<< " has type i8\n");
244+
break;
245+
}
246+
}
247+
}
248+
229249
// At this point, anything that we can get definitively correct is going to
230250
// come from declarations of builtins. If we have the actual implementation of
231251
// the function available, we should try to recover types from the function

llvm-spirv/test/transcoding/block_w_struct_return.cl

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
// RUN: %clang_cc1 -triple spir -cl-std=cl2.0 -disable-llvm-passes -fdeclare-opencl-builtins -finclude-default-header %s -emit-llvm-bc -o %t.bc -no-opaque-pointers
1+
// RUN: %clang_cc1 -triple spir -cl-std=cl2.0 -disable-llvm-passes -fdeclare-opencl-builtins -finclude-default-header %s -emit-llvm-bc -o %t.bc
22

3-
// RUN: llvm-spirv --spirv-max-version=1.1 %t.bc -opaque-pointers=0 -spirv-text -o - | FileCheck %s --check-prefix=CHECK-SPIRV
4-
// RUN: llvm-spirv --spirv-max-version=1.1 %t.bc -opaque-pointers=0 -o %t.spirv1.1.spv
3+
// RUN: llvm-spirv --spirv-max-version=1.1 %t.bc -spirv-text -o - | FileCheck %s --check-prefix=CHECK-SPIRV
4+
// RUN: llvm-spirv --spirv-max-version=1.1 %t.bc -o %t.spirv1.1.spv
55
// RUN: spirv-val --target-env spv1.1 %t.spirv1.1.spv
66
// RUN: llvm-spirv -r -emit-opaque-pointers %t.spirv1.1.spv -o %t.rev.bc
77
// RUN: llvm-dis %t.rev.bc
88
// RUN: FileCheck < %t.rev.ll %s --check-prefix=CHECK-LLVM
99

10-
// RUN: llvm-spirv --spirv-max-version=1.4 %t.bc -opaque-pointers=0 -spirv-text -o - | FileCheck %s --check-prefix=CHECK-SPIRV
11-
// RUN: llvm-spirv --spirv-max-version=1.4 %t.bc -opaque-pointers=0 -o %t.spirv1.4.spv
10+
// RUN: llvm-spirv --spirv-max-version=1.4 %t.bc -spirv-text -o - | FileCheck %s --check-prefix=CHECK-SPIRV
11+
// RUN: llvm-spirv --spirv-max-version=1.4 %t.bc -o %t.spirv1.4.spv
1212
// RUN: spirv-val --target-env spv1.4 %t.spirv1.4.spv
1313
// RUN: llvm-spirv -r -emit-opaque-pointers %t.spirv1.4.spv -o %t.rev.bc
1414
// RUN: llvm-dis %t.rev.bc
@@ -48,7 +48,7 @@ kernel void block_ret_struct(__global int* res)
4848

4949
// CHECK-SPIRV: 4 Variable [[StructPtrTy]] [[StructArg:[0-9]+]] 7
5050
// CHECK-SPIRV: 4 Variable [[StructPtrTy]] [[StructRet:[0-9]+]] 7
51-
// CHECK-SPIRV: 4 PtrCastToGeneric [[Int8Ptr]] [[BlockLit:[0-9]+]] {{[0-9]+}}
51+
// CHECK-SPIRV: 4 Bitcast [[Int8Ptr]] [[BlockLit:[0-9]+]] {{[0-9]+}}
5252
// CHECK-SPIRV: 7 FunctionCall {{[0-9]+}} {{[0-9]+}} [[BlockInv]] [[StructRet]] [[BlockLit]] [[StructArg]]
5353

5454
// CHECK-LLVM: %[[StructA:.*]] = type { i32 }

llvm-spirv/test/transcoding/enqueue_kernel.cl

+24-28
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
// RUN: %clang_cc1 -triple spir-unknown-unknown -O0 -cl-std=CL2.0 -emit-llvm-bc %s -o %t.bc -no-opaque-pointers
2-
// RUN: llvm-spirv %t.bc -opaque-pointers=0 -spirv-text -o %t.spv.txt
1+
// RUN: %clang_cc1 -triple spir-unknown-unknown -O0 -cl-std=CL2.0 -emit-llvm-bc %s -o %t.bc
2+
// RUN: llvm-spirv %t.bc -spirv-text -o %t.spv.txt
33
// RUN: FileCheck < %t.spv.txt %s --check-prefix=CHECK-SPIRV
4-
// RUN: llvm-spirv %t.bc -opaque-pointers=0 -o %t.spv
4+
// RUN: llvm-spirv %t.bc -o %t.spv
55
// RUN: spirv-val %t.spv
66
// RUN: llvm-spirv -r %t.spv --spirv-target-env CL2.0 -o %t.rev.bc
77
// RUN: llvm-dis -opaque-pointers=0 %t.rev.bc
@@ -37,12 +37,11 @@
3737
// CHECK-SPIRV: ConstantNull [[EventPtrTy]] [[EventNull:[0-9]+]]
3838

3939
// CHECK-LLVM: [[BlockTy1:%[0-9a-z\.]+]] = type { i32, i32, i8 addrspace(4)* }
40-
// CHECK-LLVM: [[BlockTy2:%[0-9a-z\.]+]] = type <{ i32, i32, i8 addrspace(4)*, i32 addrspace(1)*, i32, i8 }>
41-
// CHECK-LLVM: [[BlockTy3:%[0-9a-z\.]+]] = type <{ i32, i32, i8 addrspace(4)*, i32 addrspace(1)*, i32, i32 addrspace(1)* }>
42-
// CHECK-LLVM: [[BlockTy4:%[0-9a-z\.]+]] = type <{ i32, i32, i8 addrspace(4)* }>
40+
// CHECK-LLVM: [[BlockTy2:%[0-9a-z\.]+]] = type <{ i32, i32, i8 addrspace(4)*, i8 addrspace(1)*, i32, i8 }>
41+
// CHECK-LLVM: [[BlockTy3:%[0-9a-z\.]+]] = type <{ i32, i32, i8 addrspace(4)*, i8 addrspace(1)*, i32, i8 addrspace(1)* }>
4342

44-
// CHECK-LLVM: @__block_literal_global = internal addrspace(1) constant [[BlockTy1]] { i32 12, i32 4, i8 addrspace(4)* addrspacecast (i8* null to i8 addrspace(4)*) }, align 4
45-
// CHECK-LLVM: @__block_literal_global.1 = internal addrspace(1) constant [[BlockTy1]] { i32 12, i32 4, i8 addrspace(4)* addrspacecast (i8* null to i8 addrspace(4)*) }, align 4
43+
// CHECK-LLVM: @__block_literal_global = internal addrspace(1) constant [[BlockTy1]] { i32 12, i32 4, i8 addrspace(4)* null }, align 4
44+
// CHECK-LLVM: @__block_literal_global.1 = internal addrspace(1) constant [[BlockTy1]] { i32 12, i32 4, i8 addrspace(4)* null }, align 4
4645

4746
typedef struct {int a;} ndrange_t;
4847
#define NULL ((void*)0)
@@ -57,14 +56,13 @@ kernel void device_side_enqueue(global int *a, global int *b, int i, char c0) {
5756

5857
// Emits block literal on stack and block kernel.
5958

60-
// CHECK-SPIRV: PtrCastToGeneric [[Int8PtrGenTy]] [[BlockLit1:[0-9]+]]
59+
// CHECK-SPIRV: Bitcast [[Int8PtrGenTy]] [[BlockLit1:[0-9]+]]
6160
// CHECK-SPIRV: EnqueueKernel [[Int32Ty]] {{[0-9]+}} {{[0-9]+}} {{[0-9]+}} {{[0-9]+}}
6261
// [[ConstInt0]] [[EventNull]] [[EventNull]]
6362
// [[BlockKer1]] [[BlockLit1]] [[ConstInt17]] [[ConstInt8]]
6463

65-
// CHECK-LLVM: [[Block2:%[0-9]+]] = bitcast [[BlockTy2]]* %block to %struct.__opencl_block_literal_generic*
66-
// CHECK-LLVM: [[InterCast2:%[0-9]+]] = bitcast %struct.__opencl_block_literal_generic* [[Block2]] to i8
67-
// CHECK-LLVM: [[Block2Ptr:%[0-9]+]] = addrspacecast i8* [[InterCast2]] to i8 addrspace(4)*
64+
// CHECK-LLVM: [[Block2:%[0-9]+]] = addrspacecast [[BlockTy2]]* %block to [[BlockTy2]] addrspace(4)*
65+
// CHECK-LLVM: [[Block2Ptr:%[0-9]+]] = bitcast [[BlockTy2]] addrspace(4)* [[Block2]] to i8 addrspace(4)*
6866
// CHECK-LLVM: [[BlockInv2:%[0-9]+]] = addrspacecast void (i8 addrspace(4)*)* @__device_side_enqueue_block_invoke_kernel to i8 addrspace(4)*
6967
// CHECK-LLVM: call spir_func i32 @__enqueue_kernel_basic(%opencl.queue_t* {{.*}}, i32 {{.*}}, %struct.ndrange_t* {{.*}}, i8 addrspace(4)* [[BlockInv2]], i8 addrspace(4)* [[Block2Ptr]])
7068
// CHECK-SPV-IR: call spir_func i32 @_Z21__spirv_EnqueueKernelP13__spirv_Queuei9ndrange_tiPU3AS4P19__spirv_DeviceEventS5_U13block_pointerFvvEPU3AS4cii(%spirv.Queue* {{.*}}, i32 {{.*}}, %struct.ndrange_t* {{.*}}, i32 0, %spirv.DeviceEvent* addrspace(4)* null, %spirv.DeviceEvent* addrspace(4)* null, void (i8 addrspace(4)*)* @__device_side_enqueue_block_invoke_kernel, i8 addrspace(4)* {{.*}}, i32 {{.*}}, i32 {{.*}})
@@ -78,14 +76,13 @@ kernel void device_side_enqueue(global int *a, global int *b, int i, char c0) {
7876
// CHECK-SPIRV: PtrCastToGeneric [[EventPtrTy]] [[Event1:[0-9]+]]
7977
// CHECK-SPIRV: PtrCastToGeneric [[EventPtrTy]] [[Event2:[0-9]+]]
8078

81-
// CHECK-SPIRV: PtrCastToGeneric [[Int8PtrGenTy]] [[BlockLit2:[0-9]+]]
79+
// CHECK-SPIRV: Bitcast [[Int8PtrGenTy]] [[BlockLit2:[0-9]+]]
8280
// CHECK-SPIRV: EnqueueKernel [[Int32Ty]] {{[0-9]+}} {{[0-9]+}} {{[0-9]+}} {{[0-9]+}}
8381
// [[ConstInt2]] [[Event1]] [[Event2]]
8482
// [[BlockKer2]] [[BlockLit2]] [[ConstInt20]] [[ConstInt8]]
8583

86-
// CHECK-LLVM: [[Block3:%[0-9]+]] = bitcast [[BlockTy3]]* %block4 to %struct.__opencl_block_literal_generic*
87-
// CHECK-LLVM: [[InterCast3:%[0-9]+]] = bitcast %struct.__opencl_block_literal_generic* [[Block3]] to i8
88-
// CHECK-LLVM: [[Block3Ptr:%[0-9]+]] = addrspacecast i8* [[InterCast3]] to i8 addrspace(4)
84+
// CHECK-LLVM: [[Block3:%[0-9]+]] = addrspacecast [[BlockTy3]]* %block4 to [[BlockTy3]] addrspace(4)*
85+
// CHECK-LLVM: [[Block3Ptr:%[0-9]+]] = bitcast [[BlockTy3]] addrspace(4)* [[Block3]] to i8 addrspace(4)*
8986
// CHECK-LLVM: [[BlockInv3:%[0-9]+]] = addrspacecast void (i8 addrspace(4)*)* @__device_side_enqueue_block_invoke_2_kernel to i8 addrspace(4)*
9087
// CHECK-LLVM: call spir_func i32 @__enqueue_kernel_basic_events(%opencl.queue_t* {{.*}}, i32 {{.*}}, %struct.ndrange_t* {{.*}}, i32 2, %opencl.clk_event_t* addrspace(4)* {{.*}}, %opencl.clk_event_t* addrspace(4)* {{.*}}, i8 addrspace(4)* [[BlockInv3]], i8 addrspace(4)* [[Block3Ptr]])
9188
// CHECK-SPV-IR: call spir_func i32 @_Z21__spirv_EnqueueKernelP13__spirv_Queuei9ndrange_tiPU3AS4P19__spirv_DeviceEventS5_U13block_pointerFvvEPU3AS4cii(%spirv.Queue* {{.*}}, i32 {{.*}}, %struct.ndrange_t* {{.*}}, i32 2, %spirv.DeviceEvent* addrspace(4)* {{.*}}, %spirv.DeviceEvent* addrspace(4)* {{.*}}, void (i8 addrspace(4)*)* @__device_side_enqueue_block_invoke_2_kernel, i8 addrspace(4)* %{{.*}}, i32 {{.*}}, i32 {{.*}})
@@ -98,15 +95,15 @@ kernel void device_side_enqueue(global int *a, global int *b, int i, char c0) {
9895
// Emits global block literal and block kernel.
9996

10097
// CHECK-SPIRV: PtrAccessChain [[Int32LocPtrTy]] [[LocalBuf31:[0-9]+]]
101-
// CHECK-SPIRV: Bitcast {{[0-9]+}} [[BlockLit3Tmp:[0-9]+]] [[BlockGlb1:[0-9]+]]
102-
// CHECK-SPIRV: PtrCastToGeneric [[Int8PtrGenTy]] [[BlockLit3:[0-9]+]] [[BlockLit3Tmp]]
98+
// CHECK-SPIRV: PtrCastToGeneric {{[0-9]+}} [[BlockLit3Tmp:[0-9]+]] [[BlockGlb1:[0-9]+]]
99+
// CHECK-SPIRV: Bitcast [[Int8PtrGenTy]] [[BlockLit3:[0-9]+]] [[BlockLit3Tmp]]
103100
// CHECK-SPIRV: EnqueueKernel [[Int32Ty]] {{[0-9]+}} {{[0-9]+}} {{[0-9]+}} {{[0-9]+}}
104101
// [[ConstInt2]] [[Event1]] [[Event2]]
105102
// [[BlockKer3]] [[BlockLit3]] [[ConstInt8]] [[ConstInt8]]
106103
// [[LocalBuf31]]
107104

108-
// CHECK-LLVM: [[Block0Tmp:%[0-9]+]] = bitcast [[BlockTy1]] addrspace(1)* @__block_literal_global to i8 addrspace(1)*
109-
// CHECK-LLVM: [[Block0:%[0-9]+]] = addrspacecast i8 addrspace(1)* [[Block0Tmp]] to i8 addrspace(4)*
105+
// CHECK-LLVM: [[Block0Tmp:%[0-9]+]] = addrspacecast [[BlockTy1]] addrspace(1)* @__block_literal_global to [[BlockTy1]] addrspace(4)*
106+
// CHECK-LLVM: [[Block0:%[0-9]+]] = bitcast [[BlockTy1]] addrspace(4)* [[Block0Tmp]] to i8 addrspace(4)*
110107
// CHECK-LLVM: [[BlockInv0:%[0-9]+]] = addrspacecast void (i8 addrspace(4)*, i8 addrspace(3)*)* @__device_side_enqueue_block_invoke_3_kernel to i8 addrspace(4)*
111108
// CHECK-LLVM: call spir_func i32 @__enqueue_kernel_events_varargs(%opencl.queue_t* {{.*}}, i32 {{.*}}, %struct.ndrange_t* {{.*}}, i32 2, %opencl.clk_event_t* addrspace(4)* {{.*}}, %opencl.clk_event_t* addrspace(4)* {{.*}}, i8 addrspace(4)* [[BlockInv0]], i8 addrspace(4)* [[Block0]], i32 1, i32* {{.*}})
112109
// CHECK-SPV-IR: call spir_func i32 @_Z21__spirv_EnqueueKernelP13__spirv_Queuei9ndrange_tiPU3AS4P19__spirv_DeviceEventS5_U13block_pointerFvvEPU3AS4ciiPi(%spirv.Queue* {{.*}}, i32 {{.*}}, %struct.ndrange_t* {{.*}}, i32 2, %spirv.DeviceEvent* addrspace(4)* {{.*}}, %spirv.DeviceEvent* addrspace(4)* {{.*}}, void (i8 addrspace(4)*, i8 addrspace(3)*)* @__device_side_enqueue_block_invoke_3_kernel, i8 addrspace(4)* {{.*}}, i32 {{.*}}, i32 {{.*}}, i32* {{.*}})
@@ -121,15 +118,15 @@ kernel void device_side_enqueue(global int *a, global int *b, int i, char c0) {
121118
// CHECK-SPIRV: PtrAccessChain [[Int32LocPtrTy]] [[LocalBuf41:[0-9]+]]
122119
// CHECK-SPIRV: PtrAccessChain [[Int32LocPtrTy]] [[LocalBuf42:[0-9]+]]
123120
// CHECK-SPIRV: PtrAccessChain [[Int32LocPtrTy]] [[LocalBuf43:[0-9]+]]
124-
// CHECK-SPIRV: Bitcast {{[0-9]+}} [[BlockLit4Tmp:[0-9]+]] [[BlockGlb2:[0-9]+]]
125-
// CHECK-SPIRV: PtrCastToGeneric [[Int8PtrGenTy]] [[BlockLit4:[0-9]+]] [[BlockLit4Tmp]]
121+
// CHECK-SPIRV: PtrCastToGeneric {{[0-9]+}} [[BlockLit4Tmp:[0-9]+]] [[BlockGlb2:[0-9]+]]
122+
// CHECK-SPIRV: Bitcast [[Int8PtrGenTy]] [[BlockLit4:[0-9]+]] [[BlockLit4Tmp]]
126123
// CHECK-SPIRV: EnqueueKernel [[Int32Ty]] {{[0-9]+}} {{[0-9]+}} {{[0-9]+}} {{[0-9]+}}
127124
// [[ConstInt0]] [[EventNull]] [[EventNull]]
128125
// [[BlockKer4]] [[BlockLit4]] [[ConstInt8]] [[ConstInt8]]
129126
// [[LocalBuf41]] [[LocalBuf42]] [[LocalBuf43]]
130127

131-
// CHECK-LLVM: [[Block1Tmp:%[0-9]+]] = bitcast [[BlockTy1]] addrspace(1)* @__block_literal_global.1 to i8 addrspace(1)*
132-
// CHECK-LLVM: [[Block1:%[0-9]+]] = addrspacecast i8 addrspace(1)* [[Block1Tmp]] to i8 addrspace(4)*
128+
// CHECK-LLVM: [[Block1Tmp:%[0-9]+]] = addrspacecast [[BlockTy1]] addrspace(1)* @__block_literal_global.1 to [[BlockTy1]] addrspace(4)*
129+
// CHECK-LLVM: [[Block1:%[0-9]+]] = bitcast [[BlockTy1]] addrspace(4)* [[Block1Tmp]] to i8 addrspace(4)*
133130
// CHECK-LLVM: [[BlockInv1:%[0-9]+]] = addrspacecast void (i8 addrspace(4)*, i8 addrspace(3)*, i8 addrspace(3)*, i8 addrspace(3)*)* @__device_side_enqueue_block_invoke_4_kernel to i8 addrspace(4)*
134131
// CHECK-LLVM: call spir_func i32 @__enqueue_kernel_varargs(%opencl.queue_t* {{.*}}, i32 {{.*}}, %struct.ndrange_t* {{.*}}, i8 addrspace(4)* [[BlockInv1]], i8 addrspace(4)* [[Block1]], i32 3, i32* {{.*}})
135132
// CHECK-SPV-IR: call spir_func i32 @_Z21__spirv_EnqueueKernelP13__spirv_Queuei9ndrange_tiPU3AS4P19__spirv_DeviceEventS5_U13block_pointerFvvEPU3AS4ciiPiSA_SA_(%spirv.Queue* {{.*}}, i32 {{.*}}, %struct.ndrange_t* {{.*}}, i32 0, %spirv.DeviceEvent* addrspace(4)* null, %spirv.DeviceEvent* addrspace(4)* null, void (i8 addrspace(4)*, i8 addrspace(3)*, i8 addrspace(3)*, i8 addrspace(3)*)* @__device_side_enqueue_block_invoke_4_kernel, i8 addrspace(4)* {{.*}}, i32 {{.*}}, i32 {{.*}}, i32* {{.*}}, i32* {{.*}}, i32* {{.*}})
@@ -143,14 +140,13 @@ kernel void device_side_enqueue(global int *a, global int *b, int i, char c0) {
143140

144141
// CHECK-SPIRV: PtrCastToGeneric [[EventPtrTy]] [[Event1:[0-9]+]]
145142

146-
// CHECK-SPIRV: PtrCastToGeneric [[Int8PtrGenTy]] [[BlockLit2:[0-9]+]]
143+
// CHECK-SPIRV: Bitcast [[Int8PtrGenTy]] [[BlockLit2:[0-9]+]]
147144
// CHECK-SPIRV: EnqueueKernel [[Int32Ty]] {{[0-9]+}} {{[0-9]+}} {{[0-9]+}} {{[0-9]+}}
148145
// [[ConstInt0]] [[EventNull]] [[Event1]]
149146
// [[BlockKer5]] [[BlockLit5]] [[ConstInt20]] [[ConstInt8]]
150147

151-
// CHECK-LLVM: [[Block5:%[0-9]+]] = bitcast [[BlockTy3]]* %block15 to %struct.__opencl_block_literal_generic*
152-
// CHECK-LLVM: [[InterCast5:%[0-9]+]] = bitcast %struct.__opencl_block_literal_generic* [[Block5]] to i8
153-
// CHECK-LLVM: [[Block5Ptr:%[0-9]+]] = addrspacecast i8* [[InterCast5]] to i8 addrspace(4)
148+
// CHECK-LLVM: [[Block5:%[0-9]+]] = addrspacecast [[BlockTy3]]* %block15 to [[BlockTy3]] addrspace(4)*
149+
// CHECK-LLVM: [[Block5Ptr:%[0-9]+]] = bitcast [[BlockTy3]] addrspace(4)* [[Block5]] to i8 addrspace(4)*
154150
// CHECK-LLVM: [[BlockInv5:%[0-9]+]] = addrspacecast void (i8 addrspace(4)*)* @__device_side_enqueue_block_invoke_5_kernel to i8 addrspace(4)*
155151
// CHECK-LLVM: call spir_func i32 @__enqueue_kernel_basic_events(%opencl.queue_t* {{.*}}, i32 {{.*}}, %struct.ndrange_t* {{.*}}, i32 0, %opencl.clk_event_t* addrspace(4)* null, %opencl.clk_event_t* addrspace(4)* {{.*}}, i8 addrspace(4)* [[BlockInv5]], i8 addrspace(4)* [[Block5Ptr]])
156152
// CHECK-SPV-IR: call spir_func i32 @_Z21__spirv_EnqueueKernelP13__spirv_Queuei9ndrange_tiPU3AS4P19__spirv_DeviceEventS5_U13block_pointerFvvEPU3AS4cii(%spirv.Queue* {{.*}}, i32 {{.*}}, %struct.ndrange_t* {{.*}}, i32 0, %spirv.DeviceEvent* addrspace(4)* null, %spirv.DeviceEvent* addrspace(4)* {{.*}}, void (i8 addrspace(4)*)* @__device_side_enqueue_block_invoke_5_kernel, i8 addrspace(4)* {{.*}}, i32 {{.*}}, i32 {{.*}})

llvm-spirv/test/transcoding/global_block.cl

+5-5
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
// block-specific instructions, which are redundant in SPIR-V and should be
44
// removed
55

6-
// RUN: %clang_cc1 -O0 -triple spir-unknown-unknown -cl-std=CL2.0 -x cl %s -emit-llvm-bc -o %t.bc -no-opaque-pointers
6+
// RUN: %clang_cc1 -O0 -triple spir-unknown-unknown -cl-std=CL2.0 -x cl %s -emit-llvm-bc -o %t.bc
77

8-
// RUN: llvm-spirv --spirv-max-version=1.1 %t.bc -opaque-pointers=0 -spirv-text -o - | FileCheck %s --check-prefix=CHECK-SPIRV
9-
// RUN: llvm-spirv --spirv-max-version=1.1 %t.bc -opaque-pointers=0 -o %t.spirv1.1.spv
8+
// RUN: llvm-spirv --spirv-max-version=1.1 %t.bc -spirv-text -o - | FileCheck %s --check-prefix=CHECK-SPIRV
9+
// RUN: llvm-spirv --spirv-max-version=1.1 %t.bc -o %t.spirv1.1.spv
1010
// RUN: spirv-val --target-env spv1.1 %t.spirv1.1.spv
1111
// RUN: llvm-spirv -r -emit-opaque-pointers %t.spirv1.1.spv -o - | llvm-dis | FileCheck %s --check-prefix=CHECK-LLVM
1212

13-
// RUN: llvm-spirv --spirv-max-version=1.4 %t.bc -opaque-pointers=0 -spirv-text -o - | FileCheck %s --check-prefix=CHECK-SPIRV
14-
// RUN: llvm-spirv --spirv-max-version=1.4 %t.bc -opaque-pointers=0 -o %t.spirv1.4.spv
13+
// RUN: llvm-spirv --spirv-max-version=1.4 %t.bc -spirv-text -o - | FileCheck %s --check-prefix=CHECK-SPIRV
14+
// RUN: llvm-spirv --spirv-max-version=1.4 %t.bc -o %t.spirv1.4.spv
1515
// RUN: spirv-val --target-env spv1.4 %t.spirv1.4.spv
1616
// RUN: llvm-spirv -r -emit-opaque-pointers %t.spirv1.4.spv -o - | llvm-dis | FileCheck %s --check-prefix=CHECK-LLVM
1717

0 commit comments

Comments
 (0)