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 | ac4238f7bcf0cf1b0de98a0a9bda932c431c342f (patch) | |
| tree | 2e5ec0d59922c3ced6ea7f6f95b15980b050411f | |
| parent | aa81dce20cb0e862455b0b3f88c1d2129cdfb5a0 (diff) | |
| download | bcm5719-llvm-ac4238f7bcf0cf1b0de98a0a9bda932c431c342f.tar.gz bcm5719-llvm-ac4238f7bcf0cf1b0de98a0a9bda932c431c342f.zip | |
Do not add unreachable code to a natural loop!
llvm-svn: 9377
| -rw-r--r-- | llvm/lib/Analysis/LoopInfo.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/llvm/lib/Analysis/LoopInfo.cpp b/llvm/lib/Analysis/LoopInfo.cpp index 2277a156142..c1f97889e61 100644 --- a/llvm/lib/Analysis/LoopInfo.cpp +++ b/llvm/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, |

