Skip to content

Commit ebaacc0

Browse files
FznamznonAlexeySotkin
authored andcommitted
Fix SPIR-V friendly IR for event opcodes
This instruction was translated directly to OCL even if SPIR-V friendly LLVM IR was requested.
1 parent 6e2dae6 commit ebaacc0

File tree

3 files changed

+27
-9
lines changed

3 files changed

+27
-9
lines changed

lib/SPIRV/SPIRVReader.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -692,6 +692,8 @@ bool SPIRVToLLVM::isDirectlyTranslatedToOCL(Op OpCode) const {
692692
return true;
693693
if (OpCode == OpImageSampleExplicitLod || OpCode == OpSampledImage)
694694
return false;
695+
if (isEventOpCode(OpCode))
696+
return false;
695697
if (OCLSPIRVBuiltinMap::rfind(OpCode, nullptr)) {
696698
// Not every spirv opcode which is placed in OCLSPIRVBuiltinMap is
697699
// translated directly to OCL builtin. Some of them are translated

lib/SPIRV/libSPIRV/SPIRVOpCode.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,10 @@ inline bool isIntelSubgroupOpCode(Op OpCode) {
234234
return OpSubgroupShuffleINTEL <= OC && OC <= OpSubgroupImageBlockWriteINTEL;
235235
}
236236

237+
inline bool isEventOpCode(Op OpCode) {
238+
return OpRetainEvent <= OpCode && OpCode <= OpCaptureEventProfilingInfo;
239+
}
240+
237241
} // namespace SPIRV
238242

239243
#endif // SPIRV_LIBSPIRV_SPIRVOPCODE_H

test/transcoding/clk_event_t.cl

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@
33
// RUN: llvm-spirv %t.bc -o %t.spv
44
// RUN: spirv-val %t.spv
55
// RUN: llvm-spirv -r %t.spv -o %t.rev.bc
6-
// RUN: llvm-dis < %t.rev.bc | FileCheck %s --check-prefix=CHECK-LLVM
6+
// RUN: llvm-dis < %t.rev.bc | FileCheck %s --check-prefix=CHECK-LLVM-OCL
7+
// RUN: llvm-spirv -r --spirv-target-env=SPV-IR %t.spv -o %t.rev.bc
8+
// RUN: llvm-dis < %t.rev.bc | FileCheck %s --check-prefix=CHECK-LLVM-SPV
9+
// RUN: llvm-spirv %t.rev.bc -spirv-text -o - | FileCheck %s --check-prefix=CHECK-SPIRV
710

811
// CHECK-SPIRV: TypeDeviceEvent
912
// CHECK-SPIRV: 5 Function
@@ -15,14 +18,23 @@
1518
// CHECK-SPIRV: ReleaseEvent
1619
// CHECK-SPIRV: FunctionEnd
1720

18-
// CHECK-LLVM-LABEL: @clk_event_t_test
19-
// CHECK-LLVM: call spir_func %opencl.clk_event_t* @_Z17create_user_eventv()
20-
// CHECK-LLVM: call spir_func i1 @_Z14is_valid_event12ocl_clkevent
21-
// CHECK-LLVM: call spir_func void @_Z12retain_event12ocl_clkevent
22-
// CHECK-LLVM: call spir_func void @_Z21set_user_event_status12ocl_clkeventi(%opencl.clk_event_t* %{{[a-z]+}}, i32 -42)
23-
// CHECK-LLVM: call spir_func void @_Z28capture_event_profiling_info12ocl_clkeventiPU3AS1v(%opencl.clk_event_t* %{{[a-z]+}}, i32 1, i8 addrspace(1)* %prof)
24-
// CHECK-LLVM: call spir_func void @_Z13release_event12ocl_clkevent
25-
// CHECK-LLVM: ret
21+
// CHECK-LLVM-OCL-LABEL: @clk_event_t_test
22+
// CHECK-LLVM-OCL: call spir_func %opencl.clk_event_t* @_Z17create_user_eventv()
23+
// CHECK-LLVM-OCL: call spir_func i1 @_Z14is_valid_event12ocl_clkevent
24+
// CHECK-LLVM-OCL: call spir_func void @_Z12retain_event12ocl_clkevent
25+
// CHECK-LLVM-OCL: call spir_func void @_Z21set_user_event_status12ocl_clkeventi(%opencl.clk_event_t* %{{[a-z]+}}, i32 -42)
26+
// CHECK-LLVM-OCL: call spir_func void @_Z28capture_event_profiling_info12ocl_clkeventiPU3AS1v(%opencl.clk_event_t* %{{[a-z]+}}, i32 1, i8 addrspace(1)* %prof)
27+
// CHECK-LLVM-OCL: call spir_func void @_Z13release_event12ocl_clkevent
28+
// CHECK-LLVM-OCL: ret
29+
30+
// CHECK-LLVM-SPV-LABEL: @clk_event_t_test
31+
// CHECK-LLVM-SPV: call spir_func %opencl.clk_event_t* @_Z23__spirv_CreateUserEventv()
32+
// CHECK-LLVM-SPV: call spir_func i1 @_Z20__spirv_IsValidEvent12ocl_clkevent
33+
// CHECK-LLVM-SPV: call spir_func void @_Z19__spirv_RetainEvent12ocl_clkevent
34+
// CHECK-LLVM-SPV: call spir_func void @_Z26__spirv_SetUserEventStatus12ocl_clkeventi(%opencl.clk_event_t* %{{[a-z]+}}, i32 -42)
35+
// CHECK-LLVM-SPV: call spir_func void @_Z33__spirv_CaptureEventProfilingInfo12ocl_clkeventiPU3AS1c(%opencl.clk_event_t* %{{[a-z]+}}, i32 1, i8 addrspace(1)* %prof)
36+
// CHECK-LLVM-SPV: call spir_func void @_Z20__spirv_ReleaseEvent12ocl_clkevent
37+
// CHECK-LLVM-SPV: ret
2638

2739
kernel void clk_event_t_test(global int *res, global void *prof) {
2840
clk_event_t e1 = create_user_event();

0 commit comments

Comments
 (0)