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

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

https://gcc.gnu.org/g:488e28a80eeabf6adb791a516e6cdd3a7dd890ca

commit r16-5944-g488e28a80eeabf6adb791a516e6cdd3a7dd890ca
Author: Alexandre Oliva <[email protected]>
Date:   Sat Dec 6 20:11:46 2025 -0300

    add fusage for non-ACCUMULATE_OUTGOING_ARGS calls [PR122947]

    Since we may delete stores that are found to be redundant in
    postreload cse, we need cselib to invalidate argument stores at calls,
    and to that end we need CALL_INSN_FUNCTION_USAGE to mention all MEM
    stack space that may be legitimately modified by a const/pure callee,
    i.e., all arguments passed to it on the stack.

    When ACCUMULATE_OUTGOING_ARGS, each on-stack argument gets its own
    usage information, but when it's not, each argument is pushed
    incrementally, without precomputed stack slots.

    Since we only mentioned such precomputed stack slots in
    CALL_INSN_FUNCTION_USAGE, non-ACCUMULATE_OUTGOING_ARGS configurations
    miss the stack usage data, and cselib fails to invalidate the stores.

    Stores in such slots are anonymous, and they often invalidate other
    anonymous slots, even part of the same object, but as the testcase
    demonstrates, we may occasionally be unlucky that consecutive calls
    have the stores to multi-word objects reordered by scheduling in such
    a way that the last store for the first call survives the call in the
    cselib tables, and then it is found to be redundant with the first
    store for the subsequent call, as in the testcase.

    So, if we haven't preallocated outgoing arguments for a call (which
    would give us preassigned stack slots), and we have used any stack
    space, add function call usage covering the entire stack range where
    arguments were stored.


    for  gcc/ChangeLog

            PR rtl-optimization/122947
            * calls.cc (expand_call): Add stack function usage in
            non-ACCUMULATE_OUTGOING_ARGS configurations.

    for  gcc/testsuite/ChangeLog

            PR rtl-optimization/122947
            * gcc.dg/pr122947.c: New.

Reply via email to