[llvm] fc4f1ef - [DebugInfo][AsmPrinter] Don't emit accelerator entries with empty names

Felipe de Azevedo Piovezan via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 27 05:41:17 PDT 2023


Author: Felipe de Azevedo Piovezan
Date: 2023-06-27T08:41:06-04:00
New Revision: fc4f1efb6a05c8a475457260dd3b2143f5e19f68

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

LOG: [DebugInfo][AsmPrinter] Don't emit accelerator entries with empty names

The DWARF 5 specification says that:

> All other debugging information entries without a DW_AT_name attribute are
> excluded.

Clang started generating these variables for string literals, see D123534.

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

Added: 
    llvm/test/DebugInfo/Generic/debug-names-nameless-var.ll

Modified: 
    llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
index 1dee83cf3703f..c9cbae2ec71cd 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
@@ -3536,7 +3536,7 @@ template <typename DataT>
 void DwarfDebug::addAccelNameImpl(const DICompileUnit &CU,
                                   AccelTable<DataT> &AppleAccel, StringRef Name,
                                   const DIE &Die) {
-  if (getAccelTableKind() == AccelTableKind::None)
+  if (getAccelTableKind() == AccelTableKind::None || Name.empty())
     return;
 
   if (getAccelTableKind() != AccelTableKind::Apple &&

diff  --git a/llvm/test/DebugInfo/Generic/debug-names-nameless-var.ll b/llvm/test/DebugInfo/Generic/debug-names-nameless-var.ll
new file mode 100644
index 0000000000000..74cfec69d005e
--- /dev/null
+++ b/llvm/test/DebugInfo/Generic/debug-names-nameless-var.ll
@@ -0,0 +1,22 @@
+; RUN: %llc_dwarf -debugger-tune=lldb -accel-tables=Dwarf -filetype=obj -o %t %s
+; RUN: llvm-dwarfdump -debug-names %t | FileCheck %s
+; RUN: llvm-dwarfdump -debug-names -verify %t | FileCheck --check-prefix=VERIFY %s
+
+ at nameless_var = constant i8 0, !dbg !0
+
+; CHECK: Name count: 0
+; VERIFY: No errors
+
+!llvm.dbg.cu = !{!10}
+!llvm.module.flags = !{!14, !15}
+!llvm.ident = !{!20}
+
+!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
+!1 = distinct !DIGlobalVariable(scope: null, file: !11, line: 1, type: !5, isLocal: true, isDefinition: true)
+!5 = !DIBasicType(size: 8, encoding: DW_ATE_signed_char)
+!10 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !11, producer: "blah", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, globals: !12, splitDebugInlining: false, nameTableKind: Apple, sysroot: "/")
+!11 = !DIFile(filename: "blah", directory: "blah")
+!12 = !{!0}
+!14 = !{i32 7, !"Dwarf Version", i32 5}
+!15 = !{i32 2, !"Debug Info Version", i32 3}
+!20 = !{!"blah"}


        


More information about the llvm-commits mailing list