https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103503
Bug ID: 103503 Summary: RFE: no save registers attribute Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: hpa at zytor dot com Target Milestone: --- Target: multiple When a common assembly interrupt entry code or an equivalent hardware engine is used to handle register saves in an interrupt routine, it may be completely unnecessary to save and restore registers in the interrupt handler itself, even if they would normally be clobbered. Unfortunately [-f]call-used-reg is not supported by either __attribute__((optimize)) nor _Pragma("GCC optimize"); otherwise that would be a very valid solution. Putting all interrupt handlers in a separate compilation unit is awkward at the very best. AVR has __attribute__((OS_{task,main})) for this purpose, but being able to do it in general would improve interrupt/trap latency. See also bug 38534. Note: not saving the registers in the assembly wrapper is generally not an option; similarly, whether or not a hardware engine can do it practically depends on both the hardware implementation and the ABI. The RISC-V ABI, for example, scatters clobbered and saved registers all over the register map, which makes doing such a thing in hardware difficult.