[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
Tue Nov 5 03:20:28 PST 2019


SouraVX created this revision.
SouraVX added reviewers: probinson, aprantl, jini.susan.george.
Herald added subscribers: llvm-commits, hiraditya.
Herald added a project: LLVM.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D69839

Files:
  llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
  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/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
===================================================================
--- llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
+++ llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
@@ -2757,6 +2757,11 @@
   if (CUMap.empty())
     return;
 
+  if (llvm::all_of(CUMap, [](const decltype(CUMap)::value_type &Pair) {
+        return Pair.second->getCUNode()->getMacros().empty();
+      }))
+    return;
+
   if (llvm::all_of(CUMap, [](const decltype(CUMap)::value_type &Pair) {
         return Pair.second->getCUNode()->isDebugDirectivesOnly();
       }))


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D69839.227840.patch
Type: text/x-patch
Size: 1903 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191105/438d371d/attachment.bin>


More information about the llvm-commits mailing list