From da2903f02801ba67b8cac2917d915c930a4e977e Mon Sep 17 00:00:00 2001 From: David Greene Date: Tue, 1 Apr 2008 22:14:23 +0000 Subject: [PATCH] Iterators folloring a SmallVector erased element are invalidated so don't access cached iterators from after the erased element. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@49056 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/Scalar/LoopIndexSplit.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/lib/Transforms/Scalar/LoopIndexSplit.cpp b/lib/Transforms/Scalar/LoopIndexSplit.cpp index 8053554c17c..48b45351a0f 100644 --- a/lib/Transforms/Scalar/LoopIndexSplit.cpp +++ b/lib/Transforms/Scalar/LoopIndexSplit.cpp @@ -232,8 +232,8 @@ bool LoopIndexSplit::runOnLoop(Loop *IncomingLoop, LPPassManager &LPM_Ref) { return false; // First see if it is possible to eliminate loop itself or not. - for (SmallVector::iterator SI = SplitData.begin(), - E = SplitData.end(); SI != E;) { + for (SmallVector::iterator SI = SplitData.begin(); + SI != SplitData.end();) { SplitInfo &SD = *SI; ICmpInst *CI = dyn_cast(SD.SplitCondition); if (SD.SplitCondition->getOpcode() == Instruction::And) { @@ -244,8 +244,7 @@ bool LoopIndexSplit::runOnLoop(Loop *IncomingLoop, LPPassManager &LPM_Ref) { return Changed; } else { SmallVector::iterator Delete_SI = SI; - ++SI; - SplitData.erase(Delete_SI); + SI = SplitData.erase(Delete_SI); } } else if (CI && CI->getPredicate() == ICmpInst::ICMP_EQ) { @@ -256,8 +255,7 @@ bool LoopIndexSplit::runOnLoop(Loop *IncomingLoop, LPPassManager &LPM_Ref) { return Changed; } else { SmallVector::iterator Delete_SI = SI; - ++SI; - SplitData.erase(Delete_SI); + SI = SplitData.erase(Delete_SI); } } else ++SI; -- 2.34.1