[committed] aarch64: Fix aapcs64 testsuite failures

Richard Sandiford richard.sandiford@arm.com
Tue Nov 24 15:04:52 GMT 2020

Various aapcs64 tests were failing at -O1 and above because
the assignments to testfunc_ptr were being deleted as dead.
That in turn happened because FUNC_VAL_CHECK hid the tail call
to myfunc using an LR asm trick:

    asm volatile ("mov %0, x30" : "=r" (saved_return_address));
    asm volatile ("mov x30, %0" : : "r" ((unsigned long long) myfunc));

and so the compiler couldn't see any calls that might read

That in itself could be fixed by adding a memory clobber to the
second asm above, forcing the compiler to keep both the testfunc_ptr
and the saved_return_address assignments.  But since this is an ABI
test, it seems better to make sure that we don't do any IPA at all.
The fact that doing IPA caused a problem was kind-of helpful and
so it might be better to avoid making the test “work” in the
presence of IPA.

The patch therefore just replaced “noinline” with “noipa”.

Tested on aarch64-linux-gnu and applied.


	* gcc.target/aarch64/aapcs64/abitest.h (FUNC_VAL_CHECK): Use
	noipa rather than noinline.
	* gcc.target/aarch64/aapcs64/abitest-2.h (FUNC_VAL_CHECK): Likewise.
 gcc/testsuite/gcc.target/aarch64/aapcs64/abitest-2.h | 2 +-
 gcc/testsuite/gcc.target/aarch64/aapcs64/abitest.h   | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/gcc/testsuite/gcc.target/aarch64/aapcs64/abitest-2.h b/gcc/testsuite/gcc.target/aarch64/aapcs64/abitest-2.h
index 57492197e5f..b917938884b 100644
--- a/gcc/testsuite/gcc.target/aarch64/aapcs64/abitest-2.h
+++ b/gcc/testsuite/gcc.target/aarch64/aapcs64/abitest-2.h
@@ -66,7 +66,7 @@ MYFUNCTYPE myfunc () PCSATTR;
    of bugs like a short vector being returned in X0 after copied from V0.  */
 #define FUNC_VAL_CHECK(id, type, var, offset, layout)			  \
-__attribute__ ((noinline)) type FUNC_NAME (id) (int i, double d, type t)  \
+__attribute__ ((noipa)) type FUNC_NAME (id) (int i, double d, type t)	  \
   {									  \
     asm (""::"r" (i),"r" (d)); /* asm prevents function from getting      \
 				  optimized away.  Using i and d prevents \
diff --git a/gcc/testsuite/gcc.target/aarch64/aapcs64/abitest.h b/gcc/testsuite/gcc.target/aarch64/aapcs64/abitest.h
index af70937e047..667f4d0f2dd 100644
--- a/gcc/testsuite/gcc.target/aarch64/aapcs64/abitest.h
+++ b/gcc/testsuite/gcc.target/aarch64/aapcs64/abitest.h
@@ -73,7 +73,7 @@ MYFUNCTYPE myfunc(
 /* Dummy function to help reset parameter passing registers, i.e. X0-X7
    and V0-V7 (by being passed 0 in W0-W7 and 0.f in S0-S7).  */
-__attribute__ ((noinline)) void
+__attribute__ ((noipa)) void
 dummy_func (int w0, int w1, int w2, int w3, int w4, int w5, int w6, int w7,
 	    float s0, float s1, float s2, float s3, float s4, float s5,
 	    float s6, float s7)

More information about the Gcc-patches mailing list