aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2008-11-27 19:25:19 +0000
committerChris Lattner <sabre@nondot.org>2008-11-27 19:25:19 +0000
commit3d86d242c69a26ba2e6102f32b00b04884c4c9b1 (patch)
tree85f3f2b4af5efccb0210169a7374abd2af6ccd95 /lib
parenta89d102b32d74fed5d3c7aeea8869a11c3074063 (diff)
downloadexternal_llvm-3d86d242c69a26ba2e6102f32b00b04884c4c9b1.zip
external_llvm-3d86d242c69a26ba2e6102f32b00b04884c4c9b1.tar.gz
external_llvm-3d86d242c69a26ba2e6102f32b00b04884c4c9b1.tar.bz2
Fix PR3138: if we merge the entry block into another block, make sure to
move the other block back up into the entry position! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60179 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/Transforms/Scalar/JumpThreading.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/Transforms/Scalar/JumpThreading.cpp b/lib/Transforms/Scalar/JumpThreading.cpp
index ec35a89..5de5fb3 100644
--- a/lib/Transforms/Scalar/JumpThreading.cpp
+++ b/lib/Transforms/Scalar/JumpThreading.cpp
@@ -165,7 +165,13 @@ bool JumpThreading::ProcessBlock(BasicBlock *BB) {
// predecessors of our predecessor block.
if (BasicBlock *SinglePred = BB->getSinglePredecessor())
if (SinglePred->getTerminator()->getNumSuccessors() == 1) {
+ // Remember if SinglePred was the entry block of the function. If so, we
+ // will need to move BB back to the entry position.
+ bool isEntry = SinglePred == &SinglePred->getParent()->getEntryBlock();
MergeBasicBlockIntoOnlyPred(BB);
+
+ if (isEntry && BB != &BB->getParent()->getEntryBlock())
+ BB->moveBefore(&BB->getParent()->getEntryBlock());
return true;
}