diff options
author | Devang Patel <dpatel@apple.com> | 2007-08-14 23:59:17 +0000 |
---|---|---|
committer | Devang Patel <dpatel@apple.com> | 2007-08-14 23:59:17 +0000 |
commit | fb6c37ca2b44357619f9678305ba3caf4eabba1e (patch) | |
tree | db8ae1d4443cf30ed4b720dfd469db3ac82cf687 /lib | |
parent | 79276b3b9f8b3933f6269ffed5c181d1b38aa97f (diff) | |
download | external_llvm-fb6c37ca2b44357619f9678305ba3caf4eabba1e.zip external_llvm-fb6c37ca2b44357619f9678305ba3caf4eabba1e.tar.gz external_llvm-fb6c37ca2b44357619f9678305ba3caf4eabba1e.tar.bz2 |
Break infinite loop.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@41091 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Transforms/Utils/CloneLoop.cpp | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/lib/Transforms/Utils/CloneLoop.cpp b/lib/Transforms/Utils/CloneLoop.cpp index 02278b6..6e35916 100644 --- a/lib/Transforms/Utils/CloneLoop.cpp +++ b/lib/Transforms/Utils/CloneLoop.cpp @@ -84,22 +84,21 @@ Loop *llvm::CloneLoop(Loop *OrigL, LPPassManager *LPM, LoopInfo *LI, } SmallVector<BasicBlock *, 16> NewBlocks; - SmallVector<std::pair<Loop *, Loop::iterator>, 8> LoopNest; - LoopNest.push_back(std::make_pair(OrigL, OrigL->begin())); - - Loop *NewLoop = NULL; - while (!LoopNest.empty()) { - Loop *L = LoopNest.back().first; - Loop::iterator SubLoop = LoopNest.back().second; - - // Handle sub loops. - if (SubLoop != L->end()) { - Loop *SL = *SubLoop; - LoopNest.push_back(std::make_pair(SL, SL->begin())); - } + // Populate loop nest. + SmallVector<Loop *, 8> LoopNest; + LoopNest.push_back(OrigL); + + + Loop *NewParentLoop = NULL; + while (!LoopNest.empty()) { + Loop *L = LoopNest.back(); LoopNest.pop_back(); - NewLoop = new Loop(); + Loop *NewLoop = new Loop(); + + if (!NewParentLoop) + NewParentLoop = NewLoop; + LPM->insertLoop(NewLoop, L->getParentLoop()); // Clone Basic Blocks. @@ -122,6 +121,9 @@ Loop *llvm::CloneLoop(Loop *OrigL, LPPassManager *LPM, LoopInfo *LI, CloneDominatorInfo(BB, ValueMap, DT, DF); } + // Process sub loops + for (Loop::iterator I = L->begin(), E = L->end(); I != E; ++I) + LoopNest.push_back(*I); } // Remap instructions to reference operands from ValueMap. @@ -145,5 +147,5 @@ Loop *llvm::CloneLoop(Loop *OrigL, LPPassManager *LPM, LoopInfo *LI, Function *F = Latch->getParent(); F->getBasicBlockList().insert(Latch, NewBlocks.begin(), NewBlocks.end()); - return NewLoop; + return NewParentLoop; } |