[llvm-commits] [llvm] r144770 - /llvm/trunk/lib/CodeGen/TwoAddressInstructionPass.cpp

Evan Cheng evan.cheng at apple.com
Tue Nov 15 19:05:12 PST 2011


Author: evancheng
Date: Tue Nov 15 21:05:12 2011
New Revision: 144770

URL: http://llvm.org/viewvc/llvm-project?rev=144770&view=rev
Log:
Process all uses first before defs to accurately capture register liveness. rdar://10449480

Modified:
    llvm/trunk/lib/CodeGen/TwoAddressInstructionPass.cpp

Modified: llvm/trunk/lib/CodeGen/TwoAddressInstructionPass.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/TwoAddressInstructionPass.cpp?rev=144770&r1=144769&r2=144770&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/TwoAddressInstructionPass.cpp (original)
+++ llvm/trunk/lib/CodeGen/TwoAddressInstructionPass.cpp Tue Nov 15 21:05:12 2011
@@ -1115,6 +1115,7 @@
         MCID.isTerminator())
       // Don't move pass calls, etc.
       return false;
+    SmallVector<unsigned, 2> OtherDefs;
     for (unsigned i = 0, e = OtherMI->getNumOperands(); i != e; ++i) {
       const MachineOperand &MO = OtherMI->getOperand(i);
       if (!MO.isReg())
@@ -1131,15 +1132,20 @@
           // Don't want to extend other live ranges and update kills.
           return false;
       } else {
-        if (Uses.count(MOReg))
-          return false;
-        if (TargetRegisterInfo::isPhysicalRegister(MOReg) &&
-            LiveDefs.count(MOReg))
-          return false;
-        // Physical register def is seen.
-        Defs.erase(MOReg);
+        OtherDefs.push_back(MOReg);
       }
     }
+
+    for (unsigned i = 0, e = OtherDefs.size(); i != e; ++i) {
+      unsigned MOReg = OtherDefs[i];
+      if (Uses.count(MOReg))
+        return false;
+      if (TargetRegisterInfo::isPhysicalRegister(MOReg) &&
+          LiveDefs.count(MOReg))
+        return false;
+      // Physical register def is seen.
+      Defs.erase(MOReg);
+    }
   }
 
   // Move the old kill above MI, don't forget to move debug info as well.





More information about the llvm-commits mailing list