[PATCH, GCC/ARM, 6/10] Clear GPRs inline when calling nscall function
authorMihail Ionescu <mihail.ionescu@arm.com>
Wed, 15 Jan 2020 11:31:35 +0000 (11:31 +0000)
committerMihail Ionescu <mihail.ionescu@arm.com>
Thu, 16 Jan 2020 15:11:42 +0000 (15:11 +0000)
commit2d924ca620387c371cd564c821682012b3c97481
tree868a0f4abd0b6729fc96bbdee94b70043c7d17b9
parent0b1c7b27a7ddd06d08689c2ae8c70113c54c42f4
[PATCH, GCC/ARM, 6/10] Clear GPRs inline when calling nscall function

Besides changing the set of registers that needs to be cleared inline,
this patch also generates the push and pop to save and restore
callee-saved registers without trusting the callee inline. To make the
code more future-proof, this (currently) Armv8.1-M specific behavior is
expressed in terms of clearing of callee-saved registers rather than
directly based on the targets.

The patch contains 1 subtlety:

Debug information is disabled for push and pop because the
REG_CFA_RESTORE notes used to describe popping of registers do not stack.
Instead, they just reset the debug state for the register to the one at
the beginning of the function, which is incorrect for a register that is
pushed twice (in prologue and before nonsecure call) and then popped for
the first time. In particular, this occasionally trips CFI note creation
code when there are two codepaths to the epilogue, one of which does not
go through the nonsecure call. Obviously this mean that debugging
between the push and pop is not reliable.

*** gcc/ChangeLog ***

2020-01-16  Mihail-Calin Ionescu  <mihail.ionescu@arm.com>
2020-01-16  Thomas Preud'homme  <thomas.preudhomme@arm.com>

* config/arm/arm.c (arm_emit_multi_reg_pop): Declare early.
(cmse_nonsecure_call_clear_caller_saved): Rename into ...
(cmse_nonsecure_call_inline_register_clear): This.  Save and clear
callee-saved GPRs as well as clear ip register before doing a nonsecure
call then restore callee-saved GPRs after it when targeting
Armv8.1-M Mainline.
(arm_reorg): Adapt to function rename.

*** gcc/testsuite/ChangeLog ***

2020-01-16  Mihail-Calin Ionescu  <mihail.ionescu@arm.com>
2020-01-16  Thomas Preud'homme  <thomas.preudhomme@arm.com>

* gcc.target/arm/cmse/cmse-1.c: Add check for PUSH and POP and update
CLRM check.
* gcc.target/arm/cmse/cmse-14.c: Likewise.
* gcc.target/arm/cmse/mainline/8_1m/bitfield-4.c: Likewise.
* gcc.target/arm/cmse/mainline/8_1m/bitfield-5.c: Likewise.
* gcc.target/arm/cmse/mainline/8_1m/bitfield-6.c: Likewise.
* gcc.target/arm/cmse/mainline/8_1m/bitfield-7.c: Likewise.
* gcc.target/arm/cmse/mainline/8_1m/bitfield-8.c: Likewise.
* gcc.target/arm/cmse/mainline/8_1m/bitfield-9.c: Likewise.
* gcc.target/arm/cmse/mainline/8_1m/bitfield-and-union.c: Likewise.
* gcc.target/arm/cmse/mainline/8_1m/hard-sp/cmse-13.c: Likewise.
* gcc.target/arm/cmse/mainline/8_1m/hard-sp/cmse-7.c: Likewise.
* gcc.target/arm/cmse/mainline/8_1m/hard-sp/cmse-8.c: Likewise.
* gcc.target/arm/cmse/mainline/8_1m/hard/cmse-13.c: Likewise.
* gcc.target/arm/cmse/mainline/8_1m/hard/cmse-7.c: Likewise.
* gcc.target/arm/cmse/mainline/8_1m/hard/cmse-8.c: Likewise.
* gcc.target/arm/cmse/mainline/8_1m/soft/cmse-13.c: Likewise.
* gcc.target/arm/cmse/mainline/8_1m/soft/cmse-7.c: Likewise.
* gcc.target/arm/cmse/mainline/8_1m/soft/cmse-8.c: Likewise.
* gcc.target/arm/cmse/mainline/8_1m/soft-sp/cmse-7.c: Likewise.
* gcc.target/arm/cmse/mainline/8_1m/soft-sp/cmse-8.c: Likewise.
* gcc.target/arm/cmse/mainline/8_1m/softfp/cmse-13.c: Likewise.
* gcc.target/arm/cmse/mainline/8_1m/softfp/cmse-7.c: Likewise.
* gcc.target/arm/cmse/mainline/8_1m/softfp/cmse-8.c: Likewise.
* gcc.target/arm/cmse/mainline/8_1m/softfp/union-1.c: Likewise.
* gcc.target/arm/cmse/mainline/8_1m/softfp/union-2.c: Likewise.
28 files changed:
gcc/ChangeLog
gcc/config/arm/arm.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/arm/cmse/cmse-1.c
gcc/testsuite/gcc.target/arm/cmse/cmse-14.c
gcc/testsuite/gcc.target/arm/cmse/mainline/8_1m/bitfield-4.c
gcc/testsuite/gcc.target/arm/cmse/mainline/8_1m/bitfield-5.c
gcc/testsuite/gcc.target/arm/cmse/mainline/8_1m/bitfield-6.c
gcc/testsuite/gcc.target/arm/cmse/mainline/8_1m/bitfield-7.c
gcc/testsuite/gcc.target/arm/cmse/mainline/8_1m/bitfield-8.c
gcc/testsuite/gcc.target/arm/cmse/mainline/8_1m/bitfield-9.c
gcc/testsuite/gcc.target/arm/cmse/mainline/8_1m/bitfield-and-union.c
gcc/testsuite/gcc.target/arm/cmse/mainline/8_1m/hard-sp/cmse-13.c
gcc/testsuite/gcc.target/arm/cmse/mainline/8_1m/hard-sp/cmse-7.c
gcc/testsuite/gcc.target/arm/cmse/mainline/8_1m/hard-sp/cmse-8.c
gcc/testsuite/gcc.target/arm/cmse/mainline/8_1m/hard/cmse-13.c
gcc/testsuite/gcc.target/arm/cmse/mainline/8_1m/hard/cmse-7.c
gcc/testsuite/gcc.target/arm/cmse/mainline/8_1m/hard/cmse-8.c
gcc/testsuite/gcc.target/arm/cmse/mainline/8_1m/soft/cmse-13.c
gcc/testsuite/gcc.target/arm/cmse/mainline/8_1m/soft/cmse-7.c
gcc/testsuite/gcc.target/arm/cmse/mainline/8_1m/soft/cmse-8.c
gcc/testsuite/gcc.target/arm/cmse/mainline/8_1m/softfp-sp/cmse-7.c
gcc/testsuite/gcc.target/arm/cmse/mainline/8_1m/softfp-sp/cmse-8.c
gcc/testsuite/gcc.target/arm/cmse/mainline/8_1m/softfp/cmse-13.c
gcc/testsuite/gcc.target/arm/cmse/mainline/8_1m/softfp/cmse-7.c
gcc/testsuite/gcc.target/arm/cmse/mainline/8_1m/softfp/cmse-8.c
gcc/testsuite/gcc.target/arm/cmse/mainline/8_1m/union-1.c
gcc/testsuite/gcc.target/arm/cmse/mainline/8_1m/union-2.c