Fix bug: test/Regression/Transforms/LowerInvoke/2004-02-29-PHICrash.llx
authorChris Lattner <sabre@nondot.org>
Sun, 29 Feb 2004 22:24:41 +0000 (22:24 +0000)
committerChris Lattner <sabre@nondot.org>
Sun, 29 Feb 2004 22:24:41 +0000 (22:24 +0000)
... which tickled the lowerinvoke pass because it used the BCE routines.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12012 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Utils/BreakCriticalEdges.cpp

index 178e8ca1957c468b4fd7a126b566eaf56f99233e..8e00f9c613e9bc0c7aa6842c544328b402bc25ab 100644 (file)
@@ -119,8 +119,11 @@ bool llvm::SplitCriticalEdge(TerminatorInst *TI, unsigned SuccNum, Pass *P) {
   //
   for (BasicBlock::iterator I = DestBB->begin();
        PHINode *PN = dyn_cast<PHINode>(I); ++I) {
-    // We no longer enter through TIBB, now we come in through NewBB.
-    PN->replaceUsesOfWith(TIBB, NewBB);
+    // We no longer enter through TIBB, now we come in through NewBB.  Revector
+    // exactly one entry in the PHI node that used to come from TIBB to come
+    // from NewBB.
+    Value *InVal = PN->removeIncomingValue(TIBB, false);
+    PN->addIncoming(InVal, NewBB);
   }
 
   // If we don't have a pass object, we can't update anything...