summaryrefslogtreecommitdiff
path: root/lib/Transforms/Scalar/CodeGenPrepare.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2008-11-28 19:54:49 +0000
committerChris Lattner <sabre@nondot.org>2008-11-28 19:54:49 +0000
commitf5102a0f088e7c96f7028bf7ca1c24975c314fff (patch)
tree112c00bfeacfd18dbf355f8fc8c56664f43f11e7 /lib/Transforms/Scalar/CodeGenPrepare.cpp
parentc6dbe7fbad79eddb030a4450a135d13e6b0ca942 (diff)
downloadllvm-f5102a0f088e7c96f7028bf7ca1c24975c314fff.tar.gz
llvm-f5102a0f088e7c96f7028bf7ca1c24975c314fff.tar.bz2
llvm-f5102a0f088e7c96f7028bf7ca1c24975c314fff.tar.xz
don't call MergeBasicBlockIntoOnlyPred on a block whose only
predecessor is itself. This doesn't make sense, and this is a dead infinite loop anyway. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60210 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Scalar/CodeGenPrepare.cpp')
-rw-r--r--lib/Transforms/Scalar/CodeGenPrepare.cpp22
1 files changed, 12 insertions, 10 deletions
diff --git a/lib/Transforms/Scalar/CodeGenPrepare.cpp b/lib/Transforms/Scalar/CodeGenPrepare.cpp
index e6b7497d6b..7079fa828b 100644
--- a/lib/Transforms/Scalar/CodeGenPrepare.cpp
+++ b/lib/Transforms/Scalar/CodeGenPrepare.cpp
@@ -205,16 +205,18 @@ void CodeGenPrepare::EliminateMostlyEmptyBlock(BasicBlock *BB) {
// If the destination block has a single pred, then this is a trivial edge,
// just collapse it.
if (BasicBlock *SinglePred = DestBB->getSinglePredecessor()) {
- // 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(DestBB);
-
- if (isEntry && BB != &BB->getParent()->getEntryBlock())
- BB->moveBefore(&BB->getParent()->getEntryBlock());
-
- DOUT << "AFTER:\n" << *DestBB << "\n\n\n";
- return;
+ if (SinglePred != DestBB) {
+ // 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(DestBB);
+
+ if (isEntry && BB != &BB->getParent()->getEntryBlock())
+ BB->moveBefore(&BB->getParent()->getEntryBlock());
+
+ DOUT << "AFTER:\n" << *DestBB << "\n\n\n";
+ return;
+ }
}
// Otherwise, we have multiple predecessors of BB. Update the PHIs in DestBB