[llvm-commits] [llvm] r94225 - /llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
Chris Lattner
sabre at nondot.org
Fri Jan 22 13:43:28 PST 2010
Author: lattner
Date: Fri Jan 22 15:43:28 2010
New Revision: 94225
URL: http://llvm.org/viewvc/llvm-project?rev=94225&view=rev
Log:
make the loop comment printer print out a much better structured
output. An example:
.align 4, 0x90
LBB1_5: ## %while.cond3
## Parent Loop BB1_1 Depth=1
## => This Loop Header: Depth=2
## Child Loop BB1_8 Depth 3
## Child Loop BB1_6 Depth 3
Modified:
llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp?rev=94225&r1=94224&r2=94225&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Fri Jan 22 15:43:28 2010
@@ -1845,17 +1845,30 @@
}
}
+/// PrintParentLoopComment - Print comments about parent loops of this one.
+static void PrintParentLoopComment(raw_ostream &OS, const MachineLoop *Loop,
+ unsigned FunctionNumber) {
+ if (Loop == 0) return;
+
+ PrintParentLoopComment(OS, Loop->getParentLoop(), FunctionNumber);
+
+ OS.indent(Loop->getLoopDepth()*2)
+ << "Parent Loop BB" << FunctionNumber << "_"
+ << Loop->getHeader()->getNumber()
+ << " Depth=" << Loop->getLoopDepth() << '\n';
+}
+
+
/// PrintChildLoopComment - Print comments about child loops within
/// the loop for this basic block, with nesting.
static void PrintChildLoopComment(raw_ostream &OS, const MachineLoop *Loop,
unsigned FunctionNumber) {
// Add child loop information
for (MachineLoop::iterator CL = Loop->begin(), E = Loop->end();CL != E; ++CL){
- MachineBasicBlock *Header = (*CL)->getHeader();
- assert(Header && "No header for loop");
- OS.indent(((*CL)->getLoopDepth()-1)*2)
+ OS.indent((*CL)->getLoopDepth()*2)
<< "Child Loop BB" << FunctionNumber << "_"
- << Header->getNumber() << " Depth " << (*CL)->getLoopDepth() << '\n';
+ << (*CL)->getHeader()->getNumber() << " Depth " << (*CL)->getLoopDepth()
+ << '\n';
PrintChildLoopComment(OS, *CL, FunctionNumber);
}
}
@@ -1884,20 +1897,15 @@
// parent loops.
raw_ostream &OS = OutStreamer.GetCommentOS();
+ PrintParentLoopComment(OS, Loop->getParentLoop(), getFunctionNumber());
+
+ OS << "=>";
+ OS.indent(Loop->getLoopDepth()*2-2);
+
+ OS << "This ";
if (Loop->empty())
OS << "Inner ";
OS << "Loop Header: Depth=" + Twine(Loop->getLoopDepth()) << '\n';
PrintChildLoopComment(OS, Loop, getFunctionNumber());
-
- // Add parent loop information.
- for (const MachineLoop *CurLoop = Loop->getParentLoop(); CurLoop;
- CurLoop = CurLoop->getParentLoop()) {
- MachineBasicBlock *Header = CurLoop->getHeader();
- assert(Header && "No header for loop");
-
- OS.indent(CurLoop->getLoopDepth()*2)
- << "Inside Loop BB" << getFunctionNumber() << "_"
- << Header->getNumber() << " Depth " << CurLoop->getLoopDepth() << '\n';
- }
}
More information about the llvm-commits
mailing list