[llvm] [SPIR-V] Emit builtin variable OpVariable into entry block (PR #189958)
Arseniy Obolenskiy via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 2 02:23:49 PDT 2026
================
@@ -6114,11 +6114,16 @@ bool SPIRVInstructionSelector::loadVec3BuiltinInputID(
MIRBuilder.getMRI()->setType(NewRegister, LLT::pointer(0, 64));
GR.assignSPIRVTypeToVReg(PtrType, NewRegister, MIRBuilder.getMF());
- // Build global variable with the necessary decorations for the input ID
- // builtin variable.
+ // Emit the OpVariable into the entry block to ensure the def dominates
+ // all uses across all MBBs.
+ MachineBasicBlock &EntryBB = MIRBuilder.getMF().front();
+ MachineIRBuilder GVBuilder(MIRBuilder.getState());
+ if (&GVBuilder.getMBB() != &EntryBB)
+ GVBuilder.setInsertPt(EntryBB, EntryBB.getFirstTerminator());
----------------
aobolensk wrote:
Yes, done
https://github.com/llvm/llvm-project/pull/189958
More information about the llvm-commits
mailing list