Index: llvm/include/llvm/Analysis/LoopInfo.h =================================================================== --- llvm/include/llvm/Analysis/LoopInfo.h +++ llvm/include/llvm/Analysis/LoopInfo.h @@ -331,6 +331,9 @@ void print(raw_ostream &OS, unsigned Depth = 0) const; + /// Print loop with all the BBs inside it. + void printVerbose(raw_ostream &OS, unsigned Depth = 0) const; + protected: friend class LoopInfoBase; explicit LoopBase(BlockT *BB) : ParentLoop(nullptr) { @@ -451,6 +454,7 @@ BasicBlock *getUniqueExitBlock() const; void dump() const; + void dumpVerbose() const; /// Return the debug location of the start of this loop. /// This looks for a BB terminating instruction with a known debug Index: llvm/include/llvm/Analysis/LoopInfoImpl.h =================================================================== --- llvm/include/llvm/Analysis/LoopInfoImpl.h +++ llvm/include/llvm/Analysis/LoopInfoImpl.h @@ -335,6 +335,27 @@ (*I)->print(OS, Depth+2); } +template +void LoopBase::printVerbose(raw_ostream &OS, + unsigned Depth) const { + OS.indent(Depth*2) << "Loop at depth " << getLoopDepth() + << " containing: "; + + BlockT *H = getHeader(); + BlockT *L = getLoopLatch(); + for (unsigned i = 0; i < getBlocks().size(); ++i) { + BlockT *BB = getBlocks()[i]; + if (BB == H) OS << "
\n"; + if (BB == L) OS << "\n"; + if (isLoopExiting(BB)) OS << "\n"; + BB->print(OS); + } + OS << "\n"; + + for (iterator I = begin(), E = end(); I != E; ++I) + (*I)->print(OS, Depth+2); +} + //===----------------------------------------------------------------------===// /// Stable LoopInfo Analysis - Build a loop tree using stable iterators so the /// result does / not depend on use list (block predecessor) order. Index: llvm/lib/Analysis/LoopInfo.cpp =================================================================== --- llvm/lib/Analysis/LoopInfo.cpp +++ llvm/lib/Analysis/LoopInfo.cpp @@ -387,6 +387,10 @@ LLVM_DUMP_METHOD void Loop::dump() const { print(dbgs()); } + +LLVM_DUMP_METHOD void Loop::dumpVerbose() const { + printVerbose(dbgs()); +} #endif //===----------------------------------------------------------------------===//