[llvm-commits] [llvm] r84138 - /llvm/trunk/lib/CodeGen/PrologEpilogInserter.cpp

Jim Grosbach grosbach at apple.com
Wed Oct 14 14:22:39 PDT 2009


Author: grosbach
Date: Wed Oct 14 16:22:39 2009
New Revision: 84138

URL: http://llvm.org/viewvc/llvm-project?rev=84138&view=rev
Log:
Make loop not recalc getNumOperands() each time around

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

Modified: llvm/trunk/lib/CodeGen/PrologEpilogInserter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/PrologEpilogInserter.cpp?rev=84138&r1=84137&r2=84138&view=diff

==============================================================================
--- llvm/trunk/lib/CodeGen/PrologEpilogInserter.cpp (original)
+++ llvm/trunk/lib/CodeGen/PrologEpilogInserter.cpp Wed Oct 14 16:22:39 2009
@@ -778,9 +778,7 @@
     // directly.
     for (MachineBasicBlock::iterator I = BB->begin(); I != BB->end(); ++I) {
       MachineInstr *MI = I;
-      // Likewise, call getNumOperands() each iteration, as the MI may change
-      // inside the loop (with 'i' updated accordingly).
-      for (unsigned i = 0; i != MI->getNumOperands(); ++i)
+      for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i)
         if (MI->getOperand(i).isReg()) {
           MachineOperand &MO = MI->getOperand(i);
           unsigned Reg = MO.getReg();
@@ -853,6 +851,7 @@
               // just calculating the value we already have.
               BB->erase(I, LastUseMI);
               MI = I = LastUseMI;
+              e = MI->getNumOperands();
 
               CurrentScratchReg = PrevScratchReg;
               // Extend the live range of the register





More information about the llvm-commits mailing list