summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/BranchFolding.cpp
diff options
context:
space:
mode:
authorDale Johannesen <dalej@apple.com>2010-03-10 19:57:56 +0000
committerDale Johannesen <dalej@apple.com>2010-03-10 19:57:56 +0000
commite9b361b2e6efe7e632cd21c48327bc28306fb3cd (patch)
tree94b7f05ac9a7585ea4fa0c2925b51c17583ab592 /llvm/lib/CodeGen/BranchFolding.cpp
parent115b4756b5c7940c997d571a6db85eaa7ec732ad (diff)
downloadbcm5719-llvm-e9b361b2e6efe7e632cd21c48327bc28306fb3cd.tar.gz
bcm5719-llvm-e9b361b2e6efe7e632cd21c48327bc28306fb3cd.zip
Fix another place where DEBUG_VALUE affected codegen.
llvm-svn: 98181
Diffstat (limited to 'llvm/lib/CodeGen/BranchFolding.cpp')
-rw-r--r--llvm/lib/CodeGen/BranchFolding.cpp13
1 files changed, 12 insertions, 1 deletions
diff --git a/llvm/lib/CodeGen/BranchFolding.cpp b/llvm/lib/CodeGen/BranchFolding.cpp
index 889763ac1c8..7e27bf5631e 100644
--- a/llvm/lib/CodeGen/BranchFolding.cpp
+++ b/llvm/lib/CodeGen/BranchFolding.cpp
@@ -984,6 +984,17 @@ static bool IsEmptyBlock(MachineBasicBlock *MBB) {
return true;
}
+// Blocks with only debug info and branches should be considered the same
+// as blocks with only branches.
+static bool IsBranchOnlyBlock(MachineBasicBlock *MBB) {
+ MachineBasicBlock::iterator MBBI, MBBE;
+ for (MBBI = MBB->begin(), MBBE = MBB->end(); MBBI!=MBBE; ++MBBI) {
+ if (!MBBI->isDebugValue())
+ break;
+ }
+ return (MBBI->getDesc().isBranch());
+}
+
/// IsBetterFallthrough - Return true if it would be clearly better to
/// fall-through to MBB1 than to fall through into MBB2. This has to return
/// a strict ordering, returning true for both (MBB1,MBB2) and (MBB2,MBB1) will
@@ -1206,7 +1217,7 @@ ReoptimizeBlock:
// If this branch is the only thing in its block, see if we can forward
// other blocks across it.
if (CurTBB && CurCond.empty() && CurFBB == 0 &&
- MBB->begin()->getDesc().isBranch() && CurTBB != MBB &&
+ IsBranchOnlyBlock(MBB) && CurTBB != MBB &&
!MBB->hasAddressTaken()) {
// This block may contain just an unconditional branch. Because there can
// be 'non-branch terminators' in the block, try removing the branch and
OpenPOWER on IntegriCloud