diff options
author | Dale Johannesen <dalej@apple.com> | 2010-04-02 01:38:09 +0000 |
---|---|---|
committer | Dale Johannesen <dalej@apple.com> | 2010-04-02 01:38:09 +0000 |
commit | 4244d12769ff19cc917ac39ee450a12bbcfeccfb (patch) | |
tree | a73cbf2711c72627e31eee0ca4e370c63a0a177b /llvm/lib/CodeGen | |
parent | 8d6d0d4c5866268c202389487e49626181a340f1 (diff) | |
download | bcm5719-llvm-4244d12769ff19cc917ac39ee450a12bbcfeccfb.tar.gz bcm5719-llvm-4244d12769ff19cc917ac39ee450a12bbcfeccfb.zip |
Teach AnalyzeBranch, RemoveBranch and the branch
folder to be tolerant of debug info following the
branch(es) at the end of a block.
llvm-svn: 100168
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r-- | llvm/lib/CodeGen/BranchFolding.cpp | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/llvm/lib/CodeGen/BranchFolding.cpp b/llvm/lib/CodeGen/BranchFolding.cpp index 151e9cd4403..8f519407ccd 100644 --- a/llvm/lib/CodeGen/BranchFolding.cpp +++ b/llvm/lib/CodeGen/BranchFolding.cpp @@ -972,15 +972,21 @@ static bool IsBetterFallthrough(MachineBasicBlock *MBB1, // MBB1 doesn't, we prefer to fall through into MBB1. This allows us to // optimize branches that branch to either a return block or an assert block // into a fallthrough to the return. - if (MBB1->empty() || MBB2->empty()) return false; + if (IsEmptyBlock(MBB1) || IsEmptyBlock(MBB2)) return false; // If there is a clear successor ordering we make sure that one block // will fall through to the next if (MBB1->isSuccessor(MBB2)) return true; if (MBB2->isSuccessor(MBB1)) return false; - MachineInstr *MBB1I = --MBB1->end(); - MachineInstr *MBB2I = --MBB2->end(); + // Neither block consists entirely of debug info (per IsEmptyBlock check), + // so we needn't test for falling off the beginning here. + MachineBasicBlock::iterator MBB1I = --MBB1->end(); + while (MBB1I->isDebugValue()) + --MBB1I; + MachineBasicBlock::iterator MBB2I = --MBB2->end(); + while (MBB2I->isDebugValue()) + --MBB2I; return MBB2I->getDesc().isCall() && !MBB1I->getDesc().isCall(); } |