aboutsummaryrefslogtreecommitdiff
path: root/lib/Transforms/Utils/SimplifyCFG.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Transforms/Utils/SimplifyCFG.cpp')
-rw-r--r--lib/Transforms/Utils/SimplifyCFG.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/Transforms/Utils/SimplifyCFG.cpp b/lib/Transforms/Utils/SimplifyCFG.cpp
index e16125e832..9187a0f175 100644
--- a/lib/Transforms/Utils/SimplifyCFG.cpp
+++ b/lib/Transforms/Utils/SimplifyCFG.cpp
@@ -1899,6 +1899,13 @@ static bool SimplifyBranchOnICmpChain(BranchInst *BI, const TargetData *TD) {
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;
}