diff options
| author | Owen Anderson <resistor@mac.com> | 2007-07-30 21:26:39 +0000 |
|---|---|---|
| committer | Owen Anderson <resistor@mac.com> | 2007-07-30 21:26:39 +0000 |
| commit | 850138157e78bf8bbdcf4ce67d298c5a76724e1c (patch) | |
| tree | a778f27161941e1524a6fd2f8821ba0dc2519791 /llvm/lib | |
| parent | 14fae506662300358ea4a971fac9d5ab2aa71749 (diff) | |
| download | bcm5719-llvm-850138157e78bf8bbdcf4ce67d298c5a76724e1c.tar.gz bcm5719-llvm-850138157e78bf8bbdcf4ce67d298c5a76724e1c.zip | |
Avoid potential iterator invalidation problems.
llvm-svn: 40607
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/Transforms/Scalar/GVN.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/Scalar/GVN.cpp b/llvm/lib/Transforms/Scalar/GVN.cpp index fee0eedcc77..42e9ee8900f 100644 --- a/llvm/lib/Transforms/Scalar/GVN.cpp +++ b/llvm/lib/Transforms/Scalar/GVN.cpp @@ -895,11 +895,14 @@ bool GVN::runOnFunction(Function &F) { currAvail = availableOut[DI->getIDom()->getBlock()]; for (BasicBlock::iterator BI = BB->begin(), BE = BB->end(); - BI != BE; ++BI) { + BI != BE; ) { changed_function |= processInstruction(BI, currAvail, lastSeenLoad, toErase); NumGVNInstr += toErase.size(); + // Avoid iterator invalidation + ++BI; + for (SmallVector<Instruction*, 4>::iterator I = toErase.begin(), E = toErase.end(); I != E; ++I) (*I)->eraseFromParent(); |

