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

            Bug ID: 128061
           Summary: [DebugInfo] Zero-length inline DIE without abstract
                    origin emitted for a TLS wrapper
           Product: gcc
           Version: 17.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: debug
          Assignee: unassigned at gcc dot gnu.org
          Reporter: wujielun402 at gmail dot com
  Target Milestone: ---

With -O2 -g -gdwarf-5, GCC emits a zero-length DW_TAG_inlined_subroutine
inside read_cell for a compiler-generated C++ thread-local storage (TLS)
wrapper. The entry records an inline entry point and call-site coordinates,
but has neither DW_AT_abstract_origin nor a name identifying the inlined
function. Is this entry intentional for inline-entry tracking, or should
it be omitted or given an abstract-origin reference?

Reproducer source (repro.cc):

        int make_value ();

        struct cell_type
        {
          cell_type ();
          int value;
        };

        cell_type::cell_type () : value (make_value ()) {}

        thread_local cell_type cell;

        int
        read_cell ()
        {
          return cell.value;
        }

Compile to an object:

        g++ -O2 -g -gdwarf-5 -c repro.cc -o repro.o

Compiler Explorer: https://godbolt.org/z/x6dG7PMs9

Relevant excerpt from the supplied readelf .debug_info output:

         <2><cd>: Abbrev Number: 17 (DW_TAG_inlined_subroutine)
            <ce>   DW_AT_entry_pc    : 0x10
            <d6>   DW_AT_GNU_entry_view: 2
            <d7>   DW_AT_low_pc      : 0x10
            <df>   DW_AT_high_pc     : 0
            <e7>   DW_AT_call_file   : 1
            <e8>   DW_AT_call_line   : 15
            <e9>   DW_AT_call_column : 11
         <2><ea>: Abbrev Number: 2 (DW_TAG_inlined_subroutine)
            <eb>   DW_AT_abstract_origin: <0xa1>

DW_AT_high_pc is a length here, so DIE 0xcd covers the empty range
[0x10, 0x10). It has no children and no DW_AT_name, DW_AT_linkage_name,
DW_AT_specification, or DW_AT_abstract_origin. DIE 0xea is a separate
sibling entry, not a source of inherited attributes for DIE 0xcd.

Source inspection suggests a mismatch between ignoring the wrapper's
function description and retaining its inline-instance description:
get_tls_wrapper_fn in gcc/cp/decl2.cc marks the wrapper DECL_IGNORED_P,
while gen_inlined_subroutine_die in gcc/dwarf2out.cc still creates the
inline DIE. add_abstract_origin_attribute adds no reference when the
origin DIE is absent.

Reply via email to