diff options
author | Chris Lattner <sabre@nondot.org> | 2003-10-22 16:41:21 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2003-10-22 16:41:21 +0000 |
commit | 59dc17873d10c0cf37262b86318359bc1220cc1d (patch) | |
tree | 384bbe9003b9c857d4044a32b2682c6f6c4f1546 /lib/Analysis/LoopInfo.cpp | |
parent | d073ea00535614323aafd36e3e71582311089700 (diff) |
Do not add unreachable code to a natural loop!
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@9377 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/LoopInfo.cpp')
-rw-r--r-- | lib/Analysis/LoopInfo.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/Analysis/LoopInfo.cpp b/lib/Analysis/LoopInfo.cpp index 2277a15614..c1f97889e6 100644 --- a/lib/Analysis/LoopInfo.cpp +++ b/lib/Analysis/LoopInfo.cpp @@ -151,11 +151,14 @@ Loop *LoopInfo::ConsiderForLoop(BasicBlock *BB, const DominatorSet &DS) { Loop *L = new Loop(BB); BBMap[BB] = L; + BasicBlock *EntryBlock = &BB->getParent()->getEntryBlock(); + while (!TodoStack.empty()) { // Process all the nodes in the loop BasicBlock *X = TodoStack.back(); TodoStack.pop_back(); - if (!L->contains(X)) { // As of yet unprocessed?? + if (!L->contains(X) && // As of yet unprocessed?? + DS.dominates(EntryBlock, X)) { // X is reachable from entry block? // Check to see if this block already belongs to a loop. If this occurs // then we have a case where a loop that is supposed to be a child of the // current loop was processed before the current loop. When this occurs, |