Hi,

This patch resolves a conflict between the aapcs64 test framework for func-ret tests and the optimization option -fuse-caller-save, which was enabled by default at -O1 or above recently.

Basically, the test framework has an inline-assembly based mechanism in place which invokes the test facility function right on the return of a tested function. The compiler with -fuse-caller-save is unable to identify the unconventional call graph and carries out the optimization regardless.

Adding explicit LR clobbering field to the inline assembly doesn't solve the issue as the compiler would simply generate extra save/store of LR in the prologue/epilogue.

OK for the trunk?

Thanks,
Yufeng

gcc/testsuite/

        * gcc.target/aarch64/aapcs64/aapcs64.exp:
        (additional_flags_for_func_ret): New variable based on $additional_flags
        plus -fno-use-caller-save.
        (func-ret-*.c): Use the new variable.
diff --git a/gcc/testsuite/gcc.target/aarch64/aapcs64/aapcs64.exp 
b/gcc/testsuite/gcc.target/aarch64/aapcs64/aapcs64.exp
index 195f977..fdfbff1 100644
--- a/gcc/testsuite/gcc.target/aarch64/aapcs64/aapcs64.exp
+++ b/gcc/testsuite/gcc.target/aarch64/aapcs64/aapcs64.exp
@@ -48,11 +48,15 @@ foreach src [lsort [glob -nocomplain 
$srcdir/$subdir/va_arg-*.c]] {
 }
 
 # Test function return value.
+#   Disable -fuse-caller-save to prevent the compiler from generating
+#   conflicting code.
+set additional_flags_for_func_ret $additional_flags
+append additional_flags_for_func_ret " -fno-use-caller-save"
 foreach src [lsort [glob -nocomplain $srcdir/$subdir/func-ret-*.c]] {
     if {[runtest_file_p $runtests $src]} {
            c-torture-execute [list $src \
                                    $srcdir/$subdir/abitest.S] \
-                                   $additional_flags
+                                   $additional_flags_for_func_ret
     }
 }
 

Reply via email to