diff options
author | Yufeng Zhang <yufeng.zhang@arm.com> | 2014-06-24 16:33:45 +0000 |
---|---|---|
committer | Yufeng Zhang <yufeng@gcc.gnu.org> | 2014-06-24 16:33:45 +0000 |
commit | 84e0f57e35738500e44fd21753e31295d4700bfb (patch) | |
tree | c5373ab1c3e2da02d9311e1b630a245d97e29186 | |
parent | 3fa591d4b43316e7b7f8d46781793d96893d3374 (diff) | |
download | gcc-84e0f57e35738500e44fd21753e31295d4700bfb.zip gcc-84e0f57e35738500e44fd21753e31295d4700bfb.tar.gz gcc-84e0f57e35738500e44fd21753e31295d4700bfb.tar.bz2 |
Make the AAPCS64 function return tests more robust.
gcc/testsuite
* gcc.target/aarch64/aapcs64/abitest-2.h (saved_return_address): New
global variable.
(FUNC_VAL_CHECK): Update to call myfunc via the 'ret' instruction,
instead of calling sequentially in the C code.
* gcc.target/aarch64/aapcs64/abitest.S (LABEL_TEST_FUNC_RETURN): Store
saved_return_address to the stack frame where LR register was stored.
(saved_return_address): Declare weak.
From-SVN: r211954
-rw-r--r-- | gcc/testsuite/ChangeLog | 10 | ||||
-rw-r--r-- | gcc/testsuite/gcc.target/aarch64/aapcs64/abitest-2.h | 15 | ||||
-rw-r--r-- | gcc/testsuite/gcc.target/aarch64/aapcs64/abitest.S | 5 |
3 files changed, 29 insertions, 1 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index d42af0f..913a9a6 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,13 @@ +2014-06-24 Yufeng Zhang <yufeng.zhang@arm.com> + + * gcc.target/aarch64/aapcs64/abitest-2.h (saved_return_address): New + global variable. + (FUNC_VAL_CHECK): Update to call myfunc via the 'ret' instruction, + instead of calling sequentially in the C code. + * gcc.target/aarch64/aapcs64/abitest.S (LABEL_TEST_FUNC_RETURN): Store + saved_return_address to the stack frame where LR register was stored. + (saved_return_address): Declare weak. + 2014-06-24 Paolo Carlini <paolo.carlini@oracle.com> PR c++/33972 diff --git a/gcc/testsuite/gcc.target/aarch64/aapcs64/abitest-2.h b/gcc/testsuite/gcc.target/aarch64/aapcs64/abitest-2.h index c56e7cc..5749219 100644 --- a/gcc/testsuite/gcc.target/aarch64/aapcs64/abitest-2.h +++ b/gcc/testsuite/gcc.target/aarch64/aapcs64/abitest-2.h @@ -5,6 +5,7 @@ #include "validate_memory.h" void (*testfunc_ptr)(char* stack); +unsigned long long saved_return_address; /* Helper macros to generate function name. Example of the function name: func_return_val_1. */ @@ -71,6 +72,17 @@ __attribute__ ((noinline)) type FUNC_NAME (id) (int i, double d, type t) \ optimized away. Using i and d prevents \ warnings about unused parameters. \ */ \ + /* We save and set up the LR register in a way that essentially \ + inserts myfunc () between the return of this function and the \ + continuing execution of its caller. By doing this, myfunc () \ + can save and check the exact content of the registers that are \ + used for the function return value. \ + The previous approach of sequentially calling myfunc right after \ + this function does not guarantee myfunc see the exact register \ + content, as compiler may emit code in between the two calls, \ + especially during the -O0 codegen. */ \ + asm volatile ("mov %0, x30" : "=r" (saved_return_address)); \ + asm volatile ("mov x30, %0" : : "r" ((unsigned long long) myfunc)); \ return t; \ } #include TESTFILE @@ -84,7 +96,8 @@ __attribute__ ((noinline)) type FUNC_NAME (id) (int i, double d, type t) \ { \ testfunc_ptr = TEST_FUNC_NAME(id); \ FUNC_NAME(id) (0, 0.0, var); \ - myfunc (); \ + /* The above function implicitly calls myfunc () on its return, \ + and the execution resumes from here after myfunc () finishes. */\ } int main() diff --git a/gcc/testsuite/gcc.target/aarch64/aapcs64/abitest.S b/gcc/testsuite/gcc.target/aarch64/aapcs64/abitest.S index 86ce7be..68845fb 100644 --- a/gcc/testsuite/gcc.target/aarch64/aapcs64/abitest.S +++ b/gcc/testsuite/gcc.target/aarch64/aapcs64/abitest.S @@ -50,6 +50,10 @@ LABEL_TEST_FUNC_RETURN: add x9, x9, :lo12:testfunc_ptr ldr x9, [x9, #0] blr x9 // function return value test + adrp x9, saved_return_address + add x9, x9, :lo12:saved_return_address + ldr x9, [x9, #0] + str x9, [sp, #8] // Update the copy of LR reg saved on stack LABEL_RET: ldp x0, x30, [sp] mov sp, x0 @@ -57,3 +61,4 @@ LABEL_RET: .weak testfunc .weak testfunc_ptr +.weak saved_return_address |