From 33524c3b26e3b709488d84094493d9a6098c0155 Mon Sep 17 00:00:00 2001 From: Jim Grosbach Date: Wed, 14 Oct 2009 21:22:39 +0000 Subject: Make loop not recalc getNumOperands() each time around git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@84138 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/PrologEpilogInserter.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'lib/CodeGen/PrologEpilogInserter.cpp') diff --git a/lib/CodeGen/PrologEpilogInserter.cpp b/lib/CodeGen/PrologEpilogInserter.cpp index 74cc18b..7af0bba 100644 --- a/lib/CodeGen/PrologEpilogInserter.cpp +++ b/lib/CodeGen/PrologEpilogInserter.cpp @@ -778,9 +778,7 @@ void PEI::scavengeFrameVirtualRegs(MachineFunction &Fn) { // 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 @@ void PEI::scavengeFrameVirtualRegs(MachineFunction &Fn) { // 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 -- cgit v1.1