Record debug location information in the Dwarf writer.
authorBill Wendling <isanbard@gmail.com>
Fri, 6 Feb 2009 21:45:08 +0000 (21:45 +0000)
committerBill Wendling <isanbard@gmail.com>
Fri, 6 Feb 2009 21:45:08 +0000 (21:45 +0000)
A simple test program shows that debugging works. :-)

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

lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp
lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.h

index 9e0afc8d6f235c806ff6ab2acd8bec5ad7d9c43a..847355c50d7267e3ad4838a1075570b34b99d566 100644 (file)
@@ -207,6 +207,7 @@ void X86ATTAsmPrinter::emitFunctionHeader(const MachineFunction &MF) {
 ///
 bool X86ATTAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
   const Function *F = MF.getFunction();
+  this->MF = &MF;
   unsigned CC = F->getCallingConv();
 
   SetupMachineFunction(MF);
@@ -718,12 +719,24 @@ bool X86ATTAsmPrinter::PrintAsmMemoryOperand(const MachineInstr *MI,
   return false;
 }
 
-/// printMachineInstruction -- Print out a single X86 LLVM instruction
-/// MI in AT&T syntax to the current output stream.
+/// printMachineInstruction -- Print out a single X86 LLVM instruction MI in
+/// AT&T syntax to the current output stream.
 ///
 void X86ATTAsmPrinter::printMachineInstruction(const MachineInstr *MI) {
   ++EmittedInsts;
 
+  if (TAI->doesSupportDebugInformation()) {
+    static DebugLoc PrevDL = DebugLoc::getUnknownLoc();
+    DebugLoc CurDL = MI->getDebugLoc();
+
+    if (!CurDL.isInvalid() && !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 3732ce86a864f7703a5a44c5d3564f06f45af3bc..6be9958dcf19365b08c341db1b731c8e5d9371ea 100644 (file)
@@ -29,6 +29,7 @@ namespace llvm {
 struct MachineJumpTableInfo;
 
 struct VISIBILITY_HIDDEN X86ATTAsmPrinter : public AsmPrinter {
+  MachineFunction *MF;
   DwarfWriter *DW;
   MachineModuleInfo *MMI;
   const X86Subtarget *Subtarget;