[llvm] [SPIR-V] Fix validation errors for function pointers with CodeSectionINTEL storage class (PR #192973)
Arseniy Obolenskiy via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 28 08:06:52 PDT 2026
================
@@ -2829,13 +2829,15 @@ bool SPIRVInstructionSelector::selectAddrSpaceCast(Register ResVReg,
// are expressed by OpSpecConstantOp with an Opcode.
// TODO: maybe insert a check whether the Kernel capability was declared and
// so PtrCastToGeneric/GenericCastToPtr are available.
- unsigned SpecOpcode =
- DstSC == SPIRV::StorageClass::Generic && isGenericCastablePtr(SrcSC)
- ? static_cast<uint32_t>(SPIRV::Opcode::PtrCastToGeneric)
- : (SrcSC == SPIRV::StorageClass::Generic &&
- isGenericCastablePtr(DstSC)
- ? static_cast<uint32_t>(SPIRV::Opcode::GenericCastToPtr)
- : 0);
+ unsigned SpecOpcode = [&]() -> unsigned {
+ if (SrcSC == SPIRV::StorageClass::CodeSectionINTEL)
+ return static_cast<uint32_t>(SPIRV::Opcode::Bitcast);
+ if (DstSC == SPIRV::StorageClass::Generic && isGenericCastablePtr(SrcSC))
----------------
aobolensk wrote:
OpSpecConstantOp PtrCastToGeneric requires the source and result pointee types to match, but getUcharPtrTypeReg always produces a generic uchar* type, which doesn't match a function-pointer's pointee type.
https://github.com/llvm/llvm-project/pull/192973
More information about the llvm-commits
mailing list