On Jan 27, 2017, Alexandre Oliva <aol...@redhat.com> wrote:

> On Oct 19, 2016, Alexandre Oliva <aol...@redhat.com> wrote:
>> On Sep 23, 2016, Alexandre Oliva <aol...@redhat.com> wrote:
>>> On Aug 30, 2016, Alexandre Oliva <aol...@redhat.com> wrote:
>>>> Handling non-template friends is kind of easy, [...]

>>> Regstrapped on x86_64-linux-gnu and i686-linux-gnu, I'd failed to
>>> mention.

>>> Ping?

>> Ping?  (conflicts resolved, patch refreshed and retested)

> Ping?  (trivial conflicts resolved)

Ping?  https://gcc.gnu.org/ml/gcc-patches/2017-01/msg02112.html


> Handling non-template friends is kind of easy, but it required a bit
> of infrastructure in dwarf2out to avoid (i) forcing debug info for
> unused types or functions: DW_TAG_friend DIEs are only emitted if
> their DW_AT_friend DIE is emitted, and (ii) creating DIEs for such
> types or functions just to have them discarded at the end.  To this
> end, I introduced a list (vec, actually) of types with friends,
> processed at the end of the translation unit, and a list of
> DW_TAG_friend DIEs that, when we're pruning unused types, reference
> DIEs that are still not known to be used, revisited after we finish
> deciding all other DIEs, so that we prune DIEs that would have
> referenced pruned types or functions.

> Handling template friends turned out to be trickier: there's no
> representation in DWARF for templates.  I decided to give debuggers as
> much information as possible, enumerating all specializations of
> friend templates and outputting DW_TAG_friend DIEs referencing them as
> well.  I considered marking those as DW_AT_artificial, to indicate
> they're not explicitly stated in the source code, but in the end we
> decided that was not useful.  The greatest challenge was to enumerate
> all specializations of a template.  It looked trivial at first, given
> DECL_TEMPLATE_INSTANTIATIONS, but it won't list specializations of
> class-scoped functions and of nested templates.  For other templates,
> I ended up writing code to look for specializations in the hashtables
> of decl or type specializations.  That's not exactly efficient, but it
> gets the job done.


> for gcc/ChangeLog

>       PR debug/59319
>       * dwarf2out.c (class_types_with_friends): New.
>       (gen_friend_tags_for_type, gen_friend_tags): New.
>       (gen_member_die): Record class types with friends.
>       (deferred_marks): New.
>       (prune_unused_types_defer_undecided_mark_p): New.
>       (prune_unused_types_defer_mark): New.
>       (prune_unused_types_deferred_walk): New.
>       (prune_unused_types_walk): Defer DW_TAG_friend.
>       (prune_unused_types): Check deferred marks is empty on entry,
>       empty it after processing.
>       (dwarf2out_finish): Generate friend tags.
>       (dwarf2out_early_finish): Likewise.
>       * langhooks-def.h (LANG_HOOKS_GET_FRIENDS): New.
>       (LANG_HOOKS_FOR_TYPES_INITIALIZER): Add it.
>       * langhooks.h (lang_hooks_for_types): Add get_friends.
>       * hooks.c (hook_tree_const_tree_int_null): New.
>       * hooks.h (hook_tree_const_tree_int_null): Declare.

> for gcc/cp/ChangeLog

>       PR debug/59319
>       * cp-objcp-common.c (cp_get_friends): New.
>       * cp-objcp-common.h (cp_get_friends): Declare.
>       (LANG_HOOKS_GET_FRIENDS): Override.
>       * cp-tree.h (enumerate_friend_specializations): Declare.
>       * pt.c (optimize_friend_specialization_lookup_p): New.
>       (retrieve_friend_specialization): New.
>       (enumerate_friend_specializations): New.
>       (register_specialization): Update DECL_TEMPLATE_INSTANTIATIONS
>       for functions, even after definition, if we are emitting debug
>       info.

> for gcc/testsuite/ChangeLog

>       PR debug/59319
>       * g++.dg/debug/dwarf2/friend-1.C: New.
>       * g++.dg/debug/dwarf2/friend-2.C: New.
>       * g++.dg/debug/dwarf2/friend-3.C: New.
>       * g++.dg/debug/dwarf2/friend-4.C: New.
>       * g++.dg/debug/dwarf2/friend-5.C: New.
>       * g++.dg/debug/dwarf2/friend-6.C: New.
>       * g++.dg/debug/dwarf2/friend-7.C: New.
>       * g++.dg/debug/dwarf2/friend-8.C: New.
>       * g++.dg/debug/dwarf2/friend-9.C: New.
>       * g++.dg/debug/dwarf2/friend-10.C: New.
>       * g++.dg/debug/dwarf2/friend-11.C: New.
>       * g++.dg/debug/dwarf2/friend-12.C: New.
>       * g++.dg/debug/dwarf2/friend-13.C: New.
>       * g++.dg/debug/dwarf2/friend-14.C: New.
>       * g++.dg/debug/dwarf2/friend-15.C: New.
>       * g++.dg/debug/dwarf2/friend-16.C: New.
>       * g++.dg/debug/dwarf2/friend-17.C: New.
>       * g++.dg/debug/dwarf2/friend-18.C: New.

-- 
Alexandre Oliva, freedom fighter    http://FSFLA.org/~lxoliva/
You must be the change you wish to see in the world. -- Gandhi
Be Free! -- http://FSFLA.org/   FSF Latin America board member
Free Software Evangelist|Red Hat Brasil GNU Toolchain Engineer

Reply via email to