1 //===- LoopInfo.cpp - Natural Loop Calculator -----------------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file defines the LoopInfo class that is used to identify natural loops
11 // and determine the loop depth of various nodes of the CFG. Note that the
12 // loops identified may actually be several natural loops that share the same
13 // header node... not just a single natural loop.
15 //===----------------------------------------------------------------------===//
17 #include "llvm/Analysis/LoopInfo.h"
18 #include "llvm/Constants.h"
19 #include "llvm/Instructions.h"
20 #include "llvm/Analysis/Dominators.h"
21 #include "llvm/Analysis/LoopIterator.h"
22 #include "llvm/Assembly/Writer.h"
23 #include "llvm/Support/CFG.h"
24 #include "llvm/Support/CommandLine.h"
25 #include "llvm/Support/Debug.h"
26 #include "llvm/ADT/DepthFirstIterator.h"
27 #include "llvm/ADT/SmallPtrSet.h"
31 // Always verify loopinfo if expensive checking is enabled.
33 static bool VerifyLoopInfo = true;
35 static bool VerifyLoopInfo = false;
37 static cl::opt<bool,true>
38 VerifyLoopInfoX("verify-loop-info", cl::location(VerifyLoopInfo),
39 cl::desc("Verify loop info (time consuming)"));
41 char LoopInfo::ID = 0;
42 INITIALIZE_PASS_BEGIN(LoopInfo, "loops", "Natural Loop Information", true, true)
43 INITIALIZE_PASS_DEPENDENCY(DominatorTree)
44 INITIALIZE_PASS_END(LoopInfo, "loops", "Natural Loop Information", true, true)
46 //===----------------------------------------------------------------------===//
47 // Loop implementation
50 /// isLoopInvariant - Return true if the specified value is loop invariant
52 bool Loop::isLoopInvariant(Value *V) const {
53 if (Instruction *I = dyn_cast<Instruction>(V))
55 return true; // All non-instructions are loop invariant
58 /// hasLoopInvariantOperands - Return true if all the operands of the
59 /// specified instruction are loop invariant.
60 bool Loop::hasLoopInvariantOperands(Instruction *I) const {
61 for (unsigned i = 0, e = I->getNumOperands(); i != e; ++i)
62 if (!isLoopInvariant(I->getOperand(i)))
68 /// makeLoopInvariant - If the given value is an instruciton inside of the
69 /// loop and it can be hoisted, do so to make it trivially loop-invariant.
70 /// Return true if the value after any hoisting is loop invariant. This
71 /// function can be used as a slightly more aggressive replacement for
74 /// If InsertPt is specified, it is the point to hoist instructions to.
75 /// If null, the terminator of the loop preheader is used.
77 bool Loop::makeLoopInvariant(Value *V, bool &Changed,
78 Instruction *InsertPt) const {
79 if (Instruction *I = dyn_cast<Instruction>(V))
80 return makeLoopInvariant(I, Changed, InsertPt);
81 return true; // All non-instructions are loop-invariant.
84 /// makeLoopInvariant - If the given instruction is inside of the
85 /// loop and it can be hoisted, do so to make it trivially loop-invariant.
86 /// Return true if the instruction after any hoisting is loop invariant. This
87 /// function can be used as a slightly more aggressive replacement for
90 /// If InsertPt is specified, it is the point to hoist instructions to.
91 /// If null, the terminator of the loop preheader is used.
93 bool Loop::makeLoopInvariant(Instruction *I, bool &Changed,
94 Instruction *InsertPt) const {
95 // Test if the value is already loop-invariant.
96 if (isLoopInvariant(I))
98 if (!I->isSafeToSpeculativelyExecute())
100 if (I->mayReadFromMemory())
102 // The landingpad instruction is immobile.
103 if (isa<LandingPadInst>(I))
105 // Determine the insertion point, unless one was given.
107 BasicBlock *Preheader = getLoopPreheader();
108 // Without a preheader, hoisting is not feasible.
111 InsertPt = Preheader->getTerminator();
113 // Don't hoist instructions with loop-variant operands.
114 for (unsigned i = 0, e = I->getNumOperands(); i != e; ++i)
115 if (!makeLoopInvariant(I->getOperand(i), Changed, InsertPt))
119 I->moveBefore(InsertPt);
124 /// getCanonicalInductionVariable - Check to see if the loop has a canonical
125 /// induction variable: an integer recurrence that starts at 0 and increments
126 /// by one each time through the loop. If so, return the phi node that
127 /// corresponds to it.
129 /// The IndVarSimplify pass transforms loops to have a canonical induction
132 PHINode *Loop::getCanonicalInductionVariable() const {
133 BasicBlock *H = getHeader();
135 BasicBlock *Incoming = 0, *Backedge = 0;
136 pred_iterator PI = pred_begin(H);
137 assert(PI != pred_end(H) &&
138 "Loop must have at least one backedge!");
140 if (PI == pred_end(H)) return 0; // dead loop
142 if (PI != pred_end(H)) return 0; // multiple backedges?
144 if (contains(Incoming)) {
145 if (contains(Backedge))
147 std::swap(Incoming, Backedge);
148 } else if (!contains(Backedge))
151 // Loop over all of the PHI nodes, looking for a canonical indvar.
152 for (BasicBlock::iterator I = H->begin(); isa<PHINode>(I); ++I) {
153 PHINode *PN = cast<PHINode>(I);
154 if (ConstantInt *CI =
155 dyn_cast<ConstantInt>(PN->getIncomingValueForBlock(Incoming)))
156 if (CI->isNullValue())
157 if (Instruction *Inc =
158 dyn_cast<Instruction>(PN->getIncomingValueForBlock(Backedge)))
159 if (Inc->getOpcode() == Instruction::Add &&
160 Inc->getOperand(0) == PN)
161 if (ConstantInt *CI = dyn_cast<ConstantInt>(Inc->getOperand(1)))
162 if (CI->equalsInt(1))
168 /// getTripCount - Return a loop-invariant LLVM value indicating the number of
169 /// times the loop will be executed. Note that this means that the backedge
170 /// of the loop executes N-1 times. If the trip-count cannot be determined,
171 /// this returns null.
173 /// The IndVarSimplify pass transforms loops to have a form that this
174 /// function easily understands.
176 Value *Loop::getTripCount() const {
177 // Canonical loops will end with a 'cmp ne I, V', where I is the incremented
178 // canonical induction variable and V is the trip count of the loop.
179 PHINode *IV = getCanonicalInductionVariable();
180 if (IV == 0 || IV->getNumIncomingValues() != 2) return 0;
182 bool P0InLoop = contains(IV->getIncomingBlock(0));
183 Value *Inc = IV->getIncomingValue(!P0InLoop);
184 BasicBlock *BackedgeBlock = IV->getIncomingBlock(!P0InLoop);
186 if (BranchInst *BI = dyn_cast<BranchInst>(BackedgeBlock->getTerminator()))
187 if (BI->isConditional()) {
188 if (ICmpInst *ICI = dyn_cast<ICmpInst>(BI->getCondition())) {
189 if (ICI->getOperand(0) == Inc) {
190 if (BI->getSuccessor(0) == getHeader()) {
191 if (ICI->getPredicate() == ICmpInst::ICMP_NE)
192 return ICI->getOperand(1);
193 } else if (ICI->getPredicate() == ICmpInst::ICMP_EQ) {
194 return ICI->getOperand(1);
203 /// getSmallConstantTripCount - Returns the trip count of this loop as a
204 /// normal unsigned value, if possible. Returns 0 if the trip count is unknown
205 /// or not constant. Will also return 0 if the trip count is very large
207 unsigned Loop::getSmallConstantTripCount() const {
208 Value* TripCount = this->getTripCount();
210 if (ConstantInt *TripCountC = dyn_cast<ConstantInt>(TripCount)) {
211 // Guard against huge trip counts.
212 if (TripCountC->getValue().getActiveBits() <= 32) {
213 return (unsigned)TripCountC->getZExtValue();
220 /// getSmallConstantTripMultiple - Returns the largest constant divisor of the
221 /// trip count of this loop as a normal unsigned value, if possible. This
222 /// means that the actual trip count is always a multiple of the returned
223 /// value (don't forget the trip count could very well be zero as well!).
225 /// Returns 1 if the trip count is unknown or not guaranteed to be the
226 /// multiple of a constant (which is also the case if the trip count is simply
227 /// constant, use getSmallConstantTripCount for that case), Will also return 1
228 /// if the trip count is very large (>= 2^32).
229 unsigned Loop::getSmallConstantTripMultiple() const {
230 Value* TripCount = this->getTripCount();
231 // This will hold the ConstantInt result, if any
232 ConstantInt *Result = NULL;
234 // See if the trip count is constant itself
235 Result = dyn_cast<ConstantInt>(TripCount);
236 // if not, see if it is a multiplication
238 if (BinaryOperator *BO = dyn_cast<BinaryOperator>(TripCount)) {
239 switch (BO->getOpcode()) {
240 case BinaryOperator::Mul:
241 Result = dyn_cast<ConstantInt>(BO->getOperand(1));
243 case BinaryOperator::Shl:
244 if (ConstantInt *CI = dyn_cast<ConstantInt>(BO->getOperand(1)))
245 if (CI->getValue().getActiveBits() <= 5)
246 return 1u << CI->getZExtValue();
253 // Guard against huge trip counts.
254 if (Result && Result->getValue().getActiveBits() <= 32) {
255 return (unsigned)Result->getZExtValue();
261 /// isLCSSAForm - Return true if the Loop is in LCSSA form
262 bool Loop::isLCSSAForm(DominatorTree &DT) const {
263 // Sort the blocks vector so that we can use binary search to do quick
265 SmallPtrSet<BasicBlock*, 16> LoopBBs(block_begin(), block_end());
267 for (block_iterator BI = block_begin(), E = block_end(); BI != E; ++BI) {
268 BasicBlock *BB = *BI;
269 for (BasicBlock::iterator I = BB->begin(), E = BB->end(); I != E;++I)
270 for (Value::use_iterator UI = I->use_begin(), E = I->use_end(); UI != E;
273 BasicBlock *UserBB = cast<Instruction>(U)->getParent();
274 if (PHINode *P = dyn_cast<PHINode>(U))
275 UserBB = P->getIncomingBlock(UI);
277 // Check the current block, as a fast-path, before checking whether
278 // the use is anywhere in the loop. Most values are used in the same
279 // block they are defined in. Also, blocks not reachable from the
280 // entry are special; uses in them don't need to go through PHIs.
282 !LoopBBs.count(UserBB) &&
283 DT.isReachableFromEntry(UserBB))
291 /// isLoopSimplifyForm - Return true if the Loop is in the form that
292 /// the LoopSimplify form transforms loops to, which is sometimes called
294 bool Loop::isLoopSimplifyForm() const {
295 // Normal-form loops have a preheader, a single backedge, and all of their
296 // exits have all their predecessors inside the loop.
297 return getLoopPreheader() && getLoopLatch() && hasDedicatedExits();
300 /// hasDedicatedExits - Return true if no exit block for the loop
301 /// has a predecessor that is outside the loop.
302 bool Loop::hasDedicatedExits() const {
303 // Sort the blocks vector so that we can use binary search to do quick
305 SmallPtrSet<BasicBlock *, 16> LoopBBs(block_begin(), block_end());
306 // Each predecessor of each exit block of a normal loop is contained
308 SmallVector<BasicBlock *, 4> ExitBlocks;
309 getExitBlocks(ExitBlocks);
310 for (unsigned i = 0, e = ExitBlocks.size(); i != e; ++i)
311 for (pred_iterator PI = pred_begin(ExitBlocks[i]),
312 PE = pred_end(ExitBlocks[i]); PI != PE; ++PI)
313 if (!LoopBBs.count(*PI))
315 // All the requirements are met.
319 /// getUniqueExitBlocks - Return all unique successor blocks of this loop.
320 /// These are the blocks _outside of the current loop_ which are branched to.
321 /// This assumes that loop exits are in canonical form.
324 Loop::getUniqueExitBlocks(SmallVectorImpl<BasicBlock *> &ExitBlocks) const {
325 assert(hasDedicatedExits() &&
326 "getUniqueExitBlocks assumes the loop has canonical form exits!");
328 // Sort the blocks vector so that we can use binary search to do quick
330 SmallVector<BasicBlock *, 128> LoopBBs(block_begin(), block_end());
331 std::sort(LoopBBs.begin(), LoopBBs.end());
333 SmallVector<BasicBlock *, 32> switchExitBlocks;
335 for (block_iterator BI = block_begin(), BE = block_end(); BI != BE; ++BI) {
337 BasicBlock *current = *BI;
338 switchExitBlocks.clear();
340 for (succ_iterator I = succ_begin(*BI), E = succ_end(*BI); I != E; ++I) {
341 // If block is inside the loop then it is not a exit block.
342 if (std::binary_search(LoopBBs.begin(), LoopBBs.end(), *I))
345 pred_iterator PI = pred_begin(*I);
346 BasicBlock *firstPred = *PI;
348 // If current basic block is this exit block's first predecessor
349 // then only insert exit block in to the output ExitBlocks vector.
350 // This ensures that same exit block is not inserted twice into
351 // ExitBlocks vector.
352 if (current != firstPred)
355 // If a terminator has more then two successors, for example SwitchInst,
356 // then it is possible that there are multiple edges from current block
357 // to one exit block.
358 if (std::distance(succ_begin(current), succ_end(current)) <= 2) {
359 ExitBlocks.push_back(*I);
363 // In case of multiple edges from current block to exit block, collect
364 // only one edge in ExitBlocks. Use switchExitBlocks to keep track of
366 if (std::find(switchExitBlocks.begin(), switchExitBlocks.end(), *I)
367 == switchExitBlocks.end()) {
368 switchExitBlocks.push_back(*I);
369 ExitBlocks.push_back(*I);
375 /// getUniqueExitBlock - If getUniqueExitBlocks would return exactly one
376 /// block, return that block. Otherwise return null.
377 BasicBlock *Loop::getUniqueExitBlock() const {
378 SmallVector<BasicBlock *, 8> UniqueExitBlocks;
379 getUniqueExitBlocks(UniqueExitBlocks);
380 if (UniqueExitBlocks.size() == 1)
381 return UniqueExitBlocks[0];
385 void Loop::dump() const {
389 //===----------------------------------------------------------------------===//
390 // UnloopUpdater implementation
394 /// Find the new parent loop for all blocks within the "unloop" whose last
395 /// backedges has just been removed.
396 class UnloopUpdater {
402 // Map unloop's immediate subloops to their nearest reachable parents. Nested
403 // loops within these subloops will not change parents. However, an immediate
404 // subloop's new parent will be the nearest loop reachable from either its own
405 // exits *or* any of its nested loop's exits.
406 DenseMap<Loop*, Loop*> SubloopParents;
408 // Flag the presence of an irreducible backedge whose destination is a block
409 // directly contained by the original unloop.
413 UnloopUpdater(Loop *UL, LoopInfo *LInfo) :
414 Unloop(UL), LI(LInfo), DFS(UL), FoundIB(false) {}
416 void updateBlockParents();
418 void removeBlocksFromAncestors();
420 void updateSubloopParents();
423 Loop *getNearestLoop(BasicBlock *BB, Loop *BBLoop);
425 } // end anonymous namespace
427 /// updateBlockParents - Update the parent loop for all blocks that are directly
428 /// contained within the original "unloop".
429 void UnloopUpdater::updateBlockParents() {
430 if (Unloop->getNumBlocks()) {
431 // Perform a post order CFG traversal of all blocks within this loop,
432 // propagating the nearest loop from sucessors to predecessors.
433 LoopBlocksTraversal Traversal(DFS, LI);
434 for (LoopBlocksTraversal::POTIterator POI = Traversal.begin(),
435 POE = Traversal.end(); POI != POE; ++POI) {
437 Loop *L = LI->getLoopFor(*POI);
438 Loop *NL = getNearestLoop(*POI, L);
441 // For reducible loops, NL is now an ancestor of Unloop.
442 assert((NL != Unloop && (!NL || NL->contains(Unloop))) &&
443 "uninitialized successor");
444 LI->changeLoopFor(*POI, NL);
447 // Or the current block is part of a subloop, in which case its parent
449 assert((FoundIB || Unloop->contains(L)) && "uninitialized successor");
453 // Each irreducible loop within the unloop induces a round of iteration using
454 // the DFS result cached by Traversal.
455 bool Changed = FoundIB;
456 for (unsigned NIters = 0; Changed; ++NIters) {
457 assert(NIters < Unloop->getNumBlocks() && "runaway iterative algorithm");
459 // Iterate over the postorder list of blocks, propagating the nearest loop
460 // from successors to predecessors as before.
462 for (LoopBlocksDFS::POIterator POI = DFS.beginPostorder(),
463 POE = DFS.endPostorder(); POI != POE; ++POI) {
465 Loop *L = LI->getLoopFor(*POI);
466 Loop *NL = getNearestLoop(*POI, L);
468 assert(NL != Unloop && (!NL || NL->contains(Unloop)) &&
469 "uninitialized successor");
470 LI->changeLoopFor(*POI, NL);
477 /// removeBlocksFromAncestors - Remove unloop's blocks from all ancestors below
478 /// their new parents.
479 void UnloopUpdater::removeBlocksFromAncestors() {
480 // Remove unloop's blocks from all ancestors below their new parents.
481 for (Loop::block_iterator BI = Unloop->block_begin(),
482 BE = Unloop->block_end(); BI != BE; ++BI) {
483 Loop *NewParent = LI->getLoopFor(*BI);
484 // If this block is an immediate subloop, remove all blocks (including
485 // nested subloops) from ancestors below the new parent loop.
486 // Otherwise, if this block is in a nested subloop, skip it.
487 if (SubloopParents.count(NewParent))
488 NewParent = SubloopParents[NewParent];
489 else if (Unloop->contains(NewParent))
492 // Remove blocks from former Ancestors except Unloop itself which will be
494 for (Loop *OldParent = Unloop->getParentLoop(); OldParent != NewParent;
495 OldParent = OldParent->getParentLoop()) {
496 assert(OldParent && "new loop is not an ancestor of the original");
497 OldParent->removeBlockFromLoop(*BI);
502 /// updateSubloopParents - Update the parent loop for all subloops directly
503 /// nested within unloop.
504 void UnloopUpdater::updateSubloopParents() {
505 while (!Unloop->empty()) {
506 Loop *Subloop = *llvm::prior(Unloop->end());
507 Unloop->removeChildLoop(llvm::prior(Unloop->end()));
509 assert(SubloopParents.count(Subloop) && "DFS failed to visit subloop");
510 if (SubloopParents[Subloop])
511 SubloopParents[Subloop]->addChildLoop(Subloop);
513 LI->addTopLevelLoop(Subloop);
517 /// getNearestLoop - Return the nearest parent loop among this block's
518 /// successors. If a successor is a subloop header, consider its parent to be
519 /// the nearest parent of the subloop's exits.
521 /// For subloop blocks, simply update SubloopParents and return NULL.
522 Loop *UnloopUpdater::getNearestLoop(BasicBlock *BB, Loop *BBLoop) {
524 // Initially for blocks directly contained by Unloop, NearLoop == Unloop and
525 // is considered uninitialized.
526 Loop *NearLoop = BBLoop;
529 if (NearLoop != Unloop && Unloop->contains(NearLoop)) {
531 // Find the subloop ancestor that is directly contained within Unloop.
532 while (Subloop->getParentLoop() != Unloop) {
533 Subloop = Subloop->getParentLoop();
534 assert(Subloop && "subloop is not an ancestor of the original loop");
536 // Get the current nearest parent of the Subloop exits, initially Unloop.
537 if (!SubloopParents.count(Subloop))
538 SubloopParents[Subloop] = Unloop;
539 NearLoop = SubloopParents[Subloop];
542 succ_iterator I = succ_begin(BB), E = succ_end(BB);
544 assert(!Subloop && "subloop blocks must have a successor");
545 NearLoop = 0; // unloop blocks may now exit the function.
547 for (; I != E; ++I) {
549 continue; // self loops are uninteresting
551 Loop *L = LI->getLoopFor(*I);
553 // This successor has not been processed. This path must lead to an
554 // irreducible backedge.
555 assert((FoundIB || !DFS.hasPostorder(*I)) && "should have seen IB");
558 if (L != Unloop && Unloop->contains(L)) {
559 // Successor is in a subloop.
561 continue; // Branching within subloops. Ignore it.
563 // BB branches from the original into a subloop header.
564 assert(L->getParentLoop() == Unloop && "cannot skip into nested loops");
566 // Get the current nearest parent of the Subloop's exits.
567 L = SubloopParents[L];
568 // L could be Unloop if the only exit was an irreducible backedge.
573 // Handle critical edges from Unloop into a sibling loop.
574 if (L && !L->contains(Unloop)) {
575 L = L->getParentLoop();
577 // Remember the nearest parent loop among successors or subloop exits.
578 if (NearLoop == Unloop || !NearLoop || NearLoop->contains(L))
582 SubloopParents[Subloop] = NearLoop;
588 //===----------------------------------------------------------------------===//
589 // LoopInfo implementation
591 bool LoopInfo::runOnFunction(Function &) {
593 LI.Calculate(getAnalysis<DominatorTree>().getBase()); // Update
597 /// updateUnloop - The last backedge has been removed from a loop--now the
598 /// "unloop". Find a new parent for the blocks contained within unloop and
599 /// update the loop tree. We don't necessarily have valid dominators at this
600 /// point, but LoopInfo is still valid except for the removal of this loop.
602 /// Note that Unloop may now be an empty loop. Calling Loop::getHeader without
603 /// checking first is illegal.
604 void LoopInfo::updateUnloop(Loop *Unloop) {
606 // First handle the special case of no parent loop to simplify the algorithm.
607 if (!Unloop->getParentLoop()) {
608 // Since BBLoop had no parent, Unloop blocks are no longer in a loop.
609 for (Loop::block_iterator I = Unloop->block_begin(),
610 E = Unloop->block_end(); I != E; ++I) {
612 // Don't reparent blocks in subloops.
613 if (getLoopFor(*I) != Unloop)
616 // Blocks no longer have a parent but are still referenced by Unloop until
617 // the Unloop object is deleted.
618 LI.changeLoopFor(*I, 0);
621 // Remove the loop from the top-level LoopInfo object.
622 for (LoopInfo::iterator I = LI.begin();; ++I) {
623 assert(I != LI.end() && "Couldn't find loop");
630 // Move all of the subloops to the top-level.
631 while (!Unloop->empty())
632 LI.addTopLevelLoop(Unloop->removeChildLoop(llvm::prior(Unloop->end())));
637 // Update the parent loop for all blocks within the loop. Blocks within
638 // subloops will not change parents.
639 UnloopUpdater Updater(Unloop, this);
640 Updater.updateBlockParents();
642 // Remove blocks from former ancestor loops.
643 Updater.removeBlocksFromAncestors();
645 // Add direct subloops as children in their new parent loop.
646 Updater.updateSubloopParents();
648 // Remove unloop from its parent loop.
649 Loop *ParentLoop = Unloop->getParentLoop();
650 for (Loop::iterator I = ParentLoop->begin();; ++I) {
651 assert(I != ParentLoop->end() && "Couldn't find loop");
653 ParentLoop->removeChildLoop(I);
659 void LoopInfo::verifyAnalysis() const {
660 // LoopInfo is a FunctionPass, but verifying every loop in the function
661 // each time verifyAnalysis is called is very expensive. The
662 // -verify-loop-info option can enable this. In order to perform some
663 // checking by default, LoopPass has been taught to call verifyLoop
664 // manually during loop pass sequences.
666 if (!VerifyLoopInfo) return;
668 DenseSet<const Loop*> Loops;
669 for (iterator I = begin(), E = end(); I != E; ++I) {
670 assert(!(*I)->getParentLoop() && "Top-level loop has a parent!");
671 (*I)->verifyLoopNest(&Loops);
674 // Verify that blocks are mapped to valid loops.
676 // FIXME: With an up-to-date DFS (see LoopIterator.h) and DominatorTree, we
677 // could also verify that the blocks are still in the correct loops.
678 for (DenseMap<BasicBlock*, Loop*>::const_iterator I = LI.BBMap.begin(),
679 E = LI.BBMap.end(); I != E; ++I) {
680 assert(Loops.count(I->second) && "orphaned loop");
681 assert(I->second->contains(I->first) && "orphaned block");
685 void LoopInfo::getAnalysisUsage(AnalysisUsage &AU) const {
686 AU.setPreservesAll();
687 AU.addRequired<DominatorTree>();
690 void LoopInfo::print(raw_ostream &OS, const Module*) const {
694 //===----------------------------------------------------------------------===//
695 // LoopBlocksDFS implementation
698 /// Traverse the loop blocks and store the DFS result.
699 /// Useful for clients that just want the final DFS result and don't need to
700 /// visit blocks during the initial traversal.
701 void LoopBlocksDFS::perform(LoopInfo *LI) {
702 LoopBlocksTraversal Traversal(*this, LI);
703 for (LoopBlocksTraversal::POTIterator POI = Traversal.begin(),
704 POE = Traversal.end(); POI != POE; ++POI) ;