[LiveIntervals] Fix asan debug build failures
authorJay Foad <jay.foad@amd.com>
Fri, 24 Sep 2021 17:43:17 +0000 (18:43 +0100)
committerJay Foad <jay.foad@amd.com>
Fri, 24 Sep 2021 18:14:57 +0000 (19:14 +0100)
Call RemoveMachineInstrFromMaps before erasing instrs.
repairIntervalsInRange will do this for you after erasing the
instruction, but it's not safe to rely on it because assertions in
SlotIndexes::removeMachineInstrFromMaps refer to fields in the erased
instruction.

This fixes asan buildbot failures caused by D110328.

llvm/lib/CodeGen/TwoAddressInstructionPass.cpp

index 200f986..3e2e6c9 100644 (file)
@@ -1283,6 +1283,8 @@ tryInstructionTransform(MachineBasicBlock::iterator &mi,
               if (MO.isReg())
                 OrigRegs.push_back(MO.getReg());
             }
+
+            LIS->RemoveMachineInstrFromMaps(MI);
           }
 
           MI.eraseFromParent();
@@ -1717,6 +1719,9 @@ eliminateRegSequence(MachineBasicBlock::iterator &MBBI) {
     for (int j = MI.getNumOperands() - 1, ee = 0; j > ee; --j)
       MI.RemoveOperand(j);
   } else {
+    if (LIS)
+      LIS->RemoveMachineInstrFromMaps(MI);
+
     LLVM_DEBUG(dbgs() << "Eliminated: " << MI);
     MI.eraseFromParent();
   }