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

--- 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:543617c93595e0cb45ff7ee52c635ca30a2fe361

commit r17-4380-g543617c93595e0cb45ff7ee52c635ca30a2fe361
Author: Longjun Luo <[email protected]>
Date:   Thu Sep 17 03:02:05 2026 +0000

    middle-end: Defer section resolution for GIMPLE wrappers [PR126841]

    Since r167795, cfgexpand has resolved a function's section before RTL
    expansion.  r168624 added resolve_unique_section to the direct thunk
    emission path, when thunks were still emitted directly as assembly.  When
    r202592 added a GIMPLE thunk path, the call was retained in both paths. 
The
    direct assembler path still needs it, but the GIMPLE path later reaches
    cfgexpand, so its call is redundant.

    It can also be too early.  IPA ICF can turn equivalent functions whose
    addresses matter into GIMPLE wrappers during WPA, before LTO privatizes
their
    assembler names.  The early call records a section based on the old name,
    and that stale section is streamed into LTRANS.  IPA strub has the same
    problem in the GIMPLE wrapper code added in r14-6201.

    Remove the early calls for GIMPLE wrappers and let cfgexpand resolve their
    sections from the final assembler names.  Keep the call for directly
emitted
    assembler thunks; during LTO output it is reached only after privatization.
    Explicit and deliberately inherited section names remain unchanged.  This
    fixes the stale name at its source instead of discarding an
already-resolved
    section only when LTO privatizes a symbol.

            PR lto/126841

    gcc/ChangeLog:

            * doc/invoke.texi (-ffunction-sections): Document implicit function
            section names under LTO.
            * ipa-strub.cc (pass_ipa_strub::execute): Let cfgexpand resolve the
            GIMPLE wrapper section.
            * symtab-thunks.cc (expand_thunk): Likewise for generic GIMPLE
thunks.
            Clarify the direct-assembler case.

    gcc/testsuite/ChangeLog:

            * gcc.dg/lto/pr126841-strub_0.c: New test.
            * gcc.dg/lto/pr126841-strub_1.c: New test.
            * gcc.dg/lto/pr126841_0.c: New test.
            * gcc.dg/lto/pr126841_1.c: New test.
            * gcc.dg/lto/pr126841_2.c: New test.
            * gcc.dg/lto/pr126841_3.c: New test.

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

Reply via email to