public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/92086] Provide way to avoid saving callee-saved registers in functions without callers
       [not found] <bug-92086-4@http.gcc.gnu.org/bugzilla/>
@ 2020-04-04  7:25 ` gdisirio at gmail dot com
  2020-04-04  7:31 ` pinskia at gcc dot gnu.org
  2022-04-21  1:02 ` mcarbone at vmware dot com
  2 siblings, 0 replies; 3+ messages in thread
From: gdisirio at gmail dot com @ 2020-04-04  7:25 UTC (permalink / raw)
  To: gcc-bugs

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

Giovanni Di Sirio <gdisirio at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |gdisirio at gmail dot com

--- Comment #8 from Giovanni Di Sirio <gdisirio at gmail dot com> ---
I would like to support the introduction of a "root" attribute, I can bring
several examples in embedded development where this would be beneficial:

1) Thread functions in an RTOS, callee-saved registers are just stealing
precious RAM for each thread.
2) Multiple main()-like functions in multi-core MCUs, each core has its own
entry function, saving registers is again wasting space.
3) Functions called by ASM veneers, for example ISR code called by a common ASM
entry-point.

Note that "naked" and "noreturn" attributes do not help in the above scenarios
for various reasons. I experienced all the above points while developing my
ChibiOS project.

I would suggest the following behavior:
- Root functions cannot be called by C code (warning).
- The "used" attribute is implicit for "root" functions.
- Parameters and return values would work as usual, just the callee-saved
registers stacking/unstacking is skipped.
- main() would have implicitly the "root" attribute.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug c/92086] Provide way to avoid saving callee-saved registers in functions without callers
       [not found] <bug-92086-4@http.gcc.gnu.org/bugzilla/>
  2020-04-04  7:25 ` [Bug c/92086] Provide way to avoid saving callee-saved registers in functions without callers gdisirio at gmail dot com
@ 2020-04-04  7:31 ` pinskia at gcc dot gnu.org
  2022-04-21  1:02 ` mcarbone at vmware dot com
  2 siblings, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2020-04-04  7:31 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #9 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Segher Boessenkool from comment #7)
> This is related to the compiler saving the return address for noreturn
> sibcalls, like in
> 
>   void g(void) __attribute__((noreturn));
>   void f(void) { g(); }
> 
> Maybe we should have an option like "-fimprove-debugging-experience" that
> defaults to true only for -O0 and -Og (and maybe -O1)?

This was discussed in PR 10837.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug c/92086] Provide way to avoid saving callee-saved registers in functions without callers
       [not found] <bug-92086-4@http.gcc.gnu.org/bugzilla/>
  2020-04-04  7:25 ` [Bug c/92086] Provide way to avoid saving callee-saved registers in functions without callers gdisirio at gmail dot com
  2020-04-04  7:31 ` pinskia at gcc dot gnu.org
@ 2022-04-21  1:02 ` mcarbone at vmware dot com
  2 siblings, 0 replies; 3+ messages in thread
From: mcarbone at vmware dot com @ 2022-04-21  1:02 UTC (permalink / raw)
  To: gcc-bugs

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

Martim Carbone <mcarbone at vmware dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mcarbone at vmware dot com

--- Comment #10 from Martim Carbone <mcarbone at vmware dot com> ---
Another example where the proposed optimization would make sense is a
hypervisor's VM-exit handler. This is the entry point for guest-to-hypervisor
mode transitions, and is often implemented by having an asm preamble call a
noreturn C function that handles the exit and then directly resumes the guest.
Saving callee-saved registers in this function just adds unnecessary overhead
to a very hot path.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-04-21  1:02 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-92086-4@http.gcc.gnu.org/bugzilla/>
2020-04-04  7:25 ` [Bug c/92086] Provide way to avoid saving callee-saved registers in functions without callers gdisirio at gmail dot com
2020-04-04  7:31 ` pinskia at gcc dot gnu.org
2022-04-21  1:02 ` mcarbone at vmware dot com

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).