[llvm] [SPIRV] Update the global registry when expanding function pointer (PR #183873)

Steven Perron via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 3 06:37:33 PST 2026


================
@@ -5341,6 +5341,8 @@ bool SPIRVInstructionSelector::selectGlobalValue(
         GR.add(ConstVal, MIB2);
         // mapping the function pointer to the used Function
         GR.recordFunctionPointer(&MIB2.getInstr()->getOperand(2), GVFun);
+        GR.assignSPIRVTypeToVReg(ResType, FuncVReg, *GR.CurMF);
+        GR.assignSPIRVTypeToVReg(ResType, NewReg, *GR.CurMF);
----------------
s-perron wrote:

If you want, you can open an issue. I don't know if this is technical debt or a deliberate design decision. The comment before the block of code that I changed says:

https://github.com/llvm/llvm-project/blob/c782e2d40572ce4ff3a71562265bf6f01857c132/llvm/lib/Target/SPIRV/SPIRVInstructionSelector.cpp#L5298-L5307

It seems like it was intentional to use one type, and change it during instruction selection if the extension is available. Otherwise, you need to check for the availability of the extension early and often.  I am not certain enough that the original design is incorrect to add comments to the code saying so.

https://github.com/llvm/llvm-project/pull/183873


More information about the llvm-commits mailing list