[llvm] 5c24517 - DebugInfo: Use debug_line.dwo for debug_macro.dwo

David Blaikie via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 22 14:06:59 PDT 2020


Author: David Blaikie
Date: 2020-07-22T14:06:33-07:00
New Revision: 5c2451785dfe6d8a4448690cd1f1c247036bfca6

URL: https://github.com/llvm/llvm-project/commit/5c2451785dfe6d8a4448690cd1f1c247036bfca6
DIFF: https://github.com/llvm/llvm-project/commit/5c2451785dfe6d8a4448690cd1f1c247036bfca6.diff

LOG: DebugInfo: Use debug_line.dwo for debug_macro.dwo

This is an alternative proposal to D81476 (and D82084) - the details were sufficiently confusing to me it seemed easier to write some code and see how it looks.

Reviewers: SouraVX

Differential Revision: https://reviews.llvm.org/D84278

Added: 
    

Modified: 
    llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
    llvm/test/DebugInfo/X86/debug-macro-dwo.ll

Removed: 
    


################################################################################
diff  --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
index 8475081189a1..40a94ea4ecdc 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
@@ -3000,7 +3000,10 @@ static void emitMacroHeader(AsmPrinter *Asm, const DwarfDebug &DD,
   Asm->OutStreamer->AddComment("Flags: 32 bit, debug_line_offset present");
   Asm->emitInt8(Flags);
   Asm->OutStreamer->AddComment("debug_line_offset");
-  Asm->OutStreamer->emitSymbolValue(CU.getLineTableStartSym(), /*Size=*/4);
+  if (DD.useSplitDwarf())
+    Asm->OutStreamer->emitIntValue(0, /*Size=*/4);
+  else
+    Asm->OutStreamer->emitSymbolValue(CU.getLineTableStartSym(), /*Size=*/4);
 }
 
 void DwarfDebug::handleMacroNodes(DIMacroNodeArray Nodes, DwarfCompileUnit &U) {
@@ -3056,16 +3059,22 @@ void DwarfDebug::emitMacro(DIMacro &M) {
 }
 
 void DwarfDebug::emitMacroFileImpl(
-    DIMacroFile &F, DwarfCompileUnit &U, unsigned StartFile, unsigned EndFile,
+    DIMacroFile &MF, DwarfCompileUnit &U, unsigned StartFile, unsigned EndFile,
     StringRef (*MacroFormToString)(unsigned Form)) {
 
   Asm->OutStreamer->AddComment(MacroFormToString(StartFile));
   Asm->emitULEB128(StartFile);
   Asm->OutStreamer->AddComment("Line Number");
-  Asm->emitULEB128(F.getLine());
+  Asm->emitULEB128(MF.getLine());
   Asm->OutStreamer->AddComment("File Number");
-  Asm->emitULEB128(U.getOrCreateSourceID(F.getFile()));
-  handleMacroNodes(F.getElements(), U);
+  DIFile &F = *MF.getFile();
+  if (useSplitDwarf())
+    Asm->emitULEB128(getDwoLineTable(U)->getFile(
+        F.getDirectory(), F.getFilename(), getMD5AsBytes(&F),
+        Asm->OutContext.getDwarfVersion(), F.getSource()));
+  else
+    Asm->emitULEB128(U.getOrCreateSourceID(&F));
+  handleMacroNodes(MF.getElements(), U);
   Asm->OutStreamer->AddComment(MacroFormToString(EndFile));
   Asm->emitULEB128(EndFile);
 }

diff  --git a/llvm/test/DebugInfo/X86/debug-macro-dwo.ll b/llvm/test/DebugInfo/X86/debug-macro-dwo.ll
index 95727a82ef29..23e889f5efce 100644
--- a/llvm/test/DebugInfo/X86/debug-macro-dwo.ll
+++ b/llvm/test/DebugInfo/X86/debug-macro-dwo.ll
@@ -2,26 +2,34 @@
 ; -gdwarf-5 -gsplit-dwarf -fdebug-macro is specified.
 
 ; RUN: %llc_dwarf -dwarf-version=5 -O0 -filetype=obj \
-; RUN: -split-dwarf-file=foo.dwo < %s | llvm-dwarfdump -v - | FileCheck %s
+; RUN: -split-dwarf-file=foo.dwo < %s | llvm-dwarfdump -debug-macro -debug-info -debug-line -v - | FileCheck %s
 
 ; CHECK-LABEL:  .debug_info contents:
 ; CHECK: DW_AT_macros [DW_FORM_sec_offset] (0x00000000)
 
 ; CHECK-LABEL:  .debug_macro.dwo contents:
 ; CHECK-NEXT: 0x00000000:
-; CHECK-NEXT: macro header: version = 0x0005, flags = 0x02, format = DWARF32
+; CHECK-NEXT: macro header: version = 0x0005, flags = 0x02, format = DWARF32, debug_line_offset = 0x00000000
 ; CHECK-NEXT: DW_MACRO_start_file - lineno: 0 filenum: 0
-; FIXME: This should be filenum 1 (and 2 below) if this was using debug_loc.dwo
-;        (rather than currently incorrectly using debug_loc)
-; CHECK-NEXT:   DW_MACRO_start_file - lineno: 1 filenum: 2
+; CHECK-NEXT:   DW_MACRO_start_file - lineno: 1 filenum: 1
 ; CHECK-NEXT:     DW_MACRO_define_strx - lineno: 1 macro: FOO 5
 ; CHECK-NEXT:   DW_MACRO_end_file
-; CHECK-NEXT:   DW_MACRO_start_file - lineno: 2 filenum: 3
+; CHECK-NEXT:   DW_MACRO_start_file - lineno: 2 filenum: 2
 ; CHECK-NEXT:     DW_MACRO_undef_strx - lineno: 14 macro: YEA
 ; CHECK-NEXT:   DW_MACRO_end_file
 ; CHECK-NEXT:   DW_MACRO_undef_strx - lineno: 14 macro: YEA
 ; CHECK-NEXT: DW_MACRO_end_file
 
+; CHECK-LABEL: .debug_line.dwo contents:
+; CHECK: file_names[  0]:
+; CHECK:            name: "test.c"
+; CHECK: file_names[  1]:
+; CHECK:            name: "foo.h"
+; CHECK: file_names[  2]:
+; CHECK:            name: "bar.h"
+
+
+
 ; ModuleID = 'test.c'
 source_filename = "test.c"
 target datalayout = "e-m:e-p200:32:32-p201:32:32-p202:64:64-i64:64-f80:128-n8:16:32:64-S128"


        


More information about the llvm-commits mailing list