diff options
author | Chris Lattner <sabre@nondot.org> | 2004-01-08 00:09:44 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2004-01-08 00:09:44 +0000 |
commit | 329c1c6c949d07e3fe9722ec633b4258217fd99d (patch) | |
tree | 34270cc171608437ca572bfc081ea6bab2fe0d80 /lib/Transforms/Utils | |
parent | f789d409faec2c133039d1b1a0c27f2bb7065cd8 (diff) | |
download | external_llvm-329c1c6c949d07e3fe9722ec633b4258217fd99d.zip external_llvm-329c1c6c949d07e3fe9722ec633b4258217fd99d.tar.gz external_llvm-329c1c6c949d07e3fe9722ec633b4258217fd99d.tar.bz2 |
Improve encapsulation in the Loop and LoopInfo classes by eliminating the
getSubLoops/getTopLevelLoops methods, replacing them with iterator-based
accessors.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10714 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Utils')
-rw-r--r-- | lib/Transforms/Utils/LoopSimplify.cpp | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/lib/Transforms/Utils/LoopSimplify.cpp b/lib/Transforms/Utils/LoopSimplify.cpp index 9beae4f..45f31aa 100644 --- a/lib/Transforms/Utils/LoopSimplify.cpp +++ b/lib/Transforms/Utils/LoopSimplify.cpp @@ -91,8 +91,8 @@ bool LoopSimplify::runOnFunction(Function &F) { bool Changed = false; LoopInfo &LI = getAnalysis<LoopInfo>(); - for (unsigned i = 0, e = LI.getTopLevelLoops().size(); i != e; ++i) - Changed |= ProcessLoop(LI.getTopLevelLoops()[i]); + for (LoopInfo::iterator I = LI.begin(), E = LI.end(); I != E; ++I) + Changed |= ProcessLoop(*I); return Changed; } @@ -136,9 +136,8 @@ bool LoopSimplify::ProcessLoop(Loop *L) { Changed = true; } - const std::vector<Loop*> &SubLoops = L->getSubLoops(); - for (unsigned i = 0, e = SubLoops.size(); i != e; ++i) - Changed |= ProcessLoop(SubLoops[i]); + for (Loop::iterator I = L->begin(), E = L->end(); I != E; ++I) + Changed |= ProcessLoop(*I); return Changed; } @@ -227,9 +226,8 @@ BasicBlock *LoopSimplify::SplitBlockPredecessors(BasicBlock *BB, static void ChangeExitBlock(Loop *L, BasicBlock *OldExit, BasicBlock *NewExit) { if (L->hasExitBlock(OldExit)) { L->changeExitBlock(OldExit, NewExit); - const std::vector<Loop*> &SubLoops = L->getSubLoops(); - for (unsigned i = 0, e = SubLoops.size(); i != e; ++i) - ChangeExitBlock(SubLoops[i], OldExit, NewExit); + for (Loop::iterator I = L->begin(), E = L->end(); I != E; ++I) + ChangeExitBlock(*I, OldExit, NewExit); } } @@ -266,16 +264,19 @@ void LoopSimplify::InsertPreheaderForLoop(Loop *L) { // is a sibling loop, ie, one with the same parent loop, or one if it's // children. // - const std::vector<Loop*> *ParentSubLoops; - if (Loop *Parent = L->getParentLoop()) - ParentSubLoops = &Parent->getSubLoops(); - else // Must check top-level loops... - ParentSubLoops = &getAnalysis<LoopInfo>().getTopLevelLoops(); + LoopInfo::iterator ParentLoops, ParentLoopsE; + if (Loop *Parent = L->getParentLoop()) { + ParentLoops = Parent->begin(); + ParentLoopsE = Parent->end(); + } else { // Must check top-level loops... + ParentLoops = getAnalysis<LoopInfo>().begin(); + ParentLoopsE = getAnalysis<LoopInfo>().end(); + } // Loop over all sibling loops, performing the substitution (recursively to // include child loops)... - for (unsigned i = 0, e = ParentSubLoops->size(); i != e; ++i) - ChangeExitBlock((*ParentSubLoops)[i], Header, NewBB); + for (; ParentLoops != ParentLoopsE; ++ParentLoops) + ChangeExitBlock(*ParentLoops, Header, NewBB); DominatorSet &DS = getAnalysis<DominatorSet>(); // Update dominator info { |