You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The translator is generating spirv with function calls which should be treated as builtins.
This is only occurring when clang is run with the C++ for OpenCL mode.
When run in clc++ mode, clang generates a !opencl.cxx.version = !{!3} entry, which seems to be causing some issues.
Here is an easy way to reproduce:
kernel.cl:
// this sample doesn't use any C++ for OpenCL features__kernelvoidsample(write_onlyimage2d_timg) {
constintcol=get_global_id(0);
constintrow=get_global_id(1);
int2coord;
coord.x=col;
coord.y=row;
float4px= {0, 0, 0, 1};
write_imagef(img, coord, px);
}
We can verify that this links correctly by running spirv-link.
Repeating the same processes, but running clang without -cl-std=clc++ results in no errors. The only meaningful difference in the generated llvm is the !opencl.cxx.version = !{!3} tag
Thanks for reporting; this highlights a long-standing problem that doesn't have a trivial solution unfortunately. See e.g. the attempt reverted by #2508.
The translator is generating spirv with function calls which should be treated as builtins.
This is only occurring when clang is run with the C++ for OpenCL mode.
When run in
clc++
mode, clang generates a!opencl.cxx.version = !{!3}
entry, which seems to be causing some issues.Here is an easy way to reproduce:
kernel.cl:
run:
clang -target spirv64 -cl-std=clc++ kernel.cl
error: 0: Unresolved external reference to "_Z13get_global_idj".
Examine the generated spirv:
clang -c -target spirv64 -cl-std=clc++ -emit-llvm -o - kernel.cl | llvm-spirv -o - | spirv-dis
Notice how the spirv contains some odd
OpFunctionCall
:Looking at the llvm generated by clang:
clang -c -target spirv64 -cl-std=clc++ -emit-llvm -o - kernel.cl | llvm-dis
Notice the
!opencl.cxx.version = !{!3}
If I edit the llvm, and pass it back through llvm-spirv:
The output appears normal:
We can verify that this links correctly by running
spirv-link
.Repeating the same processes, but running clang without
-cl-std=clc++
results in no errors. The only meaningful difference in the generated llvm is the!opencl.cxx.version = !{!3}
tagrelated issue: llvm/llvm-project#118576
The text was updated successfully, but these errors were encountered: