[clang] [llvm] [SPIRV] `getMBB()` isn't always safe to call (PR #236948)
Marcos Maronas via cfe-commits
cfe-commits at lists.llvm.org
Fri Oct 30 04:55:12 PDT 2026
================
@@ -266,7 +266,8 @@ const MachineInstr *SPIRVGlobalRegistry::createConstOrTypeAtFunctionEntry(
MachineIRBuilder &MIRBuilder,
std::function<MachineInstr *(MachineIRBuilder &)> Op) {
auto oldInsertPoint = MIRBuilder.getInsertPt();
- MachineBasicBlock *OldMBB = &MIRBuilder.getMBB();
+ MachineBasicBlock *OldMBB =
----------------
maarquitos14 wrote:
I'm happy to keep this as an extra safety layer, but the MIRBuilder is passed in. Should we make the caller set the valid insertion point? That would be the `G_ANYEXT/G_SEXT/G_ZEXT/G_PTRTOINT` cases in `propagateSPIRVType`, if I'm not wrong. It creates types without positioning MIB, unlike `G_CONSTANT/G_GLOBAL_VALUE`. According to my local testing, if we hoist `MIB.setInsertPt(*MI->getParent(), MI);` above the switch this is fixed too.
https://github.com/llvm/llvm-project/pull/236948
More information about the cfe-commits
mailing list