From: Chris Lattner Date: Wed, 10 Dec 2003 20:43:04 +0000 (+0000) Subject: Fix bug: IndVarsSimplify/2003-12-10-RemoveInstrCrash.llx X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=88369d214f320e888cb0bcb98db10ff8f47602a2;p=oota-llvm.git Fix bug: IndVarsSimplify/2003-12-10-RemoveInstrCrash.llx git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10385 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Transforms/Scalar/IndVarSimplify.cpp b/lib/Transforms/Scalar/IndVarSimplify.cpp index 369be476841..ed5aca372ab 100644 --- a/lib/Transforms/Scalar/IndVarSimplify.cpp +++ b/lib/Transforms/Scalar/IndVarSimplify.cpp @@ -140,6 +140,8 @@ static bool TransformLoop(LoopInfo *Loops, Loop *Loop) { DEBUG(IV->print(std::cerr)); + while (isa(AfterPHIIt)) ++AfterPHIIt; + // Don't do math with pointers... const Type *IVTy = IV->Phi->getType(); if (isa(IVTy)) IVTy = Type::ULongTy; @@ -204,6 +206,9 @@ static bool TransformLoop(LoopInfo *Loops, Loop *Loop) { PHIOps.insert(PHIOps.end(), MaybeDead->op_begin(), MaybeDead->op_end()); MaybeDead->getParent()->getInstList().erase(MaybeDead); + + // Erasing the instruction could invalidate the AfterPHI iterator! + AfterPHIIt = Header->begin(); } }