Since the caller can save a register only if the register is enabled in the caller, change caller_save_regs to return the enabled registers.
PR rtl-optimization/125321 * function-abi.cc (function_abi_aggregator::caller_save_regs): Return the enabled registers. Signed-off-by: H.J. Lu <[email protected]> Co-Authored by: Richard Sandiford <[email protected]> -- H.J.
From 30d23f5416a46d0d19a21ae98d983bf97e2aa76e Mon Sep 17 00:00:00 2001 From: "H.J. Lu" <[email protected]> Date: Fri, 15 May 2026 08:01:56 +0800 Subject: [PATCH v2] caller_save_regs: Return the enabled registers Since the caller can save a register only if the register is enabled in the caller, change caller_save_regs to return the enabled registers. PR rtl-optimization/125321 * function-abi.cc (function_abi_aggregator::caller_save_regs): Return the enabled registers. Signed-off-by: H.J. Lu <[email protected]> Co-Authored by: Richard Sandiford <[email protected]> --- gcc/function-abi.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/gcc/function-abi.cc b/gcc/function-abi.cc index df1d2e5765b..53a76dc2341 100644 --- a/gcc/function-abi.cc +++ b/gcc/function-abi.cc @@ -159,7 +159,10 @@ caller_save_regs (const function_abi &caller_abi) const clobbers for (e.g. taking -fipa-ra into account). */ result |= (extra_clobbers & m_abi_clobbers[abi_id]); } - return result; + + /* The caller can save a register only if the register is enabled in + the caller. */ + return result & accessible_reg_set; } /* Return the set of registers that cannot be used to hold a value of -- 2.54.0
