Teach MachineBasicBlock::updateTerminator() to handle a failing TII->ReverseBranchCondition(Cond) call.

This fixes the MallocBench/cfrac test case regression.

llvm-svn: 89608
This commit is contained in:
Jakob Stoklund Olesen 2009-11-22 18:28:04 +00:00
parent 43bff37afb
commit 8a3fdae0aa
1 changed files with 8 additions and 2 deletions

View File

@ -279,8 +279,9 @@ void MachineBasicBlock::updateTerminator() {
// successors is its layout successor, rewrite it to a fallthrough // successors is its layout successor, rewrite it to a fallthrough
// conditional branch. // conditional branch.
if (isLayoutSuccessor(TBB)) { if (isLayoutSuccessor(TBB)) {
if (TII->ReverseBranchCondition(Cond))
return;
TII->RemoveBranch(*this); TII->RemoveBranch(*this);
TII->ReverseBranchCondition(Cond);
TII->InsertBranch(*this, FBB, 0, Cond); TII->InsertBranch(*this, FBB, 0, Cond);
} else if (isLayoutSuccessor(FBB)) { } else if (isLayoutSuccessor(FBB)) {
TII->RemoveBranch(*this); TII->RemoveBranch(*this);
@ -292,8 +293,13 @@ void MachineBasicBlock::updateTerminator() {
MachineBasicBlock *MBBB = *next(succ_begin()); MachineBasicBlock *MBBB = *next(succ_begin());
if (MBBA == TBB) std::swap(MBBB, MBBA); if (MBBA == TBB) std::swap(MBBB, MBBA);
if (isLayoutSuccessor(TBB)) { if (isLayoutSuccessor(TBB)) {
if (TII->ReverseBranchCondition(Cond)) {
// We can't reverse the condition, add an unconditional branch.
Cond.clear();
TII->InsertBranch(*this, MBBA, 0, Cond);
return;
}
TII->RemoveBranch(*this); TII->RemoveBranch(*this);
TII->ReverseBranchCondition(Cond);
TII->InsertBranch(*this, MBBA, 0, Cond); TII->InsertBranch(*this, MBBA, 0, Cond);
} else if (!isLayoutSuccessor(MBBA)) { } else if (!isLayoutSuccessor(MBBA)) {
TII->RemoveBranch(*this); TII->RemoveBranch(*this);