Initialize AsmPrinter::MF in the constructor
[oota-llvm.git] / lib / CodeGen / LiveRangeEdit.cpp
index 0c1d45902fe832b3c890aff4ff644568f6e2d1bb..792ef5405e2a67705974261e458e76b10f88bb1a 100644 (file)
@@ -220,6 +220,10 @@ void LiveRangeEdit::eliminateDeadDef(MachineInstr *MI, ToShrinkSet &ToShrink) {
   assert(MI->allDefsAreDead() && "Def isn't really dead");
   SlotIndex Idx = LIS.getInstructionIndex(MI).getRegSlot();
 
+  // Never delete a bundled instruction.
+  if (MI->isBundled()) {
+    return;
+  }
   // Never delete inline asm.
   if (MI->isInlineAsm()) {
     DEBUG(dbgs() << "Won't delete: " << Idx << '\t' << *MI);
@@ -249,6 +253,15 @@ void LiveRangeEdit::eliminateDeadDef(MachineInstr *MI, ToShrinkSet &ToShrink) {
       // Check if MI reads any unreserved physregs.
       if (Reg && MOI->readsReg() && !MRI.isReserved(Reg))
         ReadsPhysRegs = true;
+      else if (MOI->isDef()) {
+        for (MCRegUnitIterator Units(Reg, MRI.getTargetRegisterInfo());
+             Units.isValid(); ++Units) {
+          if (LiveInterval *LI = LIS.getCachedRegUnit(*Units)) {
+            if (VNInfo *VNI = LI->getVNInfoAt(Idx))
+              LI->removeValNo(VNI);
+          }
+        }
+      }
       continue;
     }
     LiveInterval &LI = LIS.getInterval(Reg);