* [Bug target/103503] RFE: no save registers attribute
2021-11-30 18:06 [Bug target/103503] New: RFE: no save registers attribute hpa at zytor dot com
@ 2021-11-30 21:00 ` pinskia at gcc dot gnu.org
2021-11-30 21:02 ` pinskia at gcc dot gnu.org
` (6 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-11-30 21:00 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103503
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
x86 (and I think MIPS) has an interrupt attribute, will that work instead?
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug target/103503] RFE: no save registers attribute
2021-11-30 18:06 [Bug target/103503] New: RFE: no save registers attribute 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
` (5 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-11-30 21:02 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103503
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
RISCV does have the interrupt attribute too which should work here.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug target/103503] RFE: no save registers attribute
2021-11-30 18:06 [Bug target/103503] New: RFE: no save registers attribute 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
` (4 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-11-30 21:03 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103503
--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
the only major target which does not have the interrupt attribute is aarch64.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug target/103503] RFE: no save registers attribute
2021-11-30 18:06 [Bug target/103503] New: RFE: no save registers attribute hpa at zytor dot com
` (2 preceding siblings ...)
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
` (3 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-11-30 21:03 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103503
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Severity|normal |enhancement
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug target/103503] RFE: no save registers attribute
2021-11-30 18:06 [Bug target/103503] New: RFE: no save registers attribute hpa at zytor dot com
` (3 preceding siblings ...)
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
` (2 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: hpa at zytor dot com @ 2022-06-06 17:00 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103503
--- Comment #4 from H. Peter Anvin <hpa at zytor dot com> ---
The interrupt attribute typically does two things:
1. It changes the return instruction;
2. It marks all registers as saved.
2 is exactly the *opposite* of what I want; I would like to improve performance
by the fact that the compiler-invisible entry flow has already saved all
registers, whether or not they are saved in the ABI. Thus, I would like it to
treat all (non-fixed) registers as *clobbered*, not *saved*.
Ideally, "nosaved" and "interrupt" should be possible to use together, to get
effect #1 of the interrupt attribute, but that is usually less important.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug target/103503] RFE: no save registers attribute
2021-11-30 18:06 [Bug target/103503] New: RFE: no save registers attribute hpa at zytor dot com
` (4 preceding siblings ...)
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
2024-05-15 16:17 ` hpa at zytor dot com
7 siblings, 0 replies; 9+ messages in thread
From: hjl.tools at gmail dot com @ 2024-01-11 3:44 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103503
H.J. Lu <hjl.tools at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Ever confirmed|0 |1
Status|UNCONFIRMED |NEW
Last reconfirmed| |2024-01-11
--- Comment #5 from H.J. Lu <hjl.tools at gmail dot com> ---
There is no_caller_saved_registers attribute. We can add
no_callee_saved_registers attribute.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug target/103503] RFE: no save registers attribute
2021-11-30 18:06 [Bug target/103503] New: RFE: no save registers attribute hpa at zytor dot com
` (5 preceding siblings ...)
2024-01-11 3:44 ` hjl.tools at gmail dot com
@ 2024-01-27 12:19 ` cvs-commit at gcc dot gnu.org
2024-05-15 16:17 ` hpa at zytor dot com
7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-01-27 12:19 UTC (permalink / raw)
To: gcc-bugs
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.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug target/103503] RFE: no save registers attribute
2021-11-30 18:06 [Bug target/103503] New: RFE: no save registers attribute hpa at zytor dot com
` (6 preceding siblings ...)
2024-01-27 12:19 ` cvs-commit at gcc dot gnu.org
@ 2024-05-15 16:17 ` hpa at zytor dot com
7 siblings, 0 replies; 9+ messages in thread
From: hpa at zytor dot com @ 2024-05-15 16:17 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103503
--- Comment #7 from H. Peter Anvin <hpa at zytor dot com> ---
Note: this is now implemented for x86, but it affects other targets as well.
^ permalink raw reply [flat|nested] 9+ messages in thread