From 564900e5e5039bcde465aa6d2daa7efe3f3d344b Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Tue, 2 Aug 2005 00:41:11 +0000 Subject: [PATCH] Fix an iterator invalidation problem llvm-svn: 22575 --- llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp b/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp index f06cf33c138e..0967fb7200b8 100644 --- a/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp +++ b/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp @@ -622,7 +622,9 @@ void LoopStrengthReduce::runOnLoop(Loop *L) { BasicBlock::iterator I = L->getHeader()->begin(); PHINode *PN; - for (; (PN = dyn_cast(I)); ++I) { + for (; (PN = dyn_cast(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 -- GitLab