[llvm] Fix assert in SlotIndexes::getInstructionIndex in debug builds (PR #189370)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 27 03:12:09 PDT 2026
================
@@ -1174,10 +1174,12 @@ void SIWholeQuadMode::toExact(MachineBasicBlock &MBB,
Register SaveWQM) {
assert(LiveMaskReg.isVirtual());
- bool IsTerminator = Before == MBB.end();
+ MachineBasicBlock::iterator MBBE = MBB.end();
+ bool IsTerminator = Before == MBBE;
if (!IsTerminator) {
auto FirstTerm = MBB.getFirstTerminator();
- if (FirstTerm != MBB.end()) {
+ if (FirstTerm != MBBE) {
+ Before = skipDebugInstructionsForward(Before, MBBE);
----------------
MarcoCastorina wrote:
I think `getFirstTerminator` already skips debug instructions, so there is an assumption that we might see debug instructions here. This function is only called once so far, so moving the requirement outside of the function could work now. Do we risk the problem coming back if more calls to this function are added in the future?
https://github.com/llvm/llvm-project/pull/189370
More information about the llvm-commits
mailing list