summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-12-01 06:04:43 +0000
committerChris Lattner <sabre@nondot.org>2009-12-01 06:04:43 +0000
commit3c9aca907970255d37da45528e6578f436de6e22 (patch)
tree79de30b8e0e014243992d34dbafae47b97b412db /llvm/lib/Transforms
parent3a438a93366e13b26ad08a1a3363c0fc0d3e2213 (diff)
downloadbcm5719-llvm-3c9aca907970255d37da45528e6578f436de6e22.tar.gz
bcm5719-llvm-3c9aca907970255d37da45528e6578f436de6e22.zip
fix PR5640 by tracking whether a block is the header of a loop more
precisely, which prevents us from infinitely peeling the loop. llvm-svn: 90211
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/Scalar/JumpThreading.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/llvm/lib/Transforms/Scalar/JumpThreading.cpp b/llvm/lib/Transforms/Scalar/JumpThreading.cpp
index 58641135ede..1b93f3441e4 100644
--- a/llvm/lib/Transforms/Scalar/JumpThreading.cpp
+++ b/llvm/lib/Transforms/Scalar/JumpThreading.cpp
@@ -158,12 +158,18 @@ bool JumpThreading::runOnFunction(Function &F) {
if (BBI->isTerminator()) {
// Since TryToSimplifyUncondBranchFromEmptyBlock may delete the
// block, we have to make sure it isn't in the LoopHeaders set. We
- // reinsert afterward in the rare case when the block isn't deleted.
+ // reinsert afterward if needed.
bool ErasedFromLoopHeaders = LoopHeaders.erase(BB);
+ BasicBlock *Succ = BI->getSuccessor(0);
- if (TryToSimplifyUncondBranchFromEmptyBlock(BB))
+ if (TryToSimplifyUncondBranchFromEmptyBlock(BB)) {
Changed = true;
- else if (ErasedFromLoopHeaders)
+ // If we deleted BB and BB was the header of a loop, then the
+ // successor is now the header of the loop.
+ BB = Succ;
+ }
+
+ if (ErasedFromLoopHeaders)
LoopHeaders.insert(BB);
}
}
OpenPOWER on IntegriCloud