Fix an iterator invalidation problem when we decide a phi has a constant value
authorChris Lattner <sabre@nondot.org>
Fri, 5 Aug 2005 15:34:10 +0000 (15:34 +0000)
committerChris Lattner <sabre@nondot.org>
Fri, 5 Aug 2005 15:34:10 +0000 (15:34 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22675 91177308-0d34-0410-b5e6-96231b3b80d8

lib/VMCore/BasicBlock.cpp

index bdcfb365c6ede372c37280f95ae4d5e0f3c988fe..66344db1501c1ef216b82a4c1b0bc747a50df967 100644 (file)
@@ -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<PHINode>(II)); ++II) {
+    for (iterator II = begin(); (PN = dyn_cast<PHINode>(II)); ) {
+      ++II;
       PN->removeIncomingValue(Pred, false);
       // If all incoming values to the Phi are the same, we can replace the Phi
       // with that value.