[llvm-commits] [llvm] r76780 - in /llvm/trunk: include/llvm/CodeGen/AsmPrinter.h lib/CodeGen/AsmPrinter/AsmPrinter.cpp

David Greene greened at obbligato.org
Wed Jul 22 13:33:26 PDT 2009


Author: greened
Date: Wed Jul 22 15:33:26 2009
New Revision: 76780

URL: http://llvm.org/viewvc/llvm-project?rev=76780&view=rev
Log:

Put comment printing under asm-verbose.

Modified:
    llvm/trunk/include/llvm/CodeGen/AsmPrinter.h
    llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp

Modified: llvm/trunk/include/llvm/CodeGen/AsmPrinter.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/AsmPrinter.h?rev=76780&r1=76779&r2=76780&view=diff

==============================================================================
--- llvm/trunk/include/llvm/CodeGen/AsmPrinter.h (original)
+++ llvm/trunk/include/llvm/CodeGen/AsmPrinter.h Wed Jul 22 15:33:26 2009
@@ -58,7 +58,7 @@
     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;

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp?rev=76780&r1=76779&r2=76780&view=diff

==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Wed Jul 22 15:33:26 2009
@@ -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 @@
 /// EmitComments - Pretty-print comments for instructions
 void AsmPrinter::EmitComments(const MachineInstr &MI) const
 {
-  if (!MI.getDebugLoc().isUnknown()) {
-    DebugLocTuple DLT = MF->getDebugLocTuple(MI.getDebugLoc());
+  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 " << DLT.Line << ":" << DLT.Col;
+      // 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());
+  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 " << DLT.Line << ":" << DLT.Col;
+      // 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;
+    }
   }
 }





More information about the llvm-commits mailing list