]> git.ipfire.org Git - thirdparty/gcc.git/commit
arm: Fix CMSE nonecure calls [PR 120977]
authorChristophe Lyon <christophe.lyon@linaro.org>
Tue, 8 Jul 2025 08:08:21 +0000 (08:08 +0000)
committerChristophe Lyon <christophe.lyon@linaro.org>
Fri, 8 Aug 2025 14:20:18 +0000 (14:20 +0000)
commited520bfcf4b2e0879849706dcbf707f9f3ff9da2
treec203b171cd247044abfb431713365a40e4ef1677
parentaa1e7dd6a354da428e23bd5e528a8a0f744e7351
arm: Fix CMSE nonecure calls [PR 120977]

As discussed in https://gcc.gnu.org/pipermail/gcc-patches/2025-June/685733.html
the operand of the call should be a mem rather than an unspec.

This patch moves the unspec to an additional argument of the parallel
and adjusts cmse_nonsecure_call_inline_register_clear accordingly.

The scan-rtl-dump in cmse-18.c needs a fix since we no longer emit the
'unspec' part.

In addition, I noticed that since arm_v8_1m_mve_ok is always true in
the context of the test (we know we support CMSE as per cmse.exp, and
arm_v8_1m_mve_ok finds the adequate options), we actually only use the
more permissive regex.  To improve that, the patch duplicates the
test, such that cmse-18.c forces -march=armv8-m.main+fp (so FPCXP is
disabled), and cmse-19.c forces -march=armv8.1-m.main+mve (so FPCXP is
enabled).  Each test uses the appropriate scan-rtl-dump, and also
checks we are using UNSPEC_NONSECURE_MEM (we need to remove -slim for
that).  The tests enable an FPU via -march so that the test passes
whether the testing harness forces -mfloat-abi or not.

2025-07-08  Christophe Lyon  <christophe.lyon@linaro.org>

PR target/120977
gcc/
* config/arm/arm.md (call): Move unspec parameter to parallel.
(nonsecure_call_internal): Likewise.
(call_value): Likewise.
(nonsecure_call_value_internal): Likewise.
* config/arm/thumb1.md (nonsecure_call_reg_thumb1_v5): Likewise.
(nonsecure_call_value_reg_thumb1_v5): Likewise.
* config/arm/thumb2.md (nonsecure_call_reg_thumb2_fpcxt):
Likewise.
(nonsecure_call_reg_thumb2): Likewise.
(nonsecure_call_value_reg_thumb2_fpcxt): Likewise.
(nonsecure_call_value_reg_thumb2): Likewise.
* config/arm/arm.cc (cmse_nonsecure_call_inline_register_clear):
Likewise.

gcc/testsuite
* gcc.target/arm/cmse/cmse-18.c: Check only the case when FPCXT is
not enabled.
* gcc.target/arm/cmse/cmse-19.c: New test.
gcc/config/arm/arm.cc
gcc/config/arm/arm.md
gcc/config/arm/thumb1.md
gcc/config/arm/thumb2.md
gcc/testsuite/gcc.target/arm/cmse/cmse-18.c
gcc/testsuite/gcc.target/arm/cmse/cmse-19.c [new file with mode: 0644]