Move DebugInfo checks into EmitComments and remove them from
authorDavid Greene <greened@obbligato.org>
Fri, 13 Nov 2009 21:34:57 +0000 (21:34 +0000)
committerDavid Greene <greened@obbligato.org>
Fri, 13 Nov 2009 21:34:57 +0000 (21:34 +0000)
target-specific AsmPrinters.  Not all comments need DebugInfo.

Re-enable the line numbers comment test.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@88697 91177308-0d34-0410-b5e6-96231b3b80d8

14 files changed:
lib/CodeGen/AsmPrinter/AsmPrinter.cpp
lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp
lib/Target/Alpha/AsmPrinter/AlphaAsmPrinter.cpp
lib/Target/Blackfin/AsmPrinter/BlackfinAsmPrinter.cpp
lib/Target/CellSPU/AsmPrinter/SPUAsmPrinter.cpp
lib/Target/MSP430/AsmPrinter/MSP430AsmPrinter.cpp
lib/Target/Mips/AsmPrinter/MipsAsmPrinter.cpp
lib/Target/PIC16/AsmPrinter/PIC16AsmPrinter.cpp
lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp
lib/Target/Sparc/AsmPrinter/SparcAsmPrinter.cpp
lib/Target/SystemZ/AsmPrinter/SystemZAsmPrinter.cpp
lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp
lib/Target/XCore/AsmPrinter/XCoreAsmPrinter.cpp
test/FrontendC++/2009-07-15-LineNumbers.cpp

index dbe60de89cd5f73bc5538aeba13fd531b0cb7d09..9bac86001348276e327e828bfc917a329e3f1861 100644 (file)
@@ -18,6 +18,7 @@
 #include "llvm/Module.h"
 #include "llvm/CodeGen/GCMetadataPrinter.h"
 #include "llvm/CodeGen/MachineConstantPool.h"
+#include "llvm/CodeGen/MachineFrameInfo.h"
 #include "llvm/CodeGen/MachineFunction.h"
 #include "llvm/CodeGen/MachineJumpTableInfo.h"
 #include "llvm/CodeGen/MachineLoopInfo.h"
@@ -35,6 +36,7 @@
 #include "llvm/Support/Mangler.h"
 #include "llvm/MC/MCAsmInfo.h"
 #include "llvm/Target/TargetData.h"
+#include "llvm/Target/TargetInstrInfo.h"
 #include "llvm/Target/TargetLowering.h"
 #include "llvm/Target/TargetLoweringObjectFile.h"
 #include "llvm/Target/TargetOptions.h"
@@ -1822,21 +1824,28 @@ GCMetadataPrinter *AsmPrinter::GetOrCreateGCPrinter(GCStrategy *S) {
 
 /// EmitComments - Pretty-print comments for instructions
 void AsmPrinter::EmitComments(const MachineInstr &MI) const {
-  assert(VerboseAsm && !MI.getDebugLoc().isUnknown());
-  
-  DebugLocTuple DLT = MF->getDebugLocTuple(MI.getDebugLoc());
+  if (!VerboseAsm)
+    return;
 
-  // Print source line info.
-  O.PadToColumn(MAI->getCommentColumn());
-  O << MAI->getCommentString() << " SrcLine ";
-  if (DLT.Scope) {
-    DICompileUnit CU(DLT.Scope);
-    if (!CU.isNull())
-      O << CU.getFilename() << " ";
+  bool Newline = false;
+
+  if (!MI.getDebugLoc().isUnknown()) {
+    DebugLocTuple DLT = MF->getDebugLocTuple(MI.getDebugLoc());
+
+    // Print source line info.
+    O.PadToColumn(MAI->getCommentColumn());
+    O << MAI->getCommentString() << " SrcLine ";
+    if (DLT.Scope) {
+      DICompileUnit CU(DLT.Scope);
+      if (!CU.isNull())
+        O << CU.getFilename() << " ";
+    }
+    O << DLT.Line;
+    if (DLT.Col != 0)
+      O << ":" << DLT.Col;
+    Newline = true;
   }
-  O << DLT.Line;
-  if (DLT.Col != 0) 
-    O << ":" << DLT.Col;
+
 }
 
 /// PrintChildLoopComment - Print comments about child loops within
@@ -1867,8 +1876,7 @@ static void PrintChildLoopComment(formatted_raw_ostream &O,
 }
 
 /// EmitComments - Pretty-print comments for basic blocks
-void AsmPrinter::EmitComments(const MachineBasicBlock &MBB) const
-{
+void AsmPrinter::EmitComments(const MachineBasicBlock &MBB) const {
   if (VerboseAsm) {
     // Add loop depth information
     const MachineLoop *loop = LI->getLoopFor(&MBB);
index 485e3e34d47d43a9e2772b895724fbe39fd371b9..fae44db1331d9c9681d2d5659bcf8ccf0ebb13e4 100644 (file)
@@ -1086,7 +1086,7 @@ void ARMAsmPrinter::printMachineInstruction(const MachineInstr *MI) {
     printInstruction(MI);
   }
   
-  if (VerboseAsm && !MI->getDebugLoc().isUnknown())
+  if (VerboseAsm)
     EmitComments(*MI);
   O << '\n';
   processDebugLoc(MI, false);
index 209a5bf416673cf19e13a62585c5dd6ecd8dd5f1..338057b453158bec4aa49cf8e8433726b4ae3be9 100644 (file)
@@ -178,7 +178,7 @@ bool AlphaAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
       processDebugLoc(II, true);
       printInstruction(II);
       
-      if (VerboseAsm && !II->getDebugLoc().isUnknown())
+      if (VerboseAsm)
         EmitComments(*II);
       O << '\n';
       processDebugLoc(II, false);
index 913f95bb7887f41f6fcd4ea4aff252f02be0d60c..917f7f54fb1e5065d09f1a8bd74166acaeb03f76 100644 (file)
@@ -143,7 +143,7 @@ bool BlackfinAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
       processDebugLoc(II, true);
 
       printInstruction(II);
-      if (VerboseAsm && !II->getDebugLoc().isUnknown())
+      if (VerboseAsm)
         EmitComments(*II);
       O << '\n';
       
index 007fe8f7d4d1a21c1fae37de03f4dfec67118575..dc9f81c488a14c0edba4817afd9299635c5fb407 100644 (file)
@@ -406,7 +406,7 @@ void SPUAsmPrinter::printMachineInstruction(const MachineInstr *MI) {
   ++EmittedInsts;
   processDebugLoc(MI, true);
   printInstruction(MI);
-  if (VerboseAsm && !MI->getDebugLoc().isUnknown())
+  if (VerboseAsm)
     EmitComments(*MI);
   processDebugLoc(MI, false);
   O << '\n';
index 22d80d4fba221f46430a759cbf9cefc833811ee0..145359f056fa9823dcc6c766a6f748a23cad1231 100644 (file)
@@ -239,7 +239,7 @@ void MSP430AsmPrinter::printMachineInstruction(const MachineInstr *MI) {
 
   printInstructionThroughMCStreamer(MI);
 
-  if (VerboseAsm && !MI->getDebugLoc().isUnknown())
+  if (VerboseAsm)
     EmitComments(*MI);
   O << '\n';
 
index 66ade89bda44ec5a1df43c5fb82ac16bb755439a..4898faee20e8353f7eb113b1ba8242231e290f25 100644 (file)
@@ -282,7 +282,7 @@ bool MipsAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
       // Print the assembly for the instruction.
       printInstruction(II);
       
-      if (VerboseAsm && !II->getDebugLoc().isUnknown())
+      if (VerboseAsm)
         EmitComments(*II);
       O << '\n';
 
index b2a4c1124ee945272ed208973a816d548535dc41..e1f2587658ee28e55dd3adeef6816c74828c90a8 100644 (file)
@@ -46,7 +46,7 @@ PIC16AsmPrinter::PIC16AsmPrinter(formatted_raw_ostream &O, TargetMachine &TM,
 bool PIC16AsmPrinter::printMachineInstruction(const MachineInstr *MI) {
   processDebugLoc(MI, true);
   printInstruction(MI);
-  if (VerboseAsm && !MI->getDebugLoc().isUnknown())
+  if (VerboseAsm)
     EmitComments(*MI);
   O << '\n';
   processDebugLoc(MI, false);
index d769ba5792e38161fbffb078866c6aa26840e99c..aae4607f43dd23bbde325bbbb0e258baf3d4aaa7 100644 (file)
@@ -594,7 +594,7 @@ void PPCAsmPrinter::printMachineInstruction(const MachineInstr *MI) {
 
   printInstruction(MI);
   
-  if (VerboseAsm && !MI->getDebugLoc().isUnknown())
+  if (VerboseAsm)
     EmitComments(*MI);
   O << '\n';
 
index 452b46fe69d96f566e1f37e95b21e070d3c9a483..cd85dd467f4c88b3c539092f22d0553036a24536 100644 (file)
@@ -126,7 +126,7 @@ bool SparcAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
       processDebugLoc(II, true);
       printInstruction(II);
       
-      if (VerboseAsm && !II->getDebugLoc().isUnknown())
+      if (VerboseAsm)
         EmitComments(*II);
       O << '\n';
       processDebugLoc(II, false);
index 16bac40b9273f48be7aa1fb50b86e49703748262..e97e7ca9632efe99a662e1c148675e542cc21780 100644 (file)
@@ -155,7 +155,7 @@ void SystemZAsmPrinter::printMachineInstruction(const MachineInstr *MI) {
   // Call the autogenerated instruction printer routines.
   printInstruction(MI);
   
-  if (VerboseAsm && !MI->getDebugLoc().isUnknown())
+  if (VerboseAsm)
     EmitComments(*MI);
   O << '\n';
 
index ae8e6d3db4622b599500cfbc8b5711d7a2376d5d..b88063f9ce72c1ecb41db5608136846e6d31306d 100644 (file)
@@ -651,7 +651,7 @@ void X86AsmPrinter::printMachineInstruction(const MachineInstr *MI) {
   
   printInstructionThroughMCStreamer(MI);
   
-  if (VerboseAsm && !MI->getDebugLoc().isUnknown())
+  if (VerboseAsm)
     EmitComments(*MI);
   O << '\n';
 
index bc1bbc38d3d7c8182ffef0fcd48fb0ed99f951dd..d7106a028332158f48a7e9cf7d0ba70d177aa945 100644 (file)
@@ -361,7 +361,7 @@ void XCoreAsmPrinter::printMachineInstruction(const MachineInstr *MI) {
     return;
   }
   printInstruction(MI);
-  if (VerboseAsm && !MI->getDebugLoc().isUnknown())
+  if (VerboseAsm)
     EmitComments(*MI);
   O << '\n';
 
index 54624a36666e91f32f381e9f10d7dbb6eb98fc0d..21e096c447b7e807b820eee1d222f8e6157d5023 100644 (file)
@@ -2,7 +2,6 @@
 // print line numbers in asm.
 // RUN: %llvmgcc -S -O0 -g %s -o - | llvm-as | \
 // RUN:    llc --disable-fp-elim -O0 -relocation-model=pic | grep {# SrcLine 25}
-// XFAIL: *
 
 #include <stdlib.h>