Put code that generates debug labels into TableGen so that it can be used by
authorBill Wendling <isanbard@gmail.com>
Wed, 18 Feb 2009 23:12:06 +0000 (23:12 +0000)
committerBill Wendling <isanbard@gmail.com>
Wed, 18 Feb 2009 23:12:06 +0000 (23:12 +0000)
everyone.

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

include/llvm/CodeGen/AsmPrinter.h
lib/Target/Alpha/AsmPrinter/AlphaAsmPrinter.cpp
lib/Target/IA64/IA64AsmPrinter.cpp
lib/Target/Mips/MipsAsmPrinter.cpp
lib/Target/PIC16/PIC16AsmPrinter.cpp
lib/Target/Sparc/AsmPrinter/SparcAsmPrinter.cpp
lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp
lib/Target/X86/AsmPrinter/X86IntelAsmPrinter.cpp
utils/TableGen/AsmWriterEmitter.cpp

index d63b06d954e271ab8baf3494573ba6d3ccda33fd..9c528f10fcaf36b592c4f5ea8b6b87d6a6968dd8 100644 (file)
@@ -51,17 +51,17 @@ namespace llvm {
     ///
     unsigned FunctionNumber;
 
-    /// DW -This is needed because printDeclare() has to insert
-    /// DbgVariable entries into the dwarf table. This is a short term hack
-    /// that ought be fixed soon.
-    DwarfWriter *DW;
-    
     // GCMetadataPrinters - The garbage collection metadata printer table.
     typedef DenseMap<GCStrategy*,GCMetadataPrinter*> gcp_map_type;
     typedef gcp_map_type::iterator gcp_iterator;
     gcp_map_type GCMetadataPrinters;
     
   protected:
+    /// DW -This is needed because printDeclare() has to insert
+    /// DbgVariable entries into the dwarf table. This is a short term hack
+    /// that ought be fixed soon.
+    DwarfWriter *DW;
+    
     // Necessary for external weak linkage support
     std::set<const GlobalValue*> ExtWeakSymbols;
 
index b2b8fcdf3833bc48a86cf4b87ba653ad262dca2d..fdfee1bc1508e8b4cd16891b12c8db0334c3fe50 100644 (file)
@@ -20,6 +20,7 @@
 #include "llvm/Type.h"
 #include "llvm/Assembly/Writer.h"
 #include "llvm/CodeGen/AsmPrinter.h"
+#include "llvm/CodeGen/DwarfWriter.h"
 #include "llvm/Target/TargetAsmInfo.h"
 #include "llvm/Target/TargetMachine.h"
 #include "llvm/Support/Compiler.h"
index cda0c06308ffe34403587941e9366817fd2af100..567e04c4b150a6bc9a3aebb6aa08d46905d6b04f 100644 (file)
@@ -22,6 +22,7 @@
 #include "llvm/Module.h"
 #include "llvm/Type.h"
 #include "llvm/CodeGen/AsmPrinter.h"
+#include "llvm/CodeGen/DwarfWriter.h"
 #include "llvm/CodeGen/MachineFunctionPass.h"
 #include "llvm/Target/TargetAsmInfo.h"
 #include "llvm/Target/TargetMachine.h"
index f6d8dda16a006a7b080cdbbd6e14fa667d7ad109..94cd71a760919e96ed29d03dc8262d81b3404a1b 100644 (file)
@@ -23,6 +23,7 @@
 #include "llvm/DerivedTypes.h"
 #include "llvm/Module.h"
 #include "llvm/CodeGen/AsmPrinter.h"
+#include "llvm/CodeGen/DwarfWriter.h"
 #include "llvm/CodeGen/MachineFunctionPass.h"
 #include "llvm/CodeGen/MachineConstantPool.h"
 #include "llvm/CodeGen/MachineFrameInfo.h"
index 1f3c4345646a4558949a7586d651d49f9275a547..8e80eeabe2d706a043387bd70b5dc0cc9470050c 100644 (file)
 
 #include "PIC16AsmPrinter.h"
 #include "PIC16TargetAsmInfo.h"
-#include "llvm/Support/raw_ostream.h"
-#include "llvm/Support/Mangler.h"
+#include "llvm/DerivedTypes.h"
 #include "llvm/Function.h"
 #include "llvm/Module.h"
+#include "llvm/CodeGen/DwarfWriter.h"
 #include "llvm/CodeGen/MachineFrameInfo.h"
-#include "llvm/DerivedTypes.h"
+#include "llvm/Support/raw_ostream.h"
+#include "llvm/Support/Mangler.h"
 
 using namespace llvm;
 
index a7f4ea2dda75c6cd8dcd53f3768f8bfbf5974aeb..f720d47570eda8f46ba407496bc648e4c839ffac 100644 (file)
@@ -19,6 +19,7 @@
 #include "llvm/DerivedTypes.h"
 #include "llvm/Module.h"
 #include "llvm/CodeGen/AsmPrinter.h"
+#include "llvm/CodeGen/DwarfWriter.h"
 #include "llvm/CodeGen/MachineFunctionPass.h"
 #include "llvm/CodeGen/MachineConstantPool.h"
 #include "llvm/CodeGen/MachineInstr.h"
index 9af3ba62db042df6bf37043ed70e4a684d018abc..12cfda16dcc79223603eea4987432bdae5af4096 100644 (file)
@@ -26,6 +26,7 @@
 #include "llvm/Type.h"
 #include "llvm/ADT/Statistic.h"
 #include "llvm/ADT/StringExtras.h"
+#include "llvm/CodeGen/DwarfWriter.h"
 #include "llvm/CodeGen/MachineJumpTableInfo.h"
 #include "llvm/Support/Mangler.h"
 #include "llvm/Support/raw_ostream.h"
@@ -725,23 +726,6 @@ bool X86ATTAsmPrinter::PrintAsmMemoryOperand(const MachineInstr *MI,
 void X86ATTAsmPrinter::printMachineInstruction(const MachineInstr *MI) {
   ++EmittedInsts;
 
-  if (TAI->doesSupportDebugInformation()) {
-    const Function *F = MF->getFunction();
-
-    // FIXME: Support more than '-Os'.
-    if (F->hasFnAttr(Attribute::OptimizeForSize)) {
-      static DebugLoc PrevDL = DebugLoc::getUnknownLoc();
-      DebugLoc CurDL = MI->getDebugLoc();
-
-      if (!CurDL.isUnknown() && PrevDL != CurDL) {
-        DebugLocTuple DLT = MF->getDebugLocTuple(CurDL);
-        printLabel(DW->RecordSourceLine(DLT.Line, DLT.Col, DLT.Src));
-      }
-
-      PrevDL = CurDL;
-    }
-  }
-
   // Call the autogenerated instruction printer routines.
   printInstruction(MI);
 }
index a75422a56d5c928076ce35954a400120a27674d5..4dedd026aa13fbc331cfbf6449eb18f5c3a23e9a 100644 (file)
@@ -25,6 +25,7 @@
 #include "llvm/ADT/Statistic.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/Assembly/Writer.h"
+#include "llvm/CodeGen/DwarfWriter.h"
 #include "llvm/Support/Mangler.h"
 #include "llvm/Target/TargetAsmInfo.h"
 #include "llvm/Target/TargetOptions.h"
index 93d67e843bbd5aeed7d1902254743223a12c12b3..3b66b94525c6226ac4a534c1ca5929a8e3695e96 100644 (file)
@@ -640,6 +640,17 @@ void AsmWriterEmitter::run(std::ostream &O) {
   }
   O << "\";\n\n";
 
+  O << "  {\n"
+    << "    const MachineFunction *MF = MI->getParent()->getParent();\n"
+    << "    static DebugLoc PrevDL = DebugLoc::getUnknownLoc();\n"
+    << "    DebugLoc CurDL = MI->getDebugLoc();\n\n"
+    << "    if (!CurDL.isUnknown() && PrevDL != CurDL) {\n"
+    << "      DebugLocTuple DLT = MF->getDebugLocTuple(CurDL);\n"
+    << "      printLabel(DW->RecordSourceLine(DLT.Line, DLT.Col, DLT.Src));\n"
+    << "    }\n\n"
+    << "    PrevDL = CurDL;\n"
+    << "  }\n";
+
   O << "  if (MI->getOpcode() == TargetInstrInfo::INLINEASM) {\n"
     << "    O << \"\\t\";\n"
     << "    printInlineAsm(MI);\n"