Handle more cases in LiveRangeEdit::eliminateDeadDefs.
authorAndrew Trick <atrick@apple.com>
Fri, 21 Jun 2013 18:33:20 +0000 (18:33 +0000)
committerAndrew Trick <atrick@apple.com>
Fri, 21 Jun 2013 18:33:20 +0000 (18:33 +0000)
Live intervals for dead physregs may be created during coalescing. We
need to update these in the event that their instruction goes away.

crash.ll is the unit test that catches it when MI sched is enabled on
X86.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@184572 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/CodeGen/MachineRegisterInfo.h
lib/CodeGen/LiveRangeEdit.cpp

index 95c1ffdf443c21e3e69ddadb68de084c868c68bd..7a6dcd05897b57282fe914ce1bbea72b00a8e240 100644 (file)
@@ -58,10 +58,6 @@ class MachineRegisterInfo {
   /// physical registers.
   MachineOperand **PhysRegUseDefLists;
 
-  const TargetRegisterInfo *getTargetRegisterInfo() const {
-    return TM.getRegisterInfo();
-  }
-
   /// getRegUseDefListHead - Return the head pointer for the register use/def
   /// list for the specified virtual or physical register.
   MachineOperand *&getRegUseDefListHead(unsigned RegNo) {
@@ -116,6 +112,10 @@ public:
   explicit MachineRegisterInfo(const TargetMachine &TM);
   ~MachineRegisterInfo();
 
+  const TargetRegisterInfo *getTargetRegisterInfo() const {
+    return TM.getRegisterInfo();
+  }
+
   //===--------------------------------------------------------------------===//
   // Function State
   //===--------------------------------------------------------------------===//
index 0c1d45902fe832b3c890aff4ff644568f6e2d1bb..d215d0c28a4b8c36c01437c30c47554cb067b0e8 100644 (file)
@@ -249,6 +249,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);