[2/2,ira] avoid resetting ira_reg_equiv for function invariants

Message ID or8qiix24c.fsf@lxoliva.fsfla.org
State New
Headers
Series None |

Commit Message

Alexandre Oliva Sept. 13, 2025, 7:06 a.m. UTC
  An aarch64 toolchain built with --enable-default-pie fails
gcc.target/aarch64/sme/nonlocal_goto_[123].c because the register
allocator ends up resetting equivalences, so it concludes it needs to
preserve a rematerializable function invariant across a call instead
of rematerializing it.

Allow function invariant equivalences to remain when the other
circumstances that may require their removal don't apply.

Tested on aarch64-linux-gnu with --enable-default-pie --enable-host-pie,
but I note this is not a complete fix for the problem, and I'm not
confident it's safe.  Does this look ok to install?


for  gcc/ChangeLog

	* ira.cc (setup_reg_equiv): Retain function invariant
	equivalences.
---
 gcc/ira.cc |    3 +++
 1 file changed, 3 insertions(+)
  

Patch

diff --git a/gcc/ira.cc b/gcc/ira.cc
index 4eebc9c4c50fb..79cf9a413cfb2 100644
--- a/gcc/ira.cc
+++ b/gcc/ira.cc
@@ -4278,6 +4278,9 @@  setup_reg_equiv (void)
 		    continue;
 		  }
 	      }
+	    else if (function_invariant_p (x))
+	      /* Leave ira_reg_equiv alone.  */
+	      continue;
 	  }
 	ira_reg_equiv[i].defined_p = false;
 	ira_reg_equiv[i].caller_save_p = false;