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

--- Comment #2 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The trunk branch has been updated by Andrew Pinski <[email protected]>:

https://gcc.gnu.org/g:4440e022d220c19358745a1ba7ccf6ae054ce347

commit r16-4200-g4440e022d220c19358745a1ba7ccf6ae054ce347
Author: Andrew Pinski <[email protected]>
Date:   Mon Sep 22 15:26:00 2025 -0700

    fab: rewrite optimize_stack_restore call check [PR122033]

    The call check in optimize_stack_restore is not the same as
    what is described in the comment before the function. It has never
    been the same even. It has always allowed all nromal builtins but not
    target builtins while the comment says no calls.

    This rewrites it to allow the following.
    * a restore right before a noreturn is fine to be removed as the noreturn
      function will do the restore (or exit the program).
    * Internal functions are ok because they will turn into an instruction or 2
    * Still specifically reject alloca and __scrub_leave
    * simple or inexpensive builtins (including target builtins)

    This will both reject some more locations but also accepts more locations
due
    to the internal and target and noreturn function calls checks.

    Bootstrapped and tested on x86_64-linux-gnu.

    Changes since v1:
    * v2: Add comment about why restoring before calls is important.

            PR tree-optimization/122033
    gcc/ChangeLog:

            * tree-ssa-ccp.cc (optimize_stack_restore): Rewrite the call check.
            Update comment in the front to new rules on calls.
            * tree.h (fndecl_builtin_alloc_p): New function.

    gcc/testsuite/ChangeLog:

            * gcc.dg/tree-ssa/pr122033-1.c: New test.
            * gcc.dg/tree-ssa/pr122033-2.c: New test.

    Signed-off-by: Andrew Pinski <[email protected]>

Reply via email to