summaryrefslogtreecommitdiff
path: root/lib/CodeGen/CodePlacementOpt.cpp
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2010-02-18 21:25:53 +0000
committerDan Gohman <gohman@apple.com>2010-02-18 21:25:53 +0000
commit49d7f8d341a7b4137c674ce0f08f5b18e8195f4a (patch)
tree267e9a0cd03db18189b5212e93b787b5df0c04a4 /lib/CodeGen/CodePlacementOpt.cpp
parent0ce7b1255c86dcfdfdd4dfad9ea625de12657944 (diff)
downloadllvm-49d7f8d341a7b4137c674ce0f08f5b18e8195f4a.tar.gz
llvm-49d7f8d341a7b4137c674ce0f08f5b18e8195f4a.tar.bz2
llvm-49d7f8d341a7b4137c674ce0f08f5b18e8195f4a.tar.xz
Make CodePlacementOpt detect special EH control flow by
checking whether AnalyzeBranch disagrees with the CFG directly, rather than looking for EH_LABEL instructions. EH_LABEL instructions aren't always at the end of the block, due to FP_REG_KILL and other things. This fixes an infinite loop compiling MultiSource/Benchmarks/Bullet. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96611 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CodePlacementOpt.cpp')
-rw-r--r--lib/CodeGen/CodePlacementOpt.cpp15
1 files changed, 8 insertions, 7 deletions
diff --git a/lib/CodeGen/CodePlacementOpt.cpp b/lib/CodeGen/CodePlacementOpt.cpp
index a13a310dec..3ff2a046d2 100644
--- a/lib/CodeGen/CodePlacementOpt.cpp
+++ b/lib/CodeGen/CodePlacementOpt.cpp
@@ -102,13 +102,6 @@ bool CodePlacementOpt::HasAnalyzableTerminator(MachineBasicBlock *MBB) {
// Conservatively ignore EH landing pads.
if (MBB->isLandingPad()) return false;
- // Ignore blocks which look like they might have EH-related control flow.
- // At the time of this writing, there are blocks which AnalyzeBranch
- // thinks end in single uncoditional branches, yet which have two CFG
- // successors. Code in this file is not prepared to reason about such things.
- if (!MBB->empty() && MBB->back().isEHLabel())
- return false;
-
// Aggressively handle return blocks and similar constructs.
if (MBB->succ_empty()) return true;
@@ -118,6 +111,14 @@ bool CodePlacementOpt::HasAnalyzableTerminator(MachineBasicBlock *MBB) {
// Make sure the terminator is understood.
if (TII->AnalyzeBranch(*MBB, TBB, FBB, Cond))
return false;
+ // Ignore blocks which look like they might have EH-related control flow.
+ // AnalyzeBranch thinks it knows how to analyze such things, but it doesn't
+ // recognize the possibility of a control transfer through an unwind.
+ // Such blocks contain EH_LABEL instructions, however they may be in the
+ // middle of the block. Instead of searching for them, just check to see
+ // if the CFG disagrees with AnalyzeBranch.
+ if (1u + !Cond.empty() != MBB->succ_size())
+ return false;
// Make sure we have the option of reversing the condition.
if (!Cond.empty() && TII->ReverseBranchCondition(Cond))
return false;