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

Pavel Labath via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Mar 6 03:26:49 PST 2023


labath added a comment.

In D144181#4142295 <https://reviews.llvm.org/D144181#4142295>, @Michael137 wrote:

> We thought a bit about what it would take to link a constructor declaration DIE to the various definitions (e.g., via a `DW_AT_LLVM_complete_ctor_linkage_name` or `DW_AT_LLVM_complete_ctor_ref`). The issue with this is that it would mess with type uniquing. E.g., what if two different CUs each had a constructor declaration but differed only in which definitions they linked to? Even if dsymutil were to be able to merge the declarations into a single one, LLDB would still have to support the case where two constructor DIEs for the same type point to different definitions depending on how they were used in the corresponding object files.
>
> One could instead have some new attribute on the various constructor definitions specifying which constructor type it is, and then implement @pavel's suggestion of attaching multiple `asm` labels to the `CXXConstructorDecl`. To support that in LLDB we'd have to do a lookup in the DWARF index and filter appropriately.

What about doing both? Have the declaration DIE specify the linkage names of both structor types (regardless of whether they are used in a particular CU -- just like with "normal" functions), and then have the definition DIEs specify which flavour of the structor are they defining?

> But it's unclear to me whether this is much better than the proposed patch. I pinged the libcxx people regarding their policy of using abi-tags on structures/namespaces

Yea.. I don't know. I don't really like it because it's still very much a secret clang-lldb handshake that will not work with other compilers or debuggers. But maybe it's better because it's not a three-way libc++-clang-lldb handshake and has a chance of working with libraries using abi tags in a different way than libc++?

I'm just the peanut gallery here, so feel free to overrule me.

> Some more findings on the Clang side: a very naive way to support multiple `asm` labels is to adjust the `ManglingContext::mangleName` to be aware of multiple `asm` labels and pick the correct one based on the `GlobalDecl` we're mangling. But we'd need to somehow match `CtorType` to the `AsmLabelAttr` in question. Which is possibly doable by encoding the `CtorType` into the label. E.g., `asm("C2<mangled_name>")` (?) Though that seems hacky

A bit, though if the code change itself is simple/localized, then we might be able to get away with a new attribute, or an extension of the existing one (`A() __attribute((full_structor_asm("fooC1"), base_structor_asm("fooC2"))` or something -- it's not like people will be actually typing this code anyway...)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D144181/new/

https://reviews.llvm.org/D144181



More information about the cfe-commits mailing list