[PATCH] D144181: [clang][DebugInfo] Add abi-tags on constructors/destructors as LLVM annotations

Michael Buch via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Feb 16 05:27:28 PST 2023


Michael137 created this revision.
Michael137 added reviewers: dblaikie, aprantl.
Herald added a project: All.
Michael137 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

**Summary**

After this patch, any `AbiTagAttr` attribute on a constructor/destructor
(like the ones for numerous types in libcxx) will be attached to the
declaration `DW_TAG_subprogram` as a `DW_TAG_LLVM_annotation`. E.g.,

  DW_TAG_subprogram
    DW_AT_name        ("shared_ptr")
    DW_AT_decl_file   ("./bin/../include/c++/v1/__memory/shared_ptr.h")
    DW_AT_decl_line   (475)
    DW_AT_declaration (true)
    DW_AT_external    (true)
    DW_AT_accessibility       (DW_ACCESS_public)
  
    DW_TAG_LLVM_annotation
      DW_AT_name      ("abi_tag")
      DW_AT_const_value       ("v170000")

We only emit these annotations for constructors/destructors declarations
because those don't carry linkage names, which is where this information
is usually encoded.

**Motivation**

ABI tags affect a function's linkage name, which LLDB uses to resolve
function calls during expression evaluation. However,
constructors/destructors are emitted as declarations and can have
multiple definitions with different linkage names for a single
declaration DIE. LLDB relies on Clang to mangle the function AST node
into the correct linkage name. However, LLDB doesn't know about the
`AbiTagAttr` that was attached to a constructor/destructor in the
source, so there's no way to cleanly reconstruct the AST and resolve
the function symbol.

With this patch, LLDB can attach the ABI tag to the ctor/dtor decl
and let clang determine which linkage name to pick.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D144181

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/CodeGen/CGDebugInfo.h
  clang/test/CodeGen/attr-abi_tag-ctors-dtors.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D144181.497979.patch
Type: text/x-patch
Size: 5744 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230216/4ab681d5/attachment.bin>


More information about the cfe-commits mailing list