From 5493acac6fcc06ef6fa8577bf9f720762d78e870 Mon Sep 17 00:00:00 2001 From: Jakob Stoklund Olesen Date: Tue, 17 Nov 2009 20:46:00 +0000 Subject: [PATCH] Never call UpdateTerminator() when AnalyzeBranch would fail. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@89139 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/PHIElimination.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/CodeGen/PHIElimination.cpp b/lib/CodeGen/PHIElimination.cpp index fc6574290b3..bd716c23444 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 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:" -- 2.34.1