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
This commit is contained in:
Chris Lattner 2003-12-10 20:43:04 +00:00
parent da7d0693b5
commit 88369d214f

View File

@ -140,6 +140,8 @@ static bool TransformLoop(LoopInfo *Loops, Loop *Loop) {
DEBUG(IV->print(std::cerr));
while (isa<PHINode>(AfterPHIIt)) ++AfterPHIIt;
// Don't do math with pointers...
const Type *IVTy = IV->Phi->getType();
if (isa<PointerType>(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();
}
}