[HLSL] Add checks to the SPIRVInstructionSelector's selectExtInst
functions for SPIR-V extended instruction set availability
#123847
Labels
Certain SPIR-V instructions are supported only with the OpenCL extended instruction set but not the GLSL extended instruction set, and vice-versa.
For example, the
reflect
instruction is supported in GLSL, but not OpenCL. Without adding a check that the extended instruction set is usable by the current SPIR-V target, the compiler will simply crash when attempting to selectG_INTRINSIC intrinsic(@llvm.spv.reflect)
in an OpenCL SPIR-V target.#122992 implements the check as follows in
llvm/lib/Target/SPIRV/SPIRVInstructionSelector.cpp
:There should be similar checks made for the other overloaded versions of the
selectExtInst
to keep things consistent.A non-exhaustive list of OpenCL-only instructions:
vstoren
vloadn
shuffle
(Note: AFAIK, these OpenCL-only instructions do not have corresponding HLSL intrinsics. I am not sure if there are any OpenCL-only instructions that have a direct HLSL intrinsic equivalent.)
A non-exhaustive list of GLSL-only instructions:
Reflect
Refract
FaceForward
A full list of exclusive instructions may be constructed by comparing the OpenCL extended instruction set and GLSL extended instruction set specifications.
The text was updated successfully, but these errors were encountered: