Thanks! I've added this as Issue 250130.1:

https://dwarfstd.org/issues/250130.1.html

-cary


On Thu, Jan 30, 2025 at 4:01 AM Michael Buch via Dwarf-discuss <
dwarf-discuss@lists.dwarfstd.org> wrote:

> # Allow alternate encoding of DW_AT_object_pointer as a variable index
> instead of DIE reference
>
> ## Background
>
> `DW_AT_object_pointer` is used by LLDB to conveniently determine the
> CV-qualifiers
> and storage class of C++ member functions when reconstructing types from
> DWARF.
> GCC currently emits `DW_AT_object_pointer` on both declaration and
> definition DIEs [1].
> Clang does not emit them on declarations, making the LLDB heuristics
> to find the object
> parameter fragile. We tried attaching `DW_AT_object_pointer` to
> declarations in Clang
> too [2], but that came at the cost of a ~5-10% increase in the
> `.debug_info` section size
> for some users, so we reverted it. This proposal describes an
> alternate encoding of the
> `DW_AT_object_pointer` which allows us to add it to declaration DIEs
> without
> incurring such size overheads.
>
> ## Overview
>
> The idea is to encode the index of the `DW_TAG_formal_parameter` that is
> the
> object parameter instead of a DIE reference. This index could then be of
> form
> `DW_FORM_implicit_const`, so we don't pay the 4 bytes for each reference,
> but instead pay for it once in the abbreviation.
>
> The implementation in Clang for this is currently being discussed in [3].
>
> The DWARF spec currently only mentions `reference` as the attribute class
> of `DW_AT_object_pointer`. So consumers may be surprised by this alternate
> encoding. Hence we thought it'd be good to run this past the committee.
>
> An alternative solution could be a new attribute describing the object
> parameter index (e.g., `DW_AT_object_pointer_index` with a `constant`
> attribute class).
>
> ## Proposed Changes
>
> In chapter "7.5.4 Attribute Encodings", change the "Table 7.5:
> Attribute encodings"
> table as follows:
>
> [ORIGINAL TEXT]
> >>>>>>>>>>>>>>>
> Attribute Name                 | Value | Classes
> -----------------------------------------------------------------------
> ...
> DW_AT_object_pointer    | 0x64  | reference
> ...
> [NEW TEXT]
> ==========
> Attribute Name                 | Value | Classes
> -----------------------------------------------------------------------
> ...
> DW_AT_object_pointer    | 0x64  | reference, constant
> ...
> <<<<<<<<<<<<<<<
>
> In chapter "5.7.8 Member Function Entries", extend the attribute class
> recommendation
> as follows:
>
> [ORIGINAL TEXT]
> >>>>>>>>>>>>>>>
> If the member function entry describes a non-static member function, then
> that
> entry has a DW_AT_object_pointer attribute whose value is a reference to
> the
> formal parameter entry that corresponds to the object for which the
> function is
> called.
> [NEW TEXT]
> ==========
> If the member function entry describes a non-static member function, then
> that
> entry has a DW_AT_object_pointer attribute whose value is a reference to
> the
> formal parameter entry that corresponds to the object for which the
> function is
> called. A producer may also choose to represent it as a constant whose
> value is
> the zero-based index of the formal parameter that corresponds to the object
> parameter.
> <<<<<<<<<<<<<<<
>
> ## References
>
> * [1]: https://godbolt.org/z/3TWjTfWon
> * [2]: https://github.com/llvm/llvm-project/pull/122742
> * [3]: https://github.com/llvm/llvm-project/pull/124790
> --
> Dwarf-discuss mailing list
> Dwarf-discuss@lists.dwarfstd.org
> https://lists.dwarfstd.org/mailman/listinfo/dwarf-discuss
>
-- 
Dwarf-discuss mailing list
Dwarf-discuss@lists.dwarfstd.org
https://lists.dwarfstd.org/mailman/listinfo/dwarf-discuss

Reply via email to