aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/PHIElimination.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/CodeGen/PHIElimination.cpp')
-rw-r--r--lib/CodeGen/PHIElimination.cpp14
1 files changed, 13 insertions, 1 deletions
diff --git a/lib/CodeGen/PHIElimination.cpp b/lib/CodeGen/PHIElimination.cpp
index fc6574290b..bd716c2344 100644
--- a/lib/CodeGen/PHIElimination.cpp
+++ b/lib/CodeGen/PHIElimination.cpp
@@ -445,9 +445,21 @@ bool llvm::PHIElimination::isLiveIn(unsigned Reg, const MachineBasicBlock &MBB,
MachineBasicBlock *PHIElimination::SplitCriticalEdge(MachineBasicBlock *A,
MachineBasicBlock *B) {
assert(A && B && "Missing MBB end point");
- ++NumSplits;
MachineFunction *MF = A->getParent();
+
+ // We may need to update A's terminator, but we can't do that if AnalyzeBranch
+ // fails.
+ if (A->isLayoutSuccessor(B)) {
+ const TargetInstrInfo *TII = MF->getTarget().getInstrInfo();
+ MachineBasicBlock *TBB = 0, *FBB = 0;
+ SmallVector<MachineOperand, 4> Cond;
+ if (!TII->AnalyzeBranch(*A, TBB, FBB, Cond))
+ return NULL;
+ }
+
+ ++NumSplits;
+
MachineBasicBlock *NMBB = MF->CreateMachineBasicBlock();
MF->push_back(NMBB);
DEBUG(errs() << "PHIElimination splitting critical edge:"