Put comment printing under asm-verbose.
authorDavid Greene <greened@obbligato.org>
Wed, 22 Jul 2009 20:33:26 +0000 (20:33 +0000)
committerDavid Greene <greened@obbligato.org>
Wed, 22 Jul 2009 20:33:26 +0000 (20:33 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@76780 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/CodeGen/AsmPrinter.h
lib/CodeGen/AsmPrinter/AsmPrinter.cpp

index c3d4d60b3bb84edbc8b12ff5c3870c74ee4263fe..bb86dc9c0a29876cc7aedad68b2940c783ad3f97 100644 (file)
@@ -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;
index e31a39c7a39d13f3c552717b85383ce015e0b635..fe037058116628e24b2641c65b43a559a8b43f89 100644 (file)
@@ -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;
+    }
   }
 }