diff options
author | David Greene <greened@obbligato.org> | 2009-07-22 20:33:26 +0000 |
---|---|---|
committer | David Greene <greened@obbligato.org> | 2009-07-22 20:33:26 +0000 |
commit | 67e59834fc1dca7e357c40af2e5144f3d62f5133 (patch) | |
tree | 83ccad029fb18c4441a83a3eb383dee6a63a633c | |
parent | 7384e1b39dddd3b8dc1814cf0c606aa86c64db6e (diff) |
Put comment printing under asm-verbose.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@76780 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/llvm/CodeGen/AsmPrinter.h | 2 | ||||
-rw-r--r-- | lib/CodeGen/AsmPrinter/AsmPrinter.cpp | 49 |
2 files changed, 37 insertions, 14 deletions
diff --git a/include/llvm/CodeGen/AsmPrinter.h b/include/llvm/CodeGen/AsmPrinter.h index c3d4d60b3b..bb86dc9c0a 100644 --- a/include/llvm/CodeGen/AsmPrinter.h +++ b/include/llvm/CodeGen/AsmPrinter.h @@ -58,7 +58,7 @@ namespace llvm { typedef DenseMap<GCStrategy*,GCMetadataPrinter*> gcp_map_type; typedef gcp_map_type::iterator gcp_iterator; gcp_map_type GCMetadataPrinters; - + protected: /// MMI - If available, this is a pointer to the current MachineModuleInfo. MachineModuleInfo *MMI; diff --git a/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/lib/CodeGen/AsmPrinter/AsmPrinter.cpp index e31a39c7a3..fe03705811 100644 --- a/lib/CodeGen/AsmPrinter/AsmPrinter.cpp +++ b/lib/CodeGen/AsmPrinter/AsmPrinter.cpp @@ -27,7 +27,6 @@ #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/FormattedStream.h" #include "llvm/Support/Mangler.h" -#include "llvm/Support/FormattedStream.h" #include "llvm/Target/TargetAsmInfo.h" #include "llvm/Target/TargetData.h" #include "llvm/Target/TargetLowering.h" @@ -1712,23 +1711,47 @@ GCMetadataPrinter *AsmPrinter::GetOrCreateGCPrinter(GCStrategy *S) { /// EmitComments - Pretty-print comments for instructions void AsmPrinter::EmitComments(const MachineInstr &MI) const { - if (!MI.getDebugLoc().isUnknown()) { - DebugLocTuple DLT = MF->getDebugLocTuple(MI.getDebugLoc()); - - // Print source line info - O.PadToColumn(TAI->getCommentColumn(), 1); - O << TAI->getCommentString() << " SrcLine " << DLT.Line << ":" << DLT.Col; + if (VerboseAsm) { + if (!MI.getDebugLoc().isUnknown()) { + DebugLocTuple DLT = MF->getDebugLocTuple(MI.getDebugLoc()); + + // Print source line info + O.PadToColumn(TAI->getCommentColumn(), 1); + O << TAI->getCommentString() << " SrcLine "; + if (DLT.CompileUnit->hasInitializer()) { + Constant *Name = DLT.CompileUnit->getInitializer(); + if (ConstantArray *NameString = dyn_cast<ConstantArray>(Name)) + if (NameString->isString()) { + O << NameString->getAsString() << " "; + } + } + O << DLT.Line; + if (DLT.Col != 0) + O << ":" << DLT.Col; + } } } /// EmitComments - Pretty-print comments for instructions void AsmPrinter::EmitComments(const MCInst &MI) const { - if (!MI.getDebugLoc().isUnknown()) { - DebugLocTuple DLT = MF->getDebugLocTuple(MI.getDebugLoc()); - - // Print source line info - O.PadToColumn(TAI->getCommentColumn(), 1); - O << TAI->getCommentString() << " SrcLine " << DLT.Line << ":" << DLT.Col; + if (VerboseAsm) { + if (!MI.getDebugLoc().isUnknown()) { + DebugLocTuple DLT = MF->getDebugLocTuple(MI.getDebugLoc()); + + // Print source line info + O.PadToColumn(TAI->getCommentColumn(), 1); + O << TAI->getCommentString() << " SrcLine "; + if (DLT.CompileUnit->hasInitializer()) { + Constant *Name = DLT.CompileUnit->getInitializer(); + if (ConstantArray *NameString = dyn_cast<ConstantArray>(Name)) + if (NameString->isString()) { + O << NameString->getAsString() << " "; + } + } + O << DLT.Line; + if (DLT.Col != 0) + O << ":" << DLT.Col; + } } } |