https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117289

--- Comment #2 from Indu Bhagat <ibhagat at gcc dot gnu.org> ---
Regarding handling of duplicate types in CTF, the bulk of expectation lies on
the link-time de-duplication.  On the compiler side, we simply try to not emit
duplicate CTF types to avoid bloating up the object files (and well, to reduce
the work at link time): this is achieved by DWARF DIE references as the key in
the ctfc_types hash_table (see ctf_type_exists ()).

In this testcase, when -std=gnu23 is added to the command line, I do see that
there are two distinct DWARF DIEs with tag DW_TAG_subroutine_type: one for the
structure member and another for the typedef. (As a consequence, we see the two
CTF types are added in the CTF container).

 <2><3c>: Abbrev Number: 2 (DW_TAG_member)
    <3d>   DW_AT_name        : (indirect string, offset: 0x6f7): func
    <41>   DW_AT_decl_file   : 1
    <41>   DW_AT_decl_line   : 14
    <42>   DW_AT_decl_column : 16
    <43>   DW_AT_type        : <0x59>
    <47>   DW_AT_data_member_location: 8
 <2><48>: Abbrev Number: 0
 <1><49>: Abbrev Number: 1 (DW_TAG_pointer_type)
    <4a>   DW_AT_byte_size   : 8
    <4a>   DW_AT_type        : <0x22>
 <1><4e>: Abbrev Number: 3 (DW_TAG_subroutine_type)
    <4f>   DW_AT_prototyped  : 1
    <4f>   DW_AT_sibling     : <0x59>
 <2><53>: Abbrev Number: 4 (DW_TAG_formal_parameter)
    <54>   DW_AT_type        : <0x49>
 <2><58>: Abbrev Number: 0
 <1><59>: Abbrev Number: 1 (DW_TAG_pointer_type)
    <5a>   DW_AT_byte_size   : 8
    <5a>   DW_AT_type        : <0x4e>

...
 <1><74>: Abbrev Number: 8 (DW_TAG_typedef)
    <75>   DW_AT_name        : (indirect string, offset: 0x227c):
rcu_callback_t
    <79>   DW_AT_decl_file   : 1
    <7a>   DW_AT_decl_line   : 20
    <7b>   DW_AT_decl_column : 16
    <7c>   DW_AT_type        : <0x80>
 <1><80>: Abbrev Number: 1 (DW_TAG_pointer_type)
    <81>   DW_AT_byte_size   : 8
    <81>   DW_AT_type        : <0x85>
 <1><85>: Abbrev Number: 3 (DW_TAG_subroutine_type)
    <86>   DW_AT_prototyped  : 1
    <86>   DW_AT_sibling     : <0x90>
 <2><8a>: Abbrev Number: 4 (DW_TAG_formal_parameter)
    <8b>   DW_AT_type        : <0x49>
 <2><8f>: Abbrev Number: 0
 <1><90>: Abbrev Number: 9 (DW_TAG_variable)
    <91>   DW_AT_name        : rcb
    <95>   DW_AT_decl_file   : 1
    <96>   DW_AT_decl_line   : 22
    <97>   DW_AT_decl_column : 16
    <98>   DW_AT_type        : <0x74>
    <9c>   DW_AT_external    : 1
    <9c>   DW_AT_location    : 9 byte block: 3 10 0 0 0 0 0 0 0        
(DW_OP_addr: 10)

Reply via email to