summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2010-01-22 21:11:06 +0000
committerChris Lattner <sabre@nondot.org>2010-01-22 21:11:06 +0000
commit965df54254b9e73949fc5649b51c3ca1bed4b4a6 (patch)
tree85b42fd23075bb25b004308315548aeb5e4cb280
parentd8d0aee26a5a759085bfa9114302e507c8685599 (diff)
downloadllvm-965df54254b9e73949fc5649b51c3ca1bed4b4a6.tar.gz
llvm-965df54254b9e73949fc5649b51c3ca1bed4b4a6.tar.bz2
llvm-965df54254b9e73949fc5649b51c3ca1bed4b4a6.tar.xz
For blocks that are not loop headers, just print their loop depth and header BB.
For loop headers, print Inner loop along with the other stuff so it doesn't take an extra line. We now get stuff like this: LBB1_4: ## %land.end ## in Loop: Header=BB1_1 Depth=1 notb %al testb $1, %al jne LBB1_8 and: LBB1_6: ## %while.cond7 ## Inner Loop Header: Depth=3 ## Inside Loop BB1_5 Depth 2 ## Inside Loop BB1_1 Depth 1 which still isn't great for loop headers, but is much less verbose. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94221 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/CodeGen/AsmPrinter/AsmPrinter.cpp29
1 files changed, 16 insertions, 13 deletions
diff --git a/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
index 0b8633bf59..e0186d145f 100644
--- a/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
+++ b/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
@@ -1847,9 +1847,8 @@ void AsmPrinter::EmitComments(const MachineInstr &MI) const {
/// PrintChildLoopComment - Print comments about child loops within
/// the loop for this basic block, with nesting.
-static void PrintChildLoopComment(MCStreamer &O, const MachineLoop *Loop,
+static void PrintChildLoopComment(raw_ostream &OS, const MachineLoop *Loop,
unsigned FunctionNumber) {
- raw_ostream &OS = O.GetCommentOS();
// Add child loop information
for (MachineLoop::iterator CL = Loop->begin(), E = Loop->end();CL != E; ++CL){
MachineBasicBlock *Header = (*CL)->getHeader();
@@ -1857,7 +1856,7 @@ static void PrintChildLoopComment(MCStreamer &O, const MachineLoop *Loop,
OS.indent(((*CL)->getLoopDepth()-1)*2)
<< "Child Loop BB" << FunctionNumber << "_"
<< Header->getNumber() << " Depth " << (*CL)->getLoopDepth() << '\n';
- PrintChildLoopComment(O, *CL, FunctionNumber);
+ PrintChildLoopComment(OS, *CL, FunctionNumber);
}
}
@@ -1869,23 +1868,27 @@ void AsmPrinter::EmitComments(const MachineBasicBlock &MBB) const {
const MachineLoop *Loop = LI->getLoopFor(&MBB);
if (Loop == 0) return;
- OutStreamer.AddComment("Loop Depth " + Twine(Loop->getLoopDepth()));
-
MachineBasicBlock *Header = Loop->getHeader();
assert(Header && "No header for loop");
-
+
+ // If this block is not a loop header, just print out what is the loop header
+ // and return.
if (Header != &MBB) {
- OutStreamer.AddComment("Loop Header is BB" + Twine(getFunctionNumber()) +
- "_" + Twine(Loop->getHeader()->getNumber()));
- } else {
- OutStreamer.AddComment("Loop Header");
- PrintChildLoopComment(OutStreamer, Loop, getFunctionNumber());
+ OutStreamer.AddComment(" in Loop: Header=BB" + Twine(getFunctionNumber())+
+ "_" + Twine(Loop->getHeader()->getNumber())+
+ " Depth="+Twine(Loop->getLoopDepth()));
+ return;
}
+ // Otherwise, it is a loop header. Print out information about child and
+ // parent loops.
+ raw_ostream &OS = OutStreamer.GetCommentOS();
+
if (Loop->empty())
- OutStreamer.AddComment("Inner Loop");
+ OS << "Inner ";
+ OS << "Loop Header: Depth=" + Twine(Loop->getLoopDepth()) << '\n';
- raw_ostream &OS = OutStreamer.GetCommentOS();
+ PrintChildLoopComment(OS, Loop, getFunctionNumber());
// Add parent loop information.
for (const MachineLoop *CurLoop = Loop->getParentLoop(); CurLoop;