[clang] [llvm] [clang][llvm][PPC] Implement NoCallerSavedRegs attribute (PR #174320)

Eli Friedman via cfe-commits cfe-commits at lists.llvm.org
Wed Jan 7 14:20:57 PST 2026


================
@@ -6007,10 +6007,13 @@ The user can call functions specified with the 'no_caller_saved_registers'
 attribute from an interrupt handler without saving and restoring all
 call-clobbered registers.
 
-Functions specified with the 'no_caller_saved_registers' attribute should only
+On X86, functions specified with the 'no_caller_saved_registers' attribute should only
 call other functions with the 'no_caller_saved_registers' attribute, or should be
 compiled with the '-mgeneral-regs-only' flag to avoid saving unused non-GPR registers.
 
+On PowerPC, functions specified with the 'no_caller_saved_registers' attribute may not
+return a value as the return register will be restored and thus cannot hold a value.
----------------
efriedma-quic wrote:

The way preserve_most/preserve_all works on x86 is that the function definition preserves the value or RAX if and only if it's not used to pass or return values.  So a `void(void)` function preserves RAX, but an `int(void) function doesn't.

https://github.com/llvm/llvm-project/pull/174320


More information about the cfe-commits mailing list