diff options
author | Chris Lattner <sabre@nondot.org> | 2008-11-27 19:25:19 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2008-11-27 19:25:19 +0000 |
commit | 5dfbfcd80d3a41fb6017914a8d5cb85a205d1884 (patch) | |
tree | 5e8f5d20a24e698ced30e8810d9375e33e7e61c0 /llvm/lib/Transforms/Scalar/JumpThreading.cpp | |
parent | 2c96bdd8d62c4e3daa0f7558c7276a40fd32599b (diff) | |
download | bcm5719-llvm-5dfbfcd80d3a41fb6017914a8d5cb85a205d1884.tar.gz bcm5719-llvm-5dfbfcd80d3a41fb6017914a8d5cb85a205d1884.zip |
Fix PR3138: if we merge the entry block into another block, make sure to
move the other block back up into the entry position!
llvm-svn: 60179
Diffstat (limited to 'llvm/lib/Transforms/Scalar/JumpThreading.cpp')
-rw-r--r-- | llvm/lib/Transforms/Scalar/JumpThreading.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Scalar/JumpThreading.cpp b/llvm/lib/Transforms/Scalar/JumpThreading.cpp index ec35a891e05..5de5fb3b776 100644 --- a/llvm/lib/Transforms/Scalar/JumpThreading.cpp +++ b/llvm/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; } |