[llvm-commits] CVS: llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp

Chris Lattner lattner at cs.uiuc.edu
Mon Aug 1 17:41:23 PDT 2005



Changes in directory llvm/lib/Transforms/Scalar:

LoopStrengthReduce.cpp updated: 1.17 -> 1.18
---
Log message:

Fix an iterator invalidation problem


---
Diffs of the changes:  (+3 -1)

 LoopStrengthReduce.cpp |    4 +++-
 1 files changed, 3 insertions(+), 1 deletion(-)


Index: llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
diff -u llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp:1.17 llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp:1.18
--- llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp:1.17	Sat Jul 30 13:33:25 2005
+++ llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp	Mon Aug  1 19:41:11 2005
@@ -622,7 +622,9 @@
 
     BasicBlock::iterator I = L->getHeader()->begin();
     PHINode *PN;
-    for (; (PN = dyn_cast<PHINode>(I)); ++I) {
+    for (; (PN = dyn_cast<PHINode>(I)); ) {
+      ++I;  // Preincrement iterator to avoid invalidating it when deleting PN.
+      
       // At this point, we know that we have killed one or more GEP instructions.
       // It is worth checking to see if the cann indvar is also dead, so that we
       // can remove it as well.  The requirements for the cann indvar to be






More information about the llvm-commits mailing list