LoopInfoImpl.h revision c9b1e25493b393013b28e5d457f2fb2845a4dd9f
1//===- llvm/Analysis/LoopInfoImpl.h - Natural Loop Calculator ---*- C++ -*-===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// 9// 10// This is the generic implementation of LoopInfo used for both Loops and 11// MachineLoops. 12// 13//===----------------------------------------------------------------------===// 14 15#ifndef LLVM_ANALYSIS_LOOP_INFO_IMPL_H 16#define LLVM_ANALYSIS_LOOP_INFO_IMPL_H 17 18#include "llvm/Analysis/LoopInfo.h" 19#include "llvm/ADT/PostOrderIterator.h" 20 21namespace llvm { 22 23//===----------------------------------------------------------------------===// 24// APIs for simple analysis of the loop. See header notes. 25 26/// getExitingBlocks - Return all blocks inside the loop that have successors 27/// outside of the loop. These are the blocks _inside of the current loop_ 28/// which branch out. The returned list is always unique. 29/// 30template<class BlockT, class LoopT> 31void LoopBase<BlockT, LoopT>:: 32getExitingBlocks(SmallVectorImpl<BlockT *> &ExitingBlocks) const { 33 // Sort the blocks vector so that we can use binary search to do quick 34 // lookups. 35 SmallVector<BlockT*, 128> LoopBBs(block_begin(), block_end()); 36 std::sort(LoopBBs.begin(), LoopBBs.end()); 37 38 typedef GraphTraits<BlockT*> BlockTraits; 39 for (block_iterator BI = block_begin(), BE = block_end(); BI != BE; ++BI) 40 for (typename BlockTraits::ChildIteratorType I = 41 BlockTraits::child_begin(*BI), E = BlockTraits::child_end(*BI); 42 I != E; ++I) 43 if (!std::binary_search(LoopBBs.begin(), LoopBBs.end(), *I)) { 44 // Not in current loop? It must be an exit block. 45 ExitingBlocks.push_back(*BI); 46 break; 47 } 48} 49 50/// getExitingBlock - If getExitingBlocks would return exactly one block, 51/// return that block. Otherwise return null. 52template<class BlockT, class LoopT> 53BlockT *LoopBase<BlockT, LoopT>::getExitingBlock() const { 54 SmallVector<BlockT*, 8> ExitingBlocks; 55 getExitingBlocks(ExitingBlocks); 56 if (ExitingBlocks.size() == 1) 57 return ExitingBlocks[0]; 58 return 0; 59} 60 61/// getExitBlocks - Return all of the successor blocks of this loop. These 62/// are the blocks _outside of the current loop_ which are branched to. 63/// 64template<class BlockT, class LoopT> 65void LoopBase<BlockT, LoopT>:: 66getExitBlocks(SmallVectorImpl<BlockT*> &ExitBlocks) const { 67 // Sort the blocks vector so that we can use binary search to do quick 68 // lookups. 69 SmallVector<BlockT*, 128> LoopBBs(block_begin(), block_end()); 70 std::sort(LoopBBs.begin(), LoopBBs.end()); 71 72 typedef GraphTraits<BlockT*> BlockTraits; 73 for (block_iterator BI = block_begin(), BE = block_end(); BI != BE; ++BI) 74 for (typename BlockTraits::ChildIteratorType I = 75 BlockTraits::child_begin(*BI), E = BlockTraits::child_end(*BI); 76 I != E; ++I) 77 if (!std::binary_search(LoopBBs.begin(), LoopBBs.end(), *I)) 78 // Not in current loop? It must be an exit block. 79 ExitBlocks.push_back(*I); 80} 81 82/// getExitBlock - If getExitBlocks would return exactly one block, 83/// return that block. Otherwise return null. 84template<class BlockT, class LoopT> 85BlockT *LoopBase<BlockT, LoopT>::getExitBlock() const { 86 SmallVector<BlockT*, 8> ExitBlocks; 87 getExitBlocks(ExitBlocks); 88 if (ExitBlocks.size() == 1) 89 return ExitBlocks[0]; 90 return 0; 91} 92 93/// getExitEdges - Return all pairs of (_inside_block_,_outside_block_). 94template<class BlockT, class LoopT> 95void LoopBase<BlockT, LoopT>:: 96getExitEdges(SmallVectorImpl<Edge> &ExitEdges) const { 97 // Sort the blocks vector so that we can use binary search to do quick 98 // lookups. 99 SmallVector<BlockT*, 128> LoopBBs(block_begin(), block_end()); 100 array_pod_sort(LoopBBs.begin(), LoopBBs.end()); 101 102 typedef GraphTraits<BlockT*> BlockTraits; 103 for (block_iterator BI = block_begin(), BE = block_end(); BI != BE; ++BI) 104 for (typename BlockTraits::ChildIteratorType I = 105 BlockTraits::child_begin(*BI), E = BlockTraits::child_end(*BI); 106 I != E; ++I) 107 if (!std::binary_search(LoopBBs.begin(), LoopBBs.end(), *I)) 108 // Not in current loop? It must be an exit block. 109 ExitEdges.push_back(Edge(*BI, *I)); 110} 111 112/// getLoopPreheader - If there is a preheader for this loop, return it. A 113/// loop has a preheader if there is only one edge to the header of the loop 114/// from outside of the loop. If this is the case, the block branching to the 115/// header of the loop is the preheader node. 116/// 117/// This method returns null if there is no preheader for the loop. 118/// 119template<class BlockT, class LoopT> 120BlockT *LoopBase<BlockT, LoopT>::getLoopPreheader() const { 121 // Keep track of nodes outside the loop branching to the header... 122 BlockT *Out = getLoopPredecessor(); 123 if (!Out) return 0; 124 125 // Make sure there is only one exit out of the preheader. 126 typedef GraphTraits<BlockT*> BlockTraits; 127 typename BlockTraits::ChildIteratorType SI = BlockTraits::child_begin(Out); 128 ++SI; 129 if (SI != BlockTraits::child_end(Out)) 130 return 0; // Multiple exits from the block, must not be a preheader. 131 132 // The predecessor has exactly one successor, so it is a preheader. 133 return Out; 134} 135 136/// getLoopPredecessor - If the given loop's header has exactly one unique 137/// predecessor outside the loop, return it. Otherwise return null. 138/// This is less strict that the loop "preheader" concept, which requires 139/// the predecessor to have exactly one successor. 140/// 141template<class BlockT, class LoopT> 142BlockT *LoopBase<BlockT, LoopT>::getLoopPredecessor() const { 143 // Keep track of nodes outside the loop branching to the header... 144 BlockT *Out = 0; 145 146 // Loop over the predecessors of the header node... 147 BlockT *Header = getHeader(); 148 typedef GraphTraits<BlockT*> BlockTraits; 149 typedef GraphTraits<Inverse<BlockT*> > InvBlockTraits; 150 for (typename InvBlockTraits::ChildIteratorType PI = 151 InvBlockTraits::child_begin(Header), 152 PE = InvBlockTraits::child_end(Header); PI != PE; ++PI) { 153 typename InvBlockTraits::NodeType *N = *PI; 154 if (!contains(N)) { // If the block is not in the loop... 155 if (Out && Out != N) 156 return 0; // Multiple predecessors outside the loop 157 Out = N; 158 } 159 } 160 161 // Make sure there is only one exit out of the preheader. 162 assert(Out && "Header of loop has no predecessors from outside loop?"); 163 return Out; 164} 165 166/// getLoopLatch - If there is a single latch block for this loop, return it. 167/// A latch block is a block that contains a branch back to the header. 168template<class BlockT, class LoopT> 169BlockT *LoopBase<BlockT, LoopT>::getLoopLatch() const { 170 BlockT *Header = getHeader(); 171 typedef GraphTraits<Inverse<BlockT*> > InvBlockTraits; 172 typename InvBlockTraits::ChildIteratorType PI = 173 InvBlockTraits::child_begin(Header); 174 typename InvBlockTraits::ChildIteratorType PE = 175 InvBlockTraits::child_end(Header); 176 BlockT *Latch = 0; 177 for (; PI != PE; ++PI) { 178 typename InvBlockTraits::NodeType *N = *PI; 179 if (contains(N)) { 180 if (Latch) return 0; 181 Latch = N; 182 } 183 } 184 185 return Latch; 186} 187 188//===----------------------------------------------------------------------===// 189// APIs for updating loop information after changing the CFG 190// 191 192/// addBasicBlockToLoop - This method is used by other analyses to update loop 193/// information. NewBB is set to be a new member of the current loop. 194/// Because of this, it is added as a member of all parent loops, and is added 195/// to the specified LoopInfo object as being in the current basic block. It 196/// is not valid to replace the loop header with this method. 197/// 198template<class BlockT, class LoopT> 199void LoopBase<BlockT, LoopT>:: 200addBasicBlockToLoop(BlockT *NewBB, LoopInfoBase<BlockT, LoopT> &LIB) { 201 assert((Blocks.empty() || LIB[getHeader()] == this) && 202 "Incorrect LI specified for this loop!"); 203 assert(NewBB && "Cannot add a null basic block to the loop!"); 204 assert(LIB[NewBB] == 0 && "BasicBlock already in the loop!"); 205 206 LoopT *L = static_cast<LoopT *>(this); 207 208 // Add the loop mapping to the LoopInfo object... 209 LIB.BBMap[NewBB] = L; 210 211 // Add the basic block to this loop and all parent loops... 212 while (L) { 213 L->Blocks.push_back(NewBB); 214 L = L->getParentLoop(); 215 } 216} 217 218/// replaceChildLoopWith - This is used when splitting loops up. It replaces 219/// the OldChild entry in our children list with NewChild, and updates the 220/// parent pointer of OldChild to be null and the NewChild to be this loop. 221/// This updates the loop depth of the new child. 222template<class BlockT, class LoopT> 223void LoopBase<BlockT, LoopT>:: 224replaceChildLoopWith(LoopT *OldChild, LoopT *NewChild) { 225 assert(OldChild->ParentLoop == this && "This loop is already broken!"); 226 assert(NewChild->ParentLoop == 0 && "NewChild already has a parent!"); 227 typename std::vector<LoopT *>::iterator I = 228 std::find(SubLoops.begin(), SubLoops.end(), OldChild); 229 assert(I != SubLoops.end() && "OldChild not in loop!"); 230 *I = NewChild; 231 OldChild->ParentLoop = 0; 232 NewChild->ParentLoop = static_cast<LoopT *>(this); 233} 234 235/// verifyLoop - Verify loop structure 236template<class BlockT, class LoopT> 237void LoopBase<BlockT, LoopT>::verifyLoop() const { 238#ifndef NDEBUG 239 assert(!Blocks.empty() && "Loop header is missing"); 240 241 // Setup for using a depth-first iterator to visit every block in the loop. 242 SmallVector<BlockT*, 8> ExitBBs; 243 getExitBlocks(ExitBBs); 244 llvm::SmallPtrSet<BlockT*, 8> VisitSet; 245 VisitSet.insert(ExitBBs.begin(), ExitBBs.end()); 246 df_ext_iterator<BlockT*, llvm::SmallPtrSet<BlockT*, 8> > 247 BI = df_ext_begin(getHeader(), VisitSet), 248 BE = df_ext_end(getHeader(), VisitSet); 249 250 // Keep track of the number of BBs visited. 251 unsigned NumVisited = 0; 252 253 // Sort the blocks vector so that we can use binary search to do quick 254 // lookups. 255 SmallVector<BlockT*, 128> LoopBBs(block_begin(), block_end()); 256 std::sort(LoopBBs.begin(), LoopBBs.end()); 257 258 // Check the individual blocks. 259 for ( ; BI != BE; ++BI) { 260 BlockT *BB = *BI; 261 bool HasInsideLoopSuccs = false; 262 bool HasInsideLoopPreds = false; 263 SmallVector<BlockT *, 2> OutsideLoopPreds; 264 265 typedef GraphTraits<BlockT*> BlockTraits; 266 for (typename BlockTraits::ChildIteratorType SI = 267 BlockTraits::child_begin(BB), SE = BlockTraits::child_end(BB); 268 SI != SE; ++SI) 269 if (std::binary_search(LoopBBs.begin(), LoopBBs.end(), *SI)) { 270 HasInsideLoopSuccs = true; 271 break; 272 } 273 typedef GraphTraits<Inverse<BlockT*> > InvBlockTraits; 274 for (typename InvBlockTraits::ChildIteratorType PI = 275 InvBlockTraits::child_begin(BB), PE = InvBlockTraits::child_end(BB); 276 PI != PE; ++PI) { 277 BlockT *N = *PI; 278 if (std::binary_search(LoopBBs.begin(), LoopBBs.end(), N)) 279 HasInsideLoopPreds = true; 280 else 281 OutsideLoopPreds.push_back(N); 282 } 283 284 if (BB == getHeader()) { 285 assert(!OutsideLoopPreds.empty() && "Loop is unreachable!"); 286 } else if (!OutsideLoopPreds.empty()) { 287 // A non-header loop shouldn't be reachable from outside the loop, 288 // though it is permitted if the predecessor is not itself actually 289 // reachable. 290 BlockT *EntryBB = BB->getParent()->begin(); 291 for (df_iterator<BlockT *> NI = df_begin(EntryBB), 292 NE = df_end(EntryBB); NI != NE; ++NI) 293 for (unsigned i = 0, e = OutsideLoopPreds.size(); i != e; ++i) 294 assert(*NI != OutsideLoopPreds[i] && 295 "Loop has multiple entry points!"); 296 } 297 assert(HasInsideLoopPreds && "Loop block has no in-loop predecessors!"); 298 assert(HasInsideLoopSuccs && "Loop block has no in-loop successors!"); 299 assert(BB != getHeader()->getParent()->begin() && 300 "Loop contains function entry block!"); 301 302 NumVisited++; 303 } 304 305 assert(NumVisited == getNumBlocks() && "Unreachable block in loop"); 306 307 // Check the subloops. 308 for (iterator I = begin(), E = end(); I != E; ++I) 309 // Each block in each subloop should be contained within this loop. 310 for (block_iterator BI = (*I)->block_begin(), BE = (*I)->block_end(); 311 BI != BE; ++BI) { 312 assert(std::binary_search(LoopBBs.begin(), LoopBBs.end(), *BI) && 313 "Loop does not contain all the blocks of a subloop!"); 314 } 315 316 // Check the parent loop pointer. 317 if (ParentLoop) { 318 assert(std::find(ParentLoop->begin(), ParentLoop->end(), this) != 319 ParentLoop->end() && 320 "Loop is not a subloop of its parent!"); 321 } 322#endif 323} 324 325/// verifyLoop - Verify loop structure of this loop and all nested loops. 326template<class BlockT, class LoopT> 327void LoopBase<BlockT, LoopT>::verifyLoopNest( 328 DenseSet<const LoopT*> *Loops) const { 329 Loops->insert(static_cast<const LoopT *>(this)); 330 // Verify this loop. 331 verifyLoop(); 332 // Verify the subloops. 333 for (iterator I = begin(), E = end(); I != E; ++I) 334 (*I)->verifyLoopNest(Loops); 335} 336 337template<class BlockT, class LoopT> 338void LoopBase<BlockT, LoopT>::print(raw_ostream &OS, unsigned Depth) const { 339 OS.indent(Depth*2) << "Loop at depth " << getLoopDepth() 340 << " containing: "; 341 342 for (unsigned i = 0; i < getBlocks().size(); ++i) { 343 if (i) OS << ","; 344 BlockT *BB = getBlocks()[i]; 345 WriteAsOperand(OS, BB, false); 346 if (BB == getHeader()) OS << "<header>"; 347 if (BB == getLoopLatch()) OS << "<latch>"; 348 if (isLoopExiting(BB)) OS << "<exiting>"; 349 } 350 OS << "\n"; 351 352 for (iterator I = begin(), E = end(); I != E; ++I) 353 (*I)->print(OS, Depth+2); 354} 355 356//===----------------------------------------------------------------------===// 357/// Stable LoopInfo Analysis - Build a loop tree using stable iterators so the 358/// result does / not depend on use list (block predecessor) order. 359/// 360 361/// Discover a subloop with the specified backedges such that: All blocks within 362/// this loop are mapped to this loop or a subloop. And all subloops within this 363/// loop have their parent loop set to this loop or a subloop. 364template<class BlockT, class LoopT> 365static void discoverAndMapSubloop(LoopT *L, ArrayRef<BlockT*> Backedges, 366 LoopInfoBase<BlockT, LoopT> *LI, 367 DominatorTreeBase<BlockT> &DomTree) { 368 typedef GraphTraits<Inverse<BlockT*> > InvBlockTraits; 369 370 unsigned NumBlocks = 0; 371 unsigned NumSubloops = 0; 372 373 // Perform a backward CFG traversal using a worklist. 374 std::vector<BlockT *> ReverseCFGWorklist(Backedges.begin(), Backedges.end()); 375 while (!ReverseCFGWorklist.empty()) { 376 BlockT *PredBB = ReverseCFGWorklist.back(); 377 ReverseCFGWorklist.pop_back(); 378 379 LoopT *Subloop = LI->getLoopFor(PredBB); 380 if (!Subloop) { 381 if (!DomTree.isReachableFromEntry(PredBB)) 382 continue; 383 384 // This is an undiscovered block. Map it to the current loop. 385 LI->changeLoopFor(PredBB, L); 386 ++NumBlocks; 387 if (PredBB == L->getHeader()) 388 continue; 389 // Push all block predecessors on the worklist. 390 ReverseCFGWorklist.insert(ReverseCFGWorklist.end(), 391 InvBlockTraits::child_begin(PredBB), 392 InvBlockTraits::child_end(PredBB)); 393 } 394 else { 395 // This is a discovered block. Find its outermost discovered loop. 396 while (LoopT *Parent = Subloop->getParentLoop()) 397 Subloop = Parent; 398 399 // If it is already discovered to be a subloop of this loop, continue. 400 if (Subloop == L) 401 continue; 402 403 // Discover a subloop of this loop. 404 Subloop->setParentLoop(L); 405 ++NumSubloops; 406 NumBlocks += Subloop->getBlocks().capacity(); 407 PredBB = Subloop->getHeader(); 408 // Continue traversal along predecessors that are not loop-back edges from 409 // within this subloop tree itself. Note that a predecessor may directly 410 // reach another subloop that is not yet discovered to be a subloop of 411 // this loop, which we must traverse. 412 for (typename InvBlockTraits::ChildIteratorType PI = 413 InvBlockTraits::child_begin(PredBB), 414 PE = InvBlockTraits::child_end(PredBB); PI != PE; ++PI) { 415 if (LI->getLoopFor(*PI) != Subloop) 416 ReverseCFGWorklist.push_back(*PI); 417 } 418 } 419 } 420 L->getSubLoopsVector().reserve(NumSubloops); 421 L->getBlocksVector().reserve(NumBlocks); 422} 423 424namespace { 425/// Populate all loop data in a stable order during a single forward DFS. 426template<class BlockT, class LoopT> 427class PopulateLoopsDFS { 428 typedef GraphTraits<BlockT*> BlockTraits; 429 typedef typename BlockTraits::ChildIteratorType SuccIterTy; 430 431 LoopInfoBase<BlockT, LoopT> *LI; 432 DenseSet<const BlockT *> VisitedBlocks; 433 std::vector<std::pair<BlockT*, SuccIterTy> > DFSStack; 434 435public: 436 PopulateLoopsDFS(LoopInfoBase<BlockT, LoopT> *li): 437 LI(li) {} 438 439 void traverse(BlockT *EntryBlock); 440 441protected: 442 void insertIntoLoop(BlockT *Block); 443 444 BlockT *dfsSource() { return DFSStack.back().first; } 445 SuccIterTy &dfsSucc() { return DFSStack.back().second; } 446 SuccIterTy dfsSuccEnd() { return BlockTraits::child_end(dfsSource()); } 447 448 void pushBlock(BlockT *Block) { 449 DFSStack.push_back(std::make_pair(Block, BlockTraits::child_begin(Block))); 450 } 451}; 452} // anonymous 453 454/// Top-level driver for the forward DFS within the loop. 455template<class BlockT, class LoopT> 456void PopulateLoopsDFS<BlockT, LoopT>::traverse(BlockT *EntryBlock) { 457 pushBlock(EntryBlock); 458 VisitedBlocks.insert(EntryBlock); 459 while (!DFSStack.empty()) { 460 // Traverse the leftmost path as far as possible. 461 while (dfsSucc() != dfsSuccEnd()) { 462 BlockT *BB = *dfsSucc(); 463 ++dfsSucc(); 464 if (!VisitedBlocks.insert(BB).second) 465 continue; 466 467 // Push the next DFS successor onto the stack. 468 pushBlock(BB); 469 } 470 // Visit the top of the stack in postorder and backtrack. 471 insertIntoLoop(dfsSource()); 472 DFSStack.pop_back(); 473 } 474} 475 476/// Add a single Block to its ancestor loops in PostOrder. If the block is a 477/// subloop header, add the subloop to its parent in PostOrder, then reverse the 478/// Block and Subloop vectors of the now complete subloop to achieve RPO. 479template<class BlockT, class LoopT> 480void PopulateLoopsDFS<BlockT, LoopT>::insertIntoLoop(BlockT *Block) { 481 LoopT *Subloop = LI->getLoopFor(Block); 482 if (Subloop && Block == Subloop->getHeader()) { 483 // We reach this point once per subloop after processing all the blocks in 484 // the subloop. 485 if (Subloop->getParentLoop()) 486 Subloop->getParentLoop()->getSubLoopsVector().push_back(Subloop); 487 else 488 LI->addTopLevelLoop(Subloop); 489 490 // For convenience, Blocks and Subloops are inserted in postorder. Reverse 491 // the lists, except for the loop header, which is always at the beginning. 492 std::reverse(Subloop->getBlocksVector().begin()+1, 493 Subloop->getBlocksVector().end()); 494 std::reverse(Subloop->getSubLoopsVector().begin(), 495 Subloop->getSubLoopsVector().end()); 496 497 Subloop = Subloop->getParentLoop(); 498 } 499 for (; Subloop; Subloop = Subloop->getParentLoop()) 500 Subloop->getBlocksVector().push_back(Block); 501} 502 503/// Analyze LoopInfo discovers loops during a postorder DominatorTree traversal 504/// interleaved with backward CFG traversals within each subloop 505/// (discoverAndMapSubloop). The backward traversal skips inner subloops, so 506/// this part of the algorithm is linear in the number of CFG edges. Subloop and 507/// Block vectors are then populated during a single forward CFG traversal 508/// (PopulateLoopDFS). 509/// 510/// During the two CFG traversals each block is seen three times: 511/// 1) Discovered and mapped by a reverse CFG traversal. 512/// 2) Visited during a forward DFS CFG traversal. 513/// 3) Reverse-inserted in the loop in postorder following forward DFS. 514/// 515/// The Block vectors are inclusive, so step 3 requires loop-depth number of 516/// insertions per block. 517template<class BlockT, class LoopT> 518void LoopInfoBase<BlockT, LoopT>:: 519Analyze(DominatorTreeBase<BlockT> &DomTree) { 520 521 // Postorder traversal of the dominator tree. 522 DomTreeNodeBase<BlockT>* DomRoot = DomTree.getRootNode(); 523 for (po_iterator<DomTreeNodeBase<BlockT>*> DomIter = po_begin(DomRoot), 524 DomEnd = po_end(DomRoot); DomIter != DomEnd; ++DomIter) { 525 526 BlockT *Header = DomIter->getBlock(); 527 SmallVector<BlockT *, 4> Backedges; 528 529 // Check each predecessor of the potential loop header. 530 typedef GraphTraits<Inverse<BlockT*> > InvBlockTraits; 531 for (typename InvBlockTraits::ChildIteratorType PI = 532 InvBlockTraits::child_begin(Header), 533 PE = InvBlockTraits::child_end(Header); PI != PE; ++PI) { 534 535 BlockT *Backedge = *PI; 536 537 // If Header dominates predBB, this is a new loop. Collect the backedges. 538 if (DomTree.dominates(Header, Backedge) 539 && DomTree.isReachableFromEntry(Backedge)) { 540 Backedges.push_back(Backedge); 541 } 542 } 543 // Perform a backward CFG traversal to discover and map blocks in this loop. 544 if (!Backedges.empty()) { 545 LoopT *L = new LoopT(Header); 546 discoverAndMapSubloop(L, ArrayRef<BlockT*>(Backedges), this, DomTree); 547 } 548 } 549 // Perform a single forward CFG traversal to populate block and subloop 550 // vectors for all loops. 551 PopulateLoopsDFS<BlockT, LoopT> DFS(this); 552 DFS.traverse(DomRoot->getBlock()); 553} 554 555// Debugging 556template<class BlockT, class LoopT> 557void LoopInfoBase<BlockT, LoopT>::print(raw_ostream &OS) const { 558 for (unsigned i = 0; i < TopLevelLoops.size(); ++i) 559 TopLevelLoops[i]->print(OS); 560#if 0 561 for (DenseMap<BasicBlock*, LoopT*>::const_iterator I = BBMap.begin(), 562 E = BBMap.end(); I != E; ++I) 563 OS << "BB '" << I->first->getName() << "' level = " 564 << I->second->getLoopDepth() << "\n"; 565#endif 566} 567 568} // End llvm namespace 569 570#endif 571