[llvm] Fix assert in SlotIndexes::getInstructionIndex in debug builds (PR #189370)

via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 15 01:53:47 PDT 2026


================
@@ -1174,12 +1174,14 @@ 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()) {
+    MachineBasicBlock::iterator BeforeNonDbg = skipDebugInstructionsForward(Before, MBBE);
+    if (FirstTerm != MBBE && BeforeNonDbg != MBBE) {
----------------
MarcoCastorina wrote:

I added the check for `Before` because of a previous comment. I'll remove it.

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


More information about the llvm-commits mailing list