summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/MachineSink.cpp
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2010-04-05 19:17:22 +0000
committerDan Gohman <gohman@apple.com>2010-04-05 19:17:22 +0000
commit918a90a3caf064e5d3f73736f8c0a38cc366d1aa (patch)
tree3878d4511211956be220783a1e937c64276a3877 /llvm/lib/CodeGen/MachineSink.cpp
parent976d1b600220301c467059c661abbcf9052cbf07 (diff)
downloadbcm5719-llvm-918a90a3caf064e5d3f73736f8c0a38cc366d1aa.tar.gz
bcm5719-llvm-918a90a3caf064e5d3f73736f8c0a38cc366d1aa.zip
Don't do code sinking on unreachable blocks. It's unprofitable and hazardous.
llvm-svn: 100455
Diffstat (limited to 'llvm/lib/CodeGen/MachineSink.cpp')
-rw-r--r--llvm/lib/CodeGen/MachineSink.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/MachineSink.cpp b/llvm/lib/CodeGen/MachineSink.cpp
index e47ba7c2cc3..e6596190157 100644
--- a/llvm/lib/CodeGen/MachineSink.cpp
+++ b/llvm/lib/CodeGen/MachineSink.cpp
@@ -126,6 +126,11 @@ bool MachineSinking::ProcessBlock(MachineBasicBlock &MBB) {
// Can't sink anything out of a block that has less than two successors.
if (MBB.succ_size() <= 1 || MBB.empty()) return false;
+ // Don't bother sinking code out of unreachable blocks. In addition to being
+ // unprofitable, it can also lead to infinite looping, because in an unreachable
+ // loop there may be nowhere to stop.
+ if (!DT->isReachableFromEntry(&MBB)) return false;
+
bool MadeChange = false;
// Walk the basic block bottom-up. Remember if we saw a store.
OpenPOWER on IntegriCloud