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

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

https://gcc.gnu.org/g:9d5efd46b3329f6b7b0eb2983f317687899caba6

commit r17-487-g9d5efd46b3329f6b7b0eb2983f317687899caba6
Author: H.J. Lu <[email protected]>
Date:   Sun May 10 18:36:26 2026 +0800

    x86-64: Use R11 for DRAP register in preserve_none functions

    In 64-bit mode, for preserve_none functions, DRAP may use any register
    except AX, R12âR15, DI, SI (argument registers), SP, and BP. Use R11.
    In non-callee-saved functions, R10 and R13 are also available since they
    are not used for parameter passing.  In 32-bit mode, preserve_none does
    not affect parameter passing, so the current approach remains valid.

    DRAP register is used to restore stack pointer in epilogue for stack
    realignment.  Always save and restore DRAP register between prologue
    and epilogue so that stack pointer can be restored.

    Tested with CPython 3.14.4 on Linux/x86-64.

    gcc/

            PR target/120870
            * config/i386/i386.cc (ix86_save_reg): Return true for DRAP
            register early at entry.
            (find_drap_reg): Use R11_REG in preserve_none functions in
            64-bit mode.

    gcc/testsuite/

            PR target/120870
            * gcc.target/i386/pr120870-1.c: New test.
            * gcc.target/i386/pr120870-2.c: Likewise.

    Signed-off-by: H.J. Lu <[email protected]>
    Co-Authored-By: Uros Bizjak <[email protected]>

Reply via email to