Avoid potential iterator invalidation problems.
llvm-svn: 40607
This commit is contained in:
parent
14fae50666
commit
850138157e
|
@ -895,11 +895,14 @@ bool GVN::runOnFunction(Function &F) {
|
||||||
currAvail = availableOut[DI->getIDom()->getBlock()];
|
currAvail = availableOut[DI->getIDom()->getBlock()];
|
||||||
|
|
||||||
for (BasicBlock::iterator BI = BB->begin(), BE = BB->end();
|
for (BasicBlock::iterator BI = BB->begin(), BE = BB->end();
|
||||||
BI != BE; ++BI) {
|
BI != BE; ) {
|
||||||
changed_function |= processInstruction(BI, currAvail, lastSeenLoad, toErase);
|
changed_function |= processInstruction(BI, currAvail, lastSeenLoad, toErase);
|
||||||
|
|
||||||
NumGVNInstr += toErase.size();
|
NumGVNInstr += toErase.size();
|
||||||
|
|
||||||
|
// Avoid iterator invalidation
|
||||||
|
++BI;
|
||||||
|
|
||||||
for (SmallVector<Instruction*, 4>::iterator I = toErase.begin(),
|
for (SmallVector<Instruction*, 4>::iterator I = toErase.begin(),
|
||||||
E = toErase.end(); I != E; ++I)
|
E = toErase.end(); I != E; ++I)
|
||||||
(*I)->eraseFromParent();
|
(*I)->eraseFromParent();
|
||||||
|
|
Loading…
Reference in New Issue