https://gcc.gnu.org/g:5958e61d12f21cead59e6cdaa592ac648e6f6add

commit r17-1365-g5958e61d12f21cead59e6cdaa592ac648e6f6add
Author: Andrew Pinski <[email protected]>
Date:   Fri Jun 5 00:43:28 2026 -0700

    Fix EXECUTE_IF_SET_IN_HARD_REG_SET usage in rtl-ssa/insns.cc [PR122992]
    
    r17-1279-gf6103f3a1e42fe had a mistake when converting over to use
    EXECUTE_IF_SET_IN_HARD_REG_SET. EXECUTE_IF_SET_IN_HARD_REG_SET does not work
    with a temporary as that temporary lifetime will end after the 
initialization
    part of the for loop ends. So the variable becomes garbage or in some cases
    GCC will delete the needed stores.
    The fix is to create a variable to extend the liftime of that temporary and
    pass that to EXECUTE_IF_SET_IN_HARD_REG_SET.
    
    Pushed as obvious after a bootstrap on aarch64-linux-gnu which was failing 
before.
    
            PR rtl-optimization/125609
            PR middle-end/122992
    gcc/ChangeLog:
    
            * rtl-ssa/insns.cc (function_info::record_call_clobbers): Use a
            variable to store out the result of abi.full_reg_clobbers().
    
    Signed-off-by: Andrew Pinski <[email protected]>

Diff:
---
 gcc/rtl-ssa/insns.cc | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/gcc/rtl-ssa/insns.cc b/gcc/rtl-ssa/insns.cc
index fbd1fd9634ad..64bb0f931ae3 100644
--- a/gcc/rtl-ssa/insns.cc
+++ b/gcc/rtl-ssa/insns.cc
@@ -631,7 +631,8 @@ function_info::record_call_clobbers (build_info &bi, 
insn_info *insn,
     {
       hard_reg_set_iterator hrsi;
       unsigned int regno = 0;
-      EXECUTE_IF_SET_IN_HARD_REG_SET (abi.full_reg_clobbers (), 0, regno, hrsi)
+      HARD_REG_SET full_reg_clobbers = abi.full_reg_clobbers ();
+      EXECUTE_IF_SET_IN_HARD_REG_SET (full_reg_clobbers, 0, regno, hrsi)
        {
          def_info *def = m_defs[regno + 1];
          if (!def || def->last_def ()->insn () != insn)

Reply via email to