<div dir="ltr">What's the use-case/motivation? Should this be an IR feature (on a per-CU basis, so that LTO can correctly respect some CUs requesting this feature, and some disabling it)</div><br><div class="gmail_quote"><div dir="ltr">On Mon, Mar 12, 2018 at 8:06 AM Alexey Bataev via Phabricator via llvm-commits <<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">ABataev created this revision.<br>
ABataev added reviewers: probinson, echristo.<br>
Herald added subscribers: JDevlieghere, aprantl.<br>
<br>
Added a flag -no-dwarf-gnu-pub-sections, which allows to disable<br>
emission of gnu public sections.<br>
<br>
<br>
Repository:<br>
  rL LLVM<br>
<br>
<a href="https://reviews.llvm.org/D44385" rel="noreferrer" target="_blank">https://reviews.llvm.org/D44385</a><br>
<br>
Files:<br>
  lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp<br>
  lib/CodeGen/AsmPrinter/DwarfDebug.cpp<br>
  lib/CodeGen/AsmPrinter/DwarfDebug.h<br>
  test/DebugInfo/X86/no-gnu-public-sections.ll<br>
<br>
<br>
Index: test/DebugInfo/X86/no-gnu-public-sections.ll<br>
===================================================================<br>
--- /dev/null<br>
+++ test/DebugInfo/X86/no-gnu-public-sections.ll<br>
@@ -0,0 +1,31 @@<br>
+; RUN: llc -mtriple=x86_64-pc-linux-gnu -debugger-tune=gdb -filetype=asm < %s -no-dwarf-gnu-pub-sections | FileCheck %s --check-prefix=DISABLED<br>
+; RUN: llc -mtriple=x86_64-pc-linux-gnu -debugger-tune=gdb -filetype=asm < %s | FileCheck %s<br>
+<br>
+; DISABLED-NOT: {{.debug_gnu_pubnames|.debug_gnu_pubtypes}}<br>
+; CHECK-DAG: .section .debug_gnu_pubnames<br>
+; CHECK-DAG: .section .debug_gnu_pubtypes<br>
+<br>
+%struct.bar = type { %"struct.ns::foo" }<br>
+%"struct.ns::foo" = type { i8 }<br>
+<br>
+@b = global %struct.bar zeroinitializer, align 1, !dbg !0<br>
+<br>
+!<a href="http://llvm.dbg.cu" rel="noreferrer" target="_blank">llvm.dbg.cu</a> = !{!2}<br>
+!llvm.module.flags = !{!11, !12}<br>
+!llvm.ident = !{!13}<br>
+<br>
+!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())<br>
+!1 = distinct !DIGlobalVariable(name: "b", scope: !2, file: !3, line: 8, type: !6, isLocal: false, isDefinition: true)<br>
+!2 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !3, producer: "clang", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, globals: !5, gnuPubnames: true)<br>
+!3 = !DIFile(filename: "type.cpp", directory: "/tmp/dbginfo")<br>
+!4 = !{}<br>
+!5 = !{!0}<br>
+!6 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "bar", file: !3, line: 5, size: 8, elements: !7, identifier: "_ZTS3bar")<br>
+!7 = !{!8}<br>
+!8 = !DIDerivedType(tag: DW_TAG_member, name: "f", scope: !6, file: !3, line: 6, baseType: !9, size: 8)<br>
+!9 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "foo", scope: !10, file: !3, line: 2, size: 8, elements: !4, identifier: "_ZTSN2ns3fooE")<br>
+!10 = !DINamespace(name: "ns", scope: null)<br>
+!11 = !{i32 2, !"Dwarf Version", i32 4}<br>
+!12 = !{i32 2, !"Debug Info Version", i32 3}<br>
+!13 = !{!"clang"}<br>
+<br>
Index: lib/CodeGen/AsmPrinter/DwarfDebug.h<br>
===================================================================<br>
--- lib/CodeGen/AsmPrinter/DwarfDebug.h<br>
+++ lib/CodeGen/AsmPrinter/DwarfDebug.h<br>
@@ -258,6 +258,9 @@<br>
   /// Use inlined strings.<br>
   bool UseInlineStrings = false;<br>
<br>
+  /// Emit GNU pub sections.<br>
+  bool UseGnuPubSections = true;<br>
+<br>
   /// DWARF5 Experimental Options<br>
   /// @{<br>
   bool HasDwarfAccelTables;<br>
@@ -501,6 +504,9 @@<br>
   /// Returns whether to use inline strings.<br>
   bool useInlineStrings() const { return UseInlineStrings; }<br>
<br>
+  /// Returns whether GNU oub sections should be emitted.<br>
+  bool useGnuPubSections() const { return UseGnuPubSections; }<br>
+<br>
   // Experimental DWARF5 features.<br>
<br>
   /// Returns whether or not to emit tables that dwarf consumers can<br>
Index: lib/CodeGen/AsmPrinter/DwarfDebug.cpp<br>
===================================================================<br>
--- lib/CodeGen/AsmPrinter/DwarfDebug.cpp<br>
+++ lib/CodeGen/AsmPrinter/DwarfDebug.cpp<br>
@@ -123,6 +123,11 @@<br>
                             clEnumVal(Disable, "Disabled")),<br>
                  cl::init(Default));<br>
<br>
+static cl::opt<bool><br>
+    NoDwarfGnuPubSections("no-dwarf-gnu-pub-sections", cl::Hidden,<br>
+                          cl::desc("Disable emission of GNU pub sections."),<br>
+                          cl::init(false));<br>
+<br>
 enum LinkageNameOption {<br>
   DefaultLinkageNames,<br>
   AllLinkageNames,<br>
@@ -310,6 +315,8 @@<br>
   // Use dwarf 4 by default if nothing is requested.<br>
   DwarfVersion = DwarfVersion ? DwarfVersion : dwarf::DWARF_VERSION;<br>
<br>
+  UseGnuPubSections = !NoDwarfGnuPubSections;<br>
+<br>
   // Work around a GDB bug. GDB doesn't support the standard opcode;<br>
   // SCE doesn't support GNU's; LLDB prefers the standard opcode, which<br>
   // is defined as of DWARF 3.<br>
Index: lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp<br>
===================================================================<br>
--- lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp<br>
+++ lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp<br>
@@ -846,6 +846,9 @@<br>
 }<br>
<br>
 bool DwarfCompileUnit::hasDwarfPubSections() const {<br>
+  if (!DD->useGnuPubSections())<br>
+    return false;<br>
+<br>
   // Opting in to GNU Pubnames/types overrides the default to ensure these are<br>
   // generated for things like Gold's gdb_index generation.<br>
   if (CUNode->getGnuPubnames())<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br>
</blockquote></div>