summaryrefslogtreecommitdiff
path: root/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
commitc4ae94dee8c9a07334de7ffd85c45893208cca77 (patch)
tree735529519bec82748cb7af825994ff34a239f275 /lib/CodeGen/MachineSink.cpp
parent54ab2e9326993d9db0e393d3285a5c0a72af2c51 (diff)
downloadllvm-c4ae94dee8c9a07334de7ffd85c45893208cca77.tar.gz
llvm-c4ae94dee8c9a07334de7ffd85c45893208cca77.tar.bz2
llvm-c4ae94dee8c9a07334de7ffd85c45893208cca77.tar.xz
Don't do code sinking on unreachable blocks. It's unprofitable and hazardous.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@100455 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/MachineSink.cpp')
-rw-r--r--lib/CodeGen/MachineSink.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/CodeGen/MachineSink.cpp b/lib/CodeGen/MachineSink.cpp
index e47ba7c2cc..e659619015 100644
--- a/lib/CodeGen/MachineSink.cpp
+++ b/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.