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

--- Comment #7 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:93648f6c38b00b6aa308be18c3665ffe724ceeb2

commit r17-6544-g93648f6c38b00b6aa308be18c3665ffe724ceeb2
Author: Longjun Luo <[email protected]>
Date:   Thu Nov 12 03:09:06 2026 +0800

    dwarf2out: Prefer an instance's saved abstract origin [PR126348]

    In LTO, replacing an instance's origin tree can redirect the tree-to-DIE
    lookup to another input's DIE. Keep the instance's saved origin separate
    from the declaration's DIE reference.

    Add a kind parameter to the external DIE hooks and pass the instance to
    add_abstract_origin_attribute. Prefer its saved reference, falling back
    to the origin tree's DIE when none is saved.

    Copy saved origins during LTO cloning and inlining. Clear the
    destination's saved reference when the source has none.

    Tested on x86_64-pc-linux-gnu with a C/C++ checking build and
    the LTO suites (gcc.dg/lto: 2012, g++.dg/lto: 1849 expected passes),
    with no unexpected failures.

    gcc/ChangeLog:

            PR debug/126348
            * debug.h (debug_external_ref_kind): New enum.
            (gcc_debug_hooks): Add the kind parameter and document saved
references.
            (debug_false_tree_charstarstar_uhwistar,
            debug_nothing_tree_charstar_uhwi): Add the kind parameter.
            (copy_debug_abstract_origin): Declare.
            * debug.cc (debug_false_tree_charstarstar_uhwistar,
            debug_nothing_tree_charstar_uhwi): Adjust signatures.
            (copy_debug_abstract_origin): New function.
            * dwarf2out.cc (saved_die_ref, saved_die_ref_traits,
saved_die_ref_map,
            external_abstract_origin_map): New.
            (dwarf2out_die_ref_for_decl, dwarf2out_register_external_die): Take
            the kind parameter.  Query and register saved origins separately
from
            declaration references.
            (add_abstract_origin_attribute): Take the instance and prefer its
saved
            origin.  Fall back to the origin tree's DIE.
            (gen_entry_point_die, gen_formal_parameter_die, gen_subprogram_die,
            gen_variable_die, gen_label_die, gen_lexical_block_die,
            gen_inlined_subroutine_die): Pass the instance tree.
            * cgraphclones.cc: Include debug.h.
            (cgraph_node::create_virtual_clone): Copy the saved origin.
            * tree-inline.cc (remap_block, expand_call_inline,
            tree_function_versioning): Likewise.
            * lto-streamer-in.cc (lto_input_tree): Specify DEBUG_DIE_REF.
            * lto-streamer-out.cc (lto_write_tree_1): Likewise.

    gcc/lto/ChangeLog:

            PR debug/126348
            * lto-common.cc (process_dref, lto_read_decls): Specify
DEBUG_DIE_REF.

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

Reply via email to