Fix a bug introduced with my previous patch, where it didn't correctly handle

instructions which replace themselves when FI's are rewritten (common on ppc).
This fixes CodeGen/PowerPC/2006-10-17-ppc64-alloca.ll

llvm-svn: 35789
This commit is contained in:
Chris Lattner 2007-04-09 01:19:33 +00:00
parent 4ca9cbb170
commit f73d215023
1 changed files with 9 additions and 7 deletions

View File

@ -498,20 +498,22 @@ void PEI::replaceFrameIndices(MachineFunction &Fn) {
for (MachineFunction::iterator BB = Fn.begin(), E = Fn.end(); BB != E; ++BB) { for (MachineFunction::iterator BB = Fn.begin(), E = Fn.end(); BB != E; ++BB) {
if (RS) RS->enterBasicBlock(BB); if (RS) RS->enterBasicBlock(BB);
for (MachineBasicBlock::iterator I = BB->begin(); I != BB->end(); ++I) { for (MachineBasicBlock::iterator I = BB->begin(); I != BB->end(); ) {
for (unsigned i = 0, e = I->getNumOperands(); i != e; ++i) MachineInstr *MI = I++;
if (I->getOperand(i).isFrameIndex()) { for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i)
if (MI->getOperand(i).isFrameIndex()) {
// If this instruction has a FrameIndex operand, we need to use that // If this instruction has a FrameIndex operand, we need to use that
// target machine register info object to eliminate it. // target machine register info object to eliminate it.
MRI.eliminateFrameIndex(I, RS); MRI.eliminateFrameIndex(MI, RS);
// Revisit the instruction in full. Some instructions (e.g. inline // Revisit the instruction in full. Some instructions (e.g. inline
// asm instructions) can have multiple frame indices. // asm instructions) can have multiple frame indices.
e = I->getNumOperands(); --I;
i = -1U; MI = 0;
break;
} }
// Update register states. // Update register states.
if (RS) RS->forward(I); if (RS && MI) RS->forward(MI);
} }
} }
} }