[1v1/2,aarch64,testsuite] accept ldr after failed ira-remat

Message ID orh5x6x2cn.fsf@lxoliva.fsfla.org
State Dropped
Headers
Series sme/nonlocal_goto_* tests fail remat with PIE |

Commit Message

Alexandre Oliva Sept. 13, 2025, 7:01 a.m. UTC
  When -fPIE is enabled (by default), nonlocal_goto tests fail because
ira drops reg equivalences for function invariants such as stack
addresses, and then, instead of the expected add instructions, we get
ldr to restore the pseudo holding the address, as it ends up living in
a stack slot across a call.

Tested o aarch64-linux-gnu with --enable-default-pie.  Ok to install?


for  gcc/testsuite/ChangeLog

	* gcc.target/aarch64/sme/nonlocal_goto_1.c: Accept ldr.
	* gcc.target/aarch64/sme/nonlocal_goto_2.c: Likewise.
	* gcc.target/aarch64/sme/nonlocal_goto_3.c: Likewise.
---
 .../gcc.target/aarch64/sme/nonlocal_goto_1.c       |    2 +-
 .../gcc.target/aarch64/sme/nonlocal_goto_2.c       |    2 +-
 .../gcc.target/aarch64/sme/nonlocal_goto_3.c       |    2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
  

Comments

Tamar Christina Sept. 19, 2025, 5:38 a.m. UTC | #1
Hi Alexander,

> -----Original Message-----
> From: Alexandre Oliva <oliva@adacore.com>
> Sent: Saturday, September 13, 2025 8:02 AM
> To: gcc-patches@gcc.gnu.org
> Cc: Vladimir Makarov <vmakarov@redhat.com>; Rainer Orth <ro@CeBiTec.Uni-
> Bielefeld.DE>; Mike Stump <mikestump@comcast.net>; Richard Earnshaw
> <Richard.Earnshaw@arm.com>; Tamar Christina <Tamar.Christina@arm.com>;
> Kyrylo Tkachov <ktkachov@nvidia.com>
> Subject: [PATCH 1v1/2] [aarch64] [testsuite] accept ldr after failed ira-remat
> 
> 
> When -fPIE is enabled (by default), nonlocal_goto tests fail because
> ira drops reg equivalences for function invariants such as stack
> addresses, and then, instead of the expected add instructions, we get
> ldr to restore the pseudo holding the address, as it ends up living in
> a stack slot across a call.
> 
> Tested o aarch64-linux-gnu with --enable-default-pie.  Ok to install?
> 

I have a slight preference for this one so we still see if the PIE codegen
changes.

So OK.

Thanks,
Tamar

> 
> for  gcc/testsuite/ChangeLog
> 
> 	* gcc.target/aarch64/sme/nonlocal_goto_1.c: Accept ldr.
> 	* gcc.target/aarch64/sme/nonlocal_goto_2.c: Likewise.
> 	* gcc.target/aarch64/sme/nonlocal_goto_3.c: Likewise.
> ---
>  .../gcc.target/aarch64/sme/nonlocal_goto_1.c       |    2 +-
>  .../gcc.target/aarch64/sme/nonlocal_goto_2.c       |    2 +-
>  .../gcc.target/aarch64/sme/nonlocal_goto_3.c       |    2 +-
>  3 files changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/gcc/testsuite/gcc.target/aarch64/sme/nonlocal_goto_1.c
> b/gcc/testsuite/gcc.target/aarch64/sme/nonlocal_goto_1.c
> index 11578279b9287..de9702e744519 100644
> --- a/gcc/testsuite/gcc.target/aarch64/sme/nonlocal_goto_1.c
> +++ b/gcc/testsuite/gcc.target/aarch64/sme/nonlocal_goto_1.c
> @@ -17,7 +17,7 @@ void run(void (*)());
>  **	ldr	x16, \1
>  **	tbz	x16, 0, .*
>  **	smstart	sm
> -**	add	x0, .*
> +**	(add|ldr)	x0, .*
>  **	ldr	x16, \1
>  **	tbz	x16, 0, .*
>  **	smstop	sm
> diff --git a/gcc/testsuite/gcc.target/aarch64/sme/nonlocal_goto_2.c
> b/gcc/testsuite/gcc.target/aarch64/sme/nonlocal_goto_2.c
> index 37dbcbae1a4f8..598db3cad38dd 100644
> --- a/gcc/testsuite/gcc.target/aarch64/sme/nonlocal_goto_2.c
> +++ b/gcc/testsuite/gcc.target/aarch64/sme/nonlocal_goto_2.c
> @@ -9,7 +9,7 @@ void run(void (*)());
>  **	smstop	sm
>  **	bl	[^\n]*[cC]ache[^\n]*
>  **	smstart	sm
> -**	add	x0, .*
> +**	(add|ldr)	x0, .*
>  **	smstop	sm
>  **	bl	run
>  **	smstart	sm
> diff --git a/gcc/testsuite/gcc.target/aarch64/sme/nonlocal_goto_3.c
> b/gcc/testsuite/gcc.target/aarch64/sme/nonlocal_goto_3.c
> index ae661653f3028..9aedd088d7807 100644
> --- a/gcc/testsuite/gcc.target/aarch64/sme/nonlocal_goto_3.c
> +++ b/gcc/testsuite/gcc.target/aarch64/sme/nonlocal_goto_3.c
> @@ -11,7 +11,7 @@ void run(void (*)());
>  **	smstop	sm
>  **	bl	[^\n]*[cC]ache[^\n]*
>  **	smstart	sm
> -**	add	x0, .*
> +**	(add|ldr)	x0, .*
>  **	smstop	sm
>  **	bl	run
>  **	smstart	sm
> 
> --
> Alexandre Oliva, happy hacker            https://blog.lx.oliva.nom.br/
> Free Software Activist     FSFLA co-founder     GNU Toolchain Engineer
> More tolerance and less prejudice are key for inclusion and diversity.
> Excluding neuro-others for not behaving ""normal"" is *not* inclusive!
  
Alexandre Oliva Sept. 21, 2025, 3:54 p.m. UTC | #2
On Sep 19, 2025, Tamar Christina <Tamar.Christina@arm.com> wrote:

> I have a slight preference for this one so we still see if the PIE codegen
> changes.

Thanks.  With the RA change in, we don't have a need for the workarounds
any more, so I'm *not* planning to check them in.
  

Patch

diff --git a/gcc/testsuite/gcc.target/aarch64/sme/nonlocal_goto_1.c b/gcc/testsuite/gcc.target/aarch64/sme/nonlocal_goto_1.c
index 11578279b9287..de9702e744519 100644
--- a/gcc/testsuite/gcc.target/aarch64/sme/nonlocal_goto_1.c
+++ b/gcc/testsuite/gcc.target/aarch64/sme/nonlocal_goto_1.c
@@ -17,7 +17,7 @@  void run(void (*)());
 **	ldr	x16, \1
 **	tbz	x16, 0, .*
 **	smstart	sm
-**	add	x0, .*
+**	(add|ldr)	x0, .*
 **	ldr	x16, \1
 **	tbz	x16, 0, .*
 **	smstop	sm
diff --git a/gcc/testsuite/gcc.target/aarch64/sme/nonlocal_goto_2.c b/gcc/testsuite/gcc.target/aarch64/sme/nonlocal_goto_2.c
index 37dbcbae1a4f8..598db3cad38dd 100644
--- a/gcc/testsuite/gcc.target/aarch64/sme/nonlocal_goto_2.c
+++ b/gcc/testsuite/gcc.target/aarch64/sme/nonlocal_goto_2.c
@@ -9,7 +9,7 @@  void run(void (*)());
 **	smstop	sm
 **	bl	[^\n]*[cC]ache[^\n]*
 **	smstart	sm
-**	add	x0, .*
+**	(add|ldr)	x0, .*
 **	smstop	sm
 **	bl	run
 **	smstart	sm
diff --git a/gcc/testsuite/gcc.target/aarch64/sme/nonlocal_goto_3.c b/gcc/testsuite/gcc.target/aarch64/sme/nonlocal_goto_3.c
index ae661653f3028..9aedd088d7807 100644
--- a/gcc/testsuite/gcc.target/aarch64/sme/nonlocal_goto_3.c
+++ b/gcc/testsuite/gcc.target/aarch64/sme/nonlocal_goto_3.c
@@ -11,7 +11,7 @@  void run(void (*)());
 **	smstop	sm
 **	bl	[^\n]*[cC]ache[^\n]*
 **	smstart	sm
-**	add	x0, .*
+**	(add|ldr)	x0, .*
 **	smstop	sm
 **	bl	run
 **	smstart	sm