Fix an iterator invalidation issue.

llvm-svn: 46263
This commit is contained in:
Owen Anderson 2008-01-22 23:58:54 +00:00
parent 1e0d4d2aa8
commit 7fe0bb2b43
1 changed files with 8 additions and 2 deletions

View File

@ -751,11 +751,17 @@ bool StrongPHIElimination::runOnMachineFunction(MachineFunction &Fn) {
// FIXME: Insert last-minute copies
// Remove PHIs
for (MachineFunction::iterator I = Fn.begin(), E = Fn.end(); I != E; ++I)
std::vector<MachineInstr*> phis;
for (MachineFunction::iterator I = Fn.begin(), E = Fn.end(); I != E; ++I) {
for (MachineBasicBlock::iterator BI = I->begin(), BE = I->end();
BI != BE; ++BI)
if (BI->getOpcode() == TargetInstrInfo::PHI)
BI->eraseFromParent();
phis.push_back(BI);
}
for (std::vector<MachineInstr*>::iterator I = phis.begin(), E = phis.end();
I != E; ++I)
(*I)->eraseFromParent();
return false;
}