aarch64: Fix aapcs64 testsuite failures
authorRichard Sandiford <richard.sandiford@arm.com>
Tue, 24 Nov 2020 15:01:45 +0000 (15:01 +0000)
committerRichard Sandiford <richard.sandiford@arm.com>
Tue, 24 Nov 2020 15:01:45 +0000 (15:01 +0000)
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
testfunc_ptr.

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”.

gcc/testsuite/
* 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
gcc/testsuite/gcc.target/aarch64/aapcs64/abitest.h

index 5749219..b917938 100644 (file)
@@ -66,7 +66,7 @@ MYFUNCTYPE myfunc () PCSATTR;
    of bugs like a short vector being returned in X0 after copied from V0.  */
 #undef FUNC_VAL_CHECK
 #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 \
index af70937..667f4d0 100644 (file)
@@ -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)