fix a bug in r121680 that upset the various buildbots.
llvm-svn: 121687
diff --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
index e16125e..9187a0f 100644
--- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
+++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
@@ -1899,6 +1899,13 @@
BranchInst::Create(EdgeBB, NewBB, ExtraCase, OldTI);
OldTI->eraseFromParent();
+
+ // If there are PHI nodes in EdgeBB, then we need to add a new entry to them
+ // for the edge we just added.
+ for (BasicBlock::iterator I = EdgeBB->begin(); isa<PHINode>(I); ++I) {
+ PHINode *PN = cast<PHINode>(I);
+ PN->addIncoming(PN->getIncomingValueForBlock(NewBB), BB);
+ }
BB = NewBB;
}