[llvm] r175367 - Replace erase loop with std::remove_if.

Benjamin Kramer benny.kra at googlemail.com
Sat Feb 16 09:06:38 PST 2013


Author: d0k
Date: Sat Feb 16 11:06:38 2013
New Revision: 175367

URL: http://llvm.org/viewvc/llvm-project?rev=175367&view=rev
Log:
Replace erase loop with std::remove_if.

This avoids unnecessary copies. No functionality change.

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

Modified: llvm/trunk/lib/CodeGen/RegisterPressure.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/RegisterPressure.cpp?rev=175367&r1=175366&r2=175367&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/RegisterPressure.cpp (original)
+++ llvm/trunk/lib/CodeGen/RegisterPressure.cpp Sat Feb 16 11:06:38 2013
@@ -357,15 +357,14 @@ protected:
 /// Collect physical and virtual register operands.
 static void collectOperands(const MachineInstr *MI,
                             RegisterOperands &RegOpers) {
-  for(ConstMIBundleOperands OperI(MI); OperI.isValid(); ++OperI)
+  for (ConstMIBundleOperands OperI(MI); OperI.isValid(); ++OperI)
     RegOpers.collect(*OperI);
 
   // Remove redundant physreg dead defs.
-  for (unsigned i = RegOpers.DeadDefs.size(); i > 0; --i) {
-    unsigned Reg = RegOpers.DeadDefs[i-1];
-    if (containsReg(RegOpers.Defs, Reg))
-      RegOpers.DeadDefs.erase(&RegOpers.DeadDefs[i-1]);
-  }
+  SmallVectorImpl<unsigned>::iterator I =
+    std::remove_if(RegOpers.DeadDefs.begin(), RegOpers.DeadDefs.end(),
+                   std::bind1st(std::ptr_fun(containsReg), RegOpers.Defs));
+  RegOpers.DeadDefs.erase(I, RegOpers.DeadDefs.end());
 }
 
 /// Force liveness of registers.





More information about the llvm-commits mailing list