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

--- Comment #9 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Longjun Luo <[email protected]>:

https://gcc.gnu.org/g:e762fd7f4c8c3a015dd69a692c468806c0a2a3d8

commit r17-6546-ge762fd7f4c8c3a015dd69a692c468806c0a2a3d8
Author: Longjun Luo <[email protected]>
Date:   Thu Nov 12 03:09:08 2026 +0800

    lto: Preserve input DIE references in decl states [PR126348]

    Abstract-origin references in a function body can use decl-state slots.
    SCC unification or prevailing-declaration replacement can make those slots
    resolve to another input's trees, so subsequent tree-to-DIE lookups return
    origins from that input.

    Retain sparse slot-to-DIE references with each decl state. Use them when
    reading a body to register its instances' input origins for late DWARF.
    Copy these records alongside unread bodies in WPA.

    Only LGEN output permits deriving the list from input tree slots. WPA
    and incremental-link outputs encode explicit lists, including empty lists.
    Re-emitted trees carry their saved origins in their per-tree records.

    Bootstrapped and regression tested on x86_64-pc-linux-gnu. Also tested
    with bootstrap-lto and the C/C++ LTO suites (gcc.dg/lto: 2012,
    g++.dg/lto: 1866 expected passes), with no new regressions.

    gcc/ChangeLog:

            PR debug/126348
            * lto-streamer.h (lto_decl_header): Add debug_ref_size.
            (lto_decl_origin_ref): New.
            (lto_in_decl_state, lto_out_decl_state): Add origin_refs.
            (lto_decl_origin_ref_at): Declare.
            * lto-streamer-in.cc (data_in::register_origin_refs): Resolve
            decl-state slot references.
            * lto-streamer-out.cc (copy_function_or_variable): Copy slot
origins.
            (lto_output_decl_origin_refs): New function.
            (produce_asm_for_decls): Write the saved-reference stream.
            * lto-section-in.cc (lto_decl_origin_ref_at): New function.
            (lto_delete_in_decl_state, lto_free_function_in_decl_state):
            Free origin records.
            * lto-section-out.cc (lto_delete_out_decl_state): Likewise.

    gcc/lto/ChangeLog:

            PR debug/126348
            * lto-common.cc (lto_read_in_decl_state): Derive slot references
            from original inputs or read an explicit list.
            (lto_read_decls): Read the saved-reference stream.

    gcc/testsuite/ChangeLog:

            PR debug/126348
            * g++.dg/lto/pr126348_0.C: Also check the inline instance's origin.
            * g++.dg/lto/pr126348-2_0.C: New test.
            * g++.dg/lto/pr126348-2_1.C: Likewise.
            * g++.dg/lto/pr126348-2_2.C: Likewise.

    Signed-off-by: Longjun Luo <[email protected]>

Reply via email to