public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "cvs-commit at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/103503] RFE: no save registers attribute
Date: Sat, 27 Jan 2024 12:19:53 +0000	[thread overview]
Message-ID: <bug-103503-4-6crWTIl1ec@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-103503-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #6 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by H.J. Lu <hjl@gcc.gnu.org>:

https://gcc.gnu.org/g:a96549dce7636edfc693bf758ef27fcd8adc6161

commit r14-8469-ga96549dce7636edfc693bf758ef27fcd8adc6161
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Tue Jan 23 06:59:50 2024 -0800

    x86: Add no_callee_saved_registers function attribute

    When an interrupt handler is implemented by an assembly stub which does:

    1. Save all registers.
    2. Call a C function.
    3. Restore all registers.
    4. Return from interrupt.

    it is completely unnecessary to save and restore any registers in the C
    function called by the assembly stub, even if they would normally be
    callee-saved.

    Add no_callee_saved_registers function attribute, which is complementary
    to no_caller_saved_registers function attribute, to mark a function which
    doesn't have any callee-saved registers.  Such a function won't save and
    restore any registers.  Classify function call-saved register handling
    type with:

    1. Default call-saved registers.
    2. No caller-saved registers with no_caller_saved_registers attribute.
    3. No callee-saved registers with no_callee_saved_registers attribute.

    Disallow sibcall if callee is a no_callee_saved_registers function
    and caller isn't a no_callee_saved_registers function.  Otherwise,
    callee-saved registers won't be preserved.

    After a no_callee_saved_registers function is called, all registers may
    be clobbered.  If the calling function isn't a no_callee_saved_registers
    function, we need to preserve all registers which aren't used by function
    calls.

    gcc/

            PR target/103503
            PR target/113312
            * config/i386/i386-expand.cc (ix86_expand_call): Replace
            no_caller_saved_registers check with call_saved_registers check.
            Clobber all registers that are not used by the callee with
            no_callee_saved_registers attribute.
            * config/i386/i386-options.cc (ix86_set_func_type): Set
            call_saved_registers to TYPE_NO_CALLEE_SAVED_REGISTERS for
            noreturn function.  Disallow no_callee_saved_registers with
            interrupt or no_caller_saved_registers attributes together.
            (ix86_set_current_function): Replace no_caller_saved_registers
            check with call_saved_registers check.
            (ix86_handle_no_caller_saved_registers_attribute): Renamed to ...
            (ix86_handle_call_saved_registers_attribute): This.
            (ix86_gnu_attributes): Add
            ix86_handle_call_saved_registers_attribute.
            * config/i386/i386.cc (ix86_conditional_register_usage): Replace
            no_caller_saved_registers check with call_saved_registers check.
            (ix86_function_ok_for_sibcall): Don't allow callee with
            no_callee_saved_registers attribute when the calling function
            has callee-saved registers.
            (ix86_comp_type_attributes): Also check
            no_callee_saved_registers.
            (ix86_epilogue_uses): Replace no_caller_saved_registers check
            with call_saved_registers check.
            (ix86_hard_regno_scratch_ok): Likewise.
            (ix86_save_reg): Replace no_caller_saved_registers check with
            call_saved_registers check.  Don't save any registers for
            TYPE_NO_CALLEE_SAVED_REGISTERS.  Save all registers with
            TYPE_DEFAULT_CALL_SAVED_REGISTERS if function with
            no_callee_saved_registers attribute is called.
            (find_drap_reg): Replace no_caller_saved_registers check with
            call_saved_registers check.
            * config/i386/i386.h (call_saved_registers_type): New enum.
            (machine_function): Replace no_caller_saved_registers with
            call_saved_registers.
            * doc/extend.texi: Document no_callee_saved_registers attribute.

    gcc/testsuite/

            PR target/103503
            PR target/113312
            * gcc.dg/torture/no-callee-saved-run-1a.c: New file.
            * gcc.dg/torture/no-callee-saved-run-1b.c: Likewise.
            * gcc.target/i386/no-callee-saved-1.c: Likewise.
            * gcc.target/i386/no-callee-saved-2.c: Likewise.
            * gcc.target/i386/no-callee-saved-3.c: Likewise.
            * gcc.target/i386/no-callee-saved-4.c: Likewise.
            * gcc.target/i386/no-callee-saved-5.c: Likewise.
            * gcc.target/i386/no-callee-saved-6.c: Likewise.
            * gcc.target/i386/no-callee-saved-7.c: Likewise.
            * gcc.target/i386/no-callee-saved-8.c: Likewise.
            * gcc.target/i386/no-callee-saved-9.c: Likewise.
            * gcc.target/i386/no-callee-saved-10.c: Likewise.
            * gcc.target/i386/no-callee-saved-11.c: Likewise.
            * gcc.target/i386/no-callee-saved-12.c: Likewise.
            * gcc.target/i386/no-callee-saved-13.c: Likewise.
            * gcc.target/i386/no-callee-saved-14.c: Likewise.
            * gcc.target/i386/no-callee-saved-15.c: Likewise.
            * gcc.target/i386/no-callee-saved-16.c: Likewise.
            * gcc.target/i386/no-callee-saved-17.c: Likewise.
            * gcc.target/i386/no-callee-saved-18.c: Likewise.

  parent reply	other threads:[~2024-01-27 12:19 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-30 18:06 [Bug target/103503] New: " hpa at zytor dot com
2021-11-30 21:00 ` [Bug target/103503] " pinskia at gcc dot gnu.org
2021-11-30 21:02 ` pinskia at gcc dot gnu.org
2021-11-30 21:03 ` pinskia at gcc dot gnu.org
2021-11-30 21:03 ` pinskia at gcc dot gnu.org
2022-06-06 17:00 ` hpa at zytor dot com
2024-01-11  3:44 ` hjl.tools at gmail dot com
2024-01-27 12:19 ` cvs-commit at gcc dot gnu.org [this message]
2024-05-15 16:17 ` hpa at zytor dot com

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-103503-4-6crWTIl1ec@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).