[llvm] 8af224d - [DebugInfo] Fix emission of empty debug_names for Apple

Felipe de Azevedo Piovezan via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 20 11:29:34 PDT 2023


Author: Felipe de Azevedo Piovezan
Date: 2023-06-20T14:29:12-04:00
New Revision: 8af224d52cad1380996ed84174d0b01a17d52759

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

LOG: [DebugInfo] Fix emission of empty debug_names for Apple

D118754 added a new DICompileUnit::DebugNameTableKind for "Apple", so that,
under DWARF 5, the following combination is used inside DwarfDebug.cpp:

```
(lldb) p getAccelTableKind()
(llvm::AccelTableKind) $6 = Dwarf
(lldb) p CU.getNameTableKind()
(llvm::DICompileUnit::DebugNameTableKind) $7 = Apple
```

This creates a problem in the if statements changed, whereby "for non Apple
AccelTableKind" we emit empty tables for any DebugNameTableKind that is not
"Default". We should consider the newly added kind here too.

Note that our existing test could have caught this, if only it had checked the
_contents_ of the table, instead of merely checking for the existence of the
section.

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

Added: 
    

Modified: 
    llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
    llvm/test/DebugInfo/accel-tables-apple.ll

Removed: 
    


################################################################################
diff  --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
index df2161410ad08..59376bd695d3f 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
@@ -494,6 +494,7 @@ static StringRef getObjCMethodName(StringRef In) {
 void DwarfDebug::addSubprogramNames(const DICompileUnit &CU,
                                     const DISubprogram *SP, DIE &Die) {
   if (getAccelTableKind() != AccelTableKind::Apple &&
+      CU.getNameTableKind() != DICompileUnit::DebugNameTableKind::Apple &&
       CU.getNameTableKind() == DICompileUnit::DebugNameTableKind::None)
     return;
 
@@ -3538,6 +3539,7 @@ void DwarfDebug::addAccelNameImpl(const DICompileUnit &CU,
     return;
 
   if (getAccelTableKind() != AccelTableKind::Apple &&
+      CU.getNameTableKind() != DICompileUnit::DebugNameTableKind::Apple &&
       CU.getNameTableKind() != DICompileUnit::DebugNameTableKind::Default)
     return;
 

diff  --git a/llvm/test/DebugInfo/accel-tables-apple.ll b/llvm/test/DebugInfo/accel-tables-apple.ll
index fc1e1ed5bc1b0..727e7aecc130e 100644
--- a/llvm/test/DebugInfo/accel-tables-apple.ll
+++ b/llvm/test/DebugInfo/accel-tables-apple.ll
@@ -1,8 +1,9 @@
 ; Verify the emission of accelerator tables for nameTableKind: Apple
 ; REQUIRES: x86-registered-target
 
-; RUN: llc -mtriple=x86_64-apple-darwin12 -filetype=obj < %S/Inputs/name-table-kind-apple-5.ll \
-; RUN:   | llvm-readobj --sections - | FileCheck --check-prefix=DEBUG_NAMES %s
+; RUN: llc -mtriple=x86_64-apple-darwin12 -filetype=obj -o %t.d5.o < %S/Inputs/name-table-kind-apple-5.ll
+; RUN:   llvm-readobj --sections %t.d5.o | FileCheck --check-prefix=DEBUG_NAMES %s
+; RUN:   llvm-dwarfdump --debug-names %t.d5.o | FileCheck --check-prefix=COUNT_DEBUG_NAMES %s
 
 ; RUN: llc -mtriple=x86_64-apple-darwin12 -filetype=obj < %S/Inputs/name-table-kind-apple-4.ll \
 ; RUN:   | llvm-readobj --sections - | FileCheck --check-prefix=APPLE %s
@@ -18,3 +19,5 @@
 ; DEBUG_NAMES: debug_names
 ; DEBUG_NAMES-NOT: apple_names
 ; DEBUG_NAMES-NOT: pubnames
+
+; COUNT_DEBUG_NAMES: Name count: 4


        


More information about the llvm-commits mailing list