Ugh. Copy coalescer does not update register numbers.
authorEvan Cheng <evan.cheng@apple.com>
Mon, 2 Apr 2007 18:49:18 +0000 (18:49 +0000)
committerEvan Cheng <evan.cheng@apple.com>
Mon, 2 Apr 2007 18:49:18 +0000 (18:49 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35600 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/CodeGen/LiveIntervalAnalysis.h
lib/CodeGen/LiveIntervalAnalysis.cpp

index ebd63c809624e05649084c0f63b262fb22fe3373..641ff6a0b4d6ec804f55013db27850ddde46d780 100644 (file)
@@ -267,6 +267,10 @@ namespace llvm {
     MachineInstr *lastRegisterUse(unsigned Reg, unsigned Start, unsigned End,
                                   MachineOperand *&MOU);
 
+    /// findDefOperand - Returns the MachineOperand that is a def of the specific
+    /// register. It returns NULL if the def is not found.
+    MachineOperand *findDefOperand(MachineInstr *MI, unsigned Reg);
+
     /// unsetRegisterKill - Unset IsKill property of all uses of the specific
     /// register of the specific instruction.
     void unsetRegisterKill(MachineInstr *MI, unsigned Reg);
index bc4f6016f36825c1057254909c2550b283ae2b1c..a01889a643e6ebf29407163dbfef230df8c91026 100644 (file)
@@ -945,7 +945,7 @@ bool LiveIntervals::JoinCopy(MachineInstr *CopyMI,
       } else {
         MachineInstr *SrcMI = getInstructionFromIndex(SrcStart);
         if (SrcMI) {
-          MachineOperand *mops = SrcMI->findRegisterDefOperand(SrcReg);
+          MachineOperand *mops = findDefOperand(SrcMI, repSrcReg);
           if (mops)
             // A dead def should have a single cycle interval.
             ++RemoveStart;
@@ -1022,7 +1022,7 @@ TryJoin:
       } else {
         MachineInstr *SrcMI = getInstructionFromIndex(SrcStart);
         if (SrcMI) {
-          MachineOperand *mops = SrcMI->findRegisterDefOperand(SrcReg);
+          MachineOperand *mops = findDefOperand(SrcMI, repSrcReg);
           if (mops)
             mops->setIsDead();
         }
@@ -1617,6 +1617,19 @@ LiveIntervals::lastRegisterUse(unsigned Reg, unsigned Start, unsigned End,
   return NULL;
 }
 
+
+/// findDefOperand - Returns the MachineOperand that is a def of the specific
+/// register. It returns NULL if the def is not found.
+MachineOperand *LiveIntervals::findDefOperand(MachineInstr *MI, unsigned Reg) {
+  for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) {
+    MachineOperand &MO = MI->getOperand(i);
+    if (MO.isReg() && MO.isDef() &&
+        mri_->regsOverlap(rep(MO.getReg()), Reg))
+      return &MO;
+  }
+  return NULL;
+}
+
 /// unsetRegisterKill - Unset IsKill property of all uses of specific register
 /// of the specific instruction.
 void LiveIntervals::unsetRegisterKill(MachineInstr *MI, unsigned Reg) {