From 906c5ef31ef67f74d0a1df7b3e150c2c80a7d182 Mon Sep 17 00:00:00 2001 From: Sebastian Pop Date: Wed, 27 Jul 2016 05:02:17 +0000 Subject: [PATCH] add a verbose mode to Loop->print() to print all the basic blocks of a loop Differential Revision: https://reviews.llvm.org/D22817 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@276838 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Analysis/LoopInfo.h | 6 +++++- include/llvm/Analysis/LoopInfoImpl.h | 19 +++++++++++++------ lib/Analysis/LoopInfo.cpp | 4 ++++ 3 files changed, 22 insertions(+), 7 deletions(-) diff --git a/include/llvm/Analysis/LoopInfo.h b/include/llvm/Analysis/LoopInfo.h index 088853080c8..88f7685df04 100644 --- a/include/llvm/Analysis/LoopInfo.h +++ b/include/llvm/Analysis/LoopInfo.h @@ -342,7 +342,10 @@ public: /// Verify loop structure of this loop and all nested loops. void verifyLoopNest(DenseSet *Loops) const; - void print(raw_ostream &OS, unsigned Depth = 0) const; + void print(raw_ostream &OS, unsigned Depth = 0, bool Verbose = false) const; + + /// Print loop with all the BBs inside it. + void printVerbose(raw_ostream &OS, unsigned Depth = 0) const; protected: friend class LoopInfoBase; @@ -464,6 +467,7 @@ public: 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 diff --git a/include/llvm/Analysis/LoopInfoImpl.h b/include/llvm/Analysis/LoopInfoImpl.h index 79593f4f3d2..dbe2ca53523 100644 --- a/include/llvm/Analysis/LoopInfoImpl.h +++ b/include/llvm/Analysis/LoopInfoImpl.h @@ -309,17 +309,24 @@ void LoopBase::verifyLoopNest( } template -void LoopBase::print(raw_ostream &OS, unsigned Depth) const { +void LoopBase::print(raw_ostream &OS, unsigned Depth, + bool Verbose) const { OS.indent(Depth*2) << "Loop at depth " << getLoopDepth() << " containing: "; + BlockT *H = getHeader(); for (unsigned i = 0; i < getBlocks().size(); ++i) { - if (i) OS << ","; BlockT *BB = getBlocks()[i]; - BB->printAsOperand(OS, false); - if (BB == getHeader()) OS << "
"; - if (BB == getLoopLatch()) OS << ""; - if (isLoopExiting(BB)) OS << ""; + if (!Verbose) { + if (i) OS << ","; + BB->printAsOperand(OS, false); + } else OS << "\n"; + + if (BB == H) OS << "
"; + if (isLoopLatch(BB)) OS << ""; + if (isLoopExiting(BB)) OS << ""; + if (Verbose) + BB->print(OS); } OS << "\n"; diff --git a/lib/Analysis/LoopInfo.cpp b/lib/Analysis/LoopInfo.cpp index 16325f6e78a..cbd5edec917 100644 --- a/lib/Analysis/LoopInfo.cpp +++ b/lib/Analysis/LoopInfo.cpp @@ -387,6 +387,10 @@ BasicBlock *Loop::getUniqueExitBlock() const { LLVM_DUMP_METHOD void Loop::dump() const { print(dbgs()); } + +LLVM_DUMP_METHOD void Loop::dumpVerbose() const { + print(dbgs(), /*Depth=*/ 0, /*Verbose=*/ true); +} #endif //===----------------------------------------------------------------------===// -- 2.11.0