[PATCH] D118754: [DebugInfo] Add new DebugNameTableKind::Apple to emit `.debug_names` with

Jonas Devlieghere via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 1 20:59:45 PST 2022


JDevlieghere created this revision.
JDevlieghere added reviewers: aprantl, labath, dblaikie, clayborg.
Herald added subscribers: dang, hiraditya.
JDevlieghere requested review of this revision.
Herald added a project: LLVM.

On Apple platforms, we generate `.apple_names`, `.apple_types`, `.apple_namespaces` and `.apple_objc` Apple accelerator tables for DWARF 4 and earlier. For DWARF 5, I would expect us to generate `.debug_names`, but instead we get no accelerator tables at all.

In the backend we are correctly determining that we should be emitting `.debug_names` instead of `.apple_names`. However, when we get to the point of emitting the section, CU debug name table kind is not "default" are skipped <https://github.com/apple/llvm-project/blob/5e2798f25ca9587a2343e9df2c487a341718934b/llvm/lib/CodeGen/AsmPrinter/AccelTable.cpp#L553>. This property is controlled by the `-gpubnames` argument. Indeed, passing `-gdwarf-5 -gpubnames` does generate `.debug_names` section, on all platforms.

On Apple platforms, the `.debug_names` section should be emitted by default. There's a few ways to address this issue:

1. We could always pass `-gpubnames` to CC1 for MachO. My concerns with this approach that it's lossy in the sense that you can't tell if `-gpubnames` was passed explicitly or because we're targeting an Apple platform. If you are not emitting apple accelerator tables or debug names this will results in an actual pubnames section, which we don't want.

2. We could pass a new flag `-gapplenames` to CC1 and set DebugNameTableKind to `Default`. There are a few places that assume that DebugNameTableKind::Default == pubnames but I don't think that assumption actually hurts.

3. We could pass a new flag `-gapplenames` to CC1 and set DebugNameTableKind to `Apple`. That way we know that the CU was compiled with the intent of always emitting accelerator tables. For dwarf 4 and earlier, that means Apple accelerator tables. For dwarf 5 and later, that means `.debug names`.

The third approach seemed the most principled and is what this patch implements, but I'm happy to discuss alternatives.

https://github.com/llvm/llvm-project/issues/53532


https://reviews.llvm.org/D118754

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  llvm/include/llvm/IR/DebugInfoMetadata.h
  llvm/lib/CodeGen/AsmPrinter/AccelTable.cpp
  llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
  llvm/lib/IR/DebugInfoMetadata.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D118754.405143.patch
Type: text/x-patch
Size: 5751 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220202/77236cb8/attachment.bin>


More information about the llvm-commits mailing list