]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
caller_save_regs: Return the enabled registers
authorH.J. Lu <hjl.tools@gmail.com>
Fri, 15 May 2026 00:01:56 +0000 (08:01 +0800)
committerH.J. Lu <hjl.tools@gmail.com>
Fri, 15 May 2026 12:02:21 +0000 (20:02 +0800)
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 <hjl.tools@gmail.com>
gcc/function-abi.cc

index df1d2e5765b80b66410ca0fbdf295076de559201..53a76dc2341dfb5f09b11136aed2a3926b183e4c 100644 (file)
@@ -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