[llvm-commits] [llvm] r40607 - /llvm/trunk/lib/Transforms/Scalar/GVN.cpp
Owen Anderson
resistor at mac.com
Mon Jul 30 14:26:39 PDT 2007
Author: resistor
Date: Mon Jul 30 16:26:39 2007
New Revision: 40607
URL: http://llvm.org/viewvc/llvm-project?rev=40607&view=rev
Log:
Avoid potential iterator invalidation problems.
Modified:
llvm/trunk/lib/Transforms/Scalar/GVN.cpp
Modified: llvm/trunk/lib/Transforms/Scalar/GVN.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/GVN.cpp?rev=40607&r1=40606&r2=40607&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/GVN.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/GVN.cpp Mon Jul 30 16:26:39 2007
@@ -895,11 +895,14 @@
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();
More information about the llvm-commits
mailing list