summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Pop <sebpop@gmail.com>2016-07-27 05:02:17 +0000
committerSebastian Pop <sebpop@gmail.com>2016-07-27 05:02:17 +0000
commit906c5ef31ef67f74d0a1df7b3e150c2c80a7d182 (patch)
tree21cede88a8993163d57d68ad38024649920087dc
parentfde7c9daa63ee8033b7a2fb5e5da794254a0be8b (diff)
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
-rw-r--r--include/llvm/Analysis/LoopInfo.h6
-rw-r--r--include/llvm/Analysis/LoopInfoImpl.h19
-rw-r--r--lib/Analysis/LoopInfo.cpp4
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<const LoopT*> *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<BlockT, LoopT>;
@@ -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<BlockT, LoopT>::verifyLoopNest(
}
template<class BlockT, class LoopT>
-void LoopBase<BlockT, LoopT>::print(raw_ostream &OS, unsigned Depth) const {
+void LoopBase<BlockT, LoopT>::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 << "<header>";
- if (BB == getLoopLatch()) OS << "<latch>";
- if (isLoopExiting(BB)) OS << "<exiting>";
+ if (!Verbose) {
+ if (i) OS << ",";
+ BB->printAsOperand(OS, false);
+ } else OS << "\n";
+
+ if (BB == H) OS << "<header>";
+ if (isLoopLatch(BB)) OS << "<latch>";
+ if (isLoopExiting(BB)) OS << "<exiting>";
+ 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
//===----------------------------------------------------------------------===//