From: Chris Lattner Date: Fri, 5 Aug 2005 15:34:10 +0000 (+0000) Subject: Fix an iterator invalidation problem when we decide a phi has a constant value X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=80f4d88a97e1b925c2ea67f932dd9c3ce1df1f8d;p=oota-llvm.git Fix an iterator invalidation problem when we decide a phi has a constant value git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22675 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/VMCore/BasicBlock.cpp b/lib/VMCore/BasicBlock.cpp index bdcfb365c6e..66344db1501 100644 --- a/lib/VMCore/BasicBlock.cpp +++ b/lib/VMCore/BasicBlock.cpp @@ -189,7 +189,8 @@ void BasicBlock::removePredecessor(BasicBlock *Pred, // Okay, now we know that we need to remove predecessor #pred_idx from all // PHI nodes. Iterate over each PHI node fixing them up PHINode *PN; - for (iterator II = begin(); (PN = dyn_cast(II)); ++II) { + for (iterator II = begin(); (PN = dyn_cast(II)); ) { + ++II; PN->removeIncomingValue(Pred, false); // If all incoming values to the Phi are the same, we can replace the Phi // with that value.