[PATCH] D69839: [DebugInfo] Fix for stopping emission of debug_macinfo section in normal case and -fno-debug-macro switch enabled case.
Sourabh Singh Tomar via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 6 02:59:29 PST 2019
SouraVX updated this revision to Diff 228029.
SouraVX added a comment.
I've tried to streamline the code, based on review comments.
While working on this, I discovered one more caveat -- clang doesn't generate debug_macinfo.dwo section when "-fdebuf-macro -gsplit-dwarf" is specified.
But, This require another set of patches to dealt with separately.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D69839/new/
https://reviews.llvm.org/D69839
Files:
llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
llvm/test/DebugInfo/X86/debug-macro.ll
llvm/test/DebugInfo/X86/empty_macinfo.ll
llvm/test/DebugInfo/X86/length_symbol_difference.ll
Index: llvm/test/DebugInfo/X86/length_symbol_difference.ll
===================================================================
--- llvm/test/DebugInfo/X86/length_symbol_difference.ll
+++ llvm/test/DebugInfo/X86/length_symbol_difference.ll
@@ -1,11 +1,11 @@
-; RUN: llc -filetype=asm -O0 -mtriple=x86_64-linux-gnu < %s | FileCheck %s
+; RUN: llc -dwarf-version 4 -filetype=asm -O0 -mtriple=x86_64-linux-gnu < %s | FileCheck %s
; CHECK: .long .Ldebug_info_end0-.Ldebug_info_start0 # Length of Unit
; CHECK-NEXT: .Ldebug_info_start0:
; CHECK-NOT: .byte 0
; CHECK: .byte 0 # End Of Children Mark
; CHECK-NEXT: .Ldebug_info_end0:
-; CHECK-NEXT: .section
+; CHECK-NOT: .section .debug_macinfo
define dso_local void @_Z2f1v() !dbg !7 {
Index: llvm/test/DebugInfo/X86/empty_macinfo.ll
===================================================================
--- llvm/test/DebugInfo/X86/empty_macinfo.ll
+++ llvm/test/DebugInfo/X86/empty_macinfo.ll
@@ -2,9 +2,7 @@
; Test that we don't pollute the start of the file with debug sections
-; CHECK: .section .debug_macinfo,"", at progbits
-; CHECK-NEXT: .byte 0 # End Of Macro List Mark
-; CHECK-NEXT: .section
+; CHECK-NOT: .section .debug_macinfo,"", at progbits
; CHECK-NOT: .debug_macinfo
define void @f() !dbg !4 {
Index: llvm/test/DebugInfo/X86/debug-macro.ll
===================================================================
--- llvm/test/DebugInfo/X86/debug-macro.ll
+++ llvm/test/DebugInfo/X86/debug-macro.ll
@@ -9,7 +9,7 @@
; CHECK: DW_TAG_compile_unit
; CHECK-NOT: DW_TAG
; CHECK: DW_AT_name {{.*}}"debug-macro1.cpp")
-; CHECK: DW_AT_macro_info {{.*}}(0x00000044)
+; CHECK: DW_AT_macro_info {{.*}}(0x00000045)
; CHECK: DW_TAG_compile_unit
; CHECK-NOT: DW_TAG
; CHECK: DW_AT_name {{.*}}"debug-macro2.cpp")
@@ -24,8 +24,6 @@
; CHECK-NEXT: DW_MACINFO_end_file
; CHECK-NEXT: DW_MACINFO_undef - lineno: 10 macro: NameUndef2
; CHECK-NEXT: DW_MACINFO_end_file
-; CHECK-NEXT: DW_MACINFO_start_file - lineno: 0 filenum: 1
-; CHECK-NEXT: DW_MACINFO_end_file
; CHECK-LABEL: .debug_line contents:
; CHECK: file_names[ 1]:
Index: llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
===================================================================
--- llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
+++ llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
@@ -2732,30 +2732,25 @@
if (CUMap.empty())
return;
- if (llvm::all_of(CUMap, [](const decltype(CUMap)::value_type &Pair) {
- return Pair.second->getCUNode()->isDebugDirectivesOnly();
- }))
- return;
-
- // Start the dwarf macinfo section.
- Asm->OutStreamer->SwitchSection(
- Asm->getObjFileLowering().getDwarfMacinfoSection());
-
for (const auto &P : CUMap) {
auto &TheCU = *P.second;
if (TheCU.getCUNode()->isDebugDirectivesOnly())
continue;
+
auto *SkCU = TheCU.getSkeleton();
DwarfCompileUnit &U = SkCU ? *SkCU : TheCU;
auto *CUNode = cast<DICompileUnit>(P.first);
DIMacroNodeArray Macros = CUNode->getMacros();
- if (!Macros.empty()) {
- Asm->OutStreamer->EmitLabel(U.getMacroLabelBegin());
- handleMacroNodes(Macros, U);
- }
+ if (Macros.empty())
+ continue;
+ // Start the dwarf macinfo section.
+ Asm->OutStreamer->SwitchSection(
+ Asm->getObjFileLowering().getDwarfMacinfoSection());
+ Asm->OutStreamer->EmitLabel(U.getMacroLabelBegin());
+ handleMacroNodes(Macros, U);
+ Asm->OutStreamer->AddComment("End Of Macro List Mark");
+ Asm->emitInt8(0);
}
- Asm->OutStreamer->AddComment("End Of Macro List Mark");
- Asm->emitInt8(0);
}
// DWARF5 Experimental Separate Dwarf emitters.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D69839.228029.patch
Type: text/x-patch
Size: 3677 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191106/908454e9/attachment.bin>
More information about the llvm-commits
mailing list