Hi, While checking Martin's fix for PR ipa/94445, he made me realize that the cmse-15.c testcase still fails at -Os because ICF means that we generate nonsecure2: b nonsecure0
which is OK, but does not match the currently expected nonsecure2: ... bl __gnu_cmse_nonsecure_call (see https://gcc.gnu.org/pipermail/gcc-patches/2020-April/543190.html) The test has already different expectations for v8-M and v8.1-M. I've decided to try to use check-function-bodies to account for the different possibilities: - v8-M vs v8.1-M via two different prefixes - code generation variants (-0?) via multiple regexps I've tested that the test now passes with --target-board=-march=armv8-m.main and --target-board=-march=armv8.1-m.main. I feel this a bit too much of a burden for the purpose, maybe there's a better way of handling all these alternatives (in particular, there's a lot of duplication since the expected code for the secure* functions is the same for v8-M and v8.1-M). OK? Thanks, Christophe
diff --git a/gcc/testsuite/gcc.target/arm/cmse/cmse-15.c b/gcc/testsuite/gcc.target/arm/cmse/cmse-15.c index 0e37b50..603c456 100644 --- a/gcc/testsuite/gcc.target/arm/cmse/cmse-15.c +++ b/gcc/testsuite/gcc.target/arm/cmse/cmse-15.c @@ -1,5 +1,9 @@ /* { dg-do compile } */ /* { dg-options "-mcmse" } */ +/* ARMv8-M expectation. */ +/* { dg-final { check-function-bodies "*Noclear" "" "" { target { ! arm_cmse_clear_ok } } } } */ +/* ARMv8.1-M expectation. */ +/* { dg-final { check-function-bodies "*Clear" "" "" { target arm_cmse_clear_ok } } } */ int __attribute__ ((cmse_nonsecure_call)) (*ns_foo) (void); int (*s_bar) (void); @@ -11,67 +15,242 @@ typedef int s_bar_t (void); typedef int __attribute__ ((cmse_nonsecure_call)) (* ns_foo_ptr) (void); typedef int (*s_bar_ptr) (void); +/* +*Clear nonsecure0: +*Clear ... +*Clear blxns r[0-3] +*Clear ... +*Noclear nonsecure0: +*Noclear ... +*Noclear bl __gnu_cmse_nonsecure_call +*Noclear ... +*/ int nonsecure0 (ns_foo_t * ns_foo_p) { return ns_foo_p (); } +/* +*Clear nonsecure1: +*Clear ... +*Clear blxns r[0-3] +*Clear ... +*Noclear nonsecure1: +*Noclear ... +*Noclear bl __gnu_cmse_nonsecure_call +*Noclear ... +*/ int nonsecure1 (ns_foo_t ** ns_foo_p) { return (*ns_foo_p) (); } +/* +*Clear nonsecure2: +*Clear ... +*Clear ( +*Clear blxns r[0-3] +*Clear | +*Clear b nonsecure0 +*Clear ) +*Clear ... +*Noclear nonsecure2: +*Noclear ... +*Noclear ( +*Noclear bl __gnu_cmse_nonsecure_call +*Noclear | +*Noclear b nonsecure0 +*Noclear ) +*Noclear ... +*/ int nonsecure2 (ns_foo_ptr ns_foo_p) { return ns_foo_p (); } + +/* +*Clear nonsecure3: +*Clear ... +*Clear blxns r[0-3] +*Clear ... +*Noclear nonsecure3: +*Noclear ... +*Noclear bl __gnu_cmse_nonsecure_call +*Noclear ... +*/ int nonsecure3 (ns_foo_ptr * ns_foo_p) { return (*ns_foo_p) (); } +/* +*Clear secure0: +*Clear ... +*Clear ( +*Clear bx r[0-3] +*Clear | +*Clear blx r[0-3] +*Clear ) +*Clear ... +*Noclear secure0: +*Noclear ... +*Noclear ( +*Noclear bx r[0-3] +*Noclear | +*Noclear blx r[0-3] +*Noclear ) +*Noclear ... +*/ int secure0 (s_bar_t * s_bar_p) { return s_bar_p (); } +/* +*Clear secure1: +*Clear ... +*Clear ( +*Clear bx r[0-3] +*Clear | +*Clear blx r[0-3] +*Clear ) +*Clear ... +*Noclear secure1: +*Noclear ... +*Noclear ( +*Noclear bx r[0-3] +*Noclear | +*Noclear blx r[0-3] +*Noclear ) +*Noclear ... +*/ int secure1 (s_bar_t ** s_bar_p) { return (*s_bar_p) (); } +/* +*Clear secure2: +*Clear ... +*Clear ( +*Clear bx r[0-3] +*Clear | +*Clear blx r[0-3] +*Clear | +*Clear b secure0 +*Clear ) +*Clear ... +*Noclear secure2: +*Noclear ... +*Noclear ( +*Noclear bx r[0-3] +*Noclear | +*Noclear blx r[0-3] +*Noclear | +*Noclear b secure0 +*Noclear ) +*Noclear ... +*/ int secure2 (s_bar_ptr s_bar_p) { return s_bar_p (); } +/* +*Clear secure3: +*Clear ... +*Clear ( +*Clear bx r[0-3] +*Clear | +*Clear blx r[0-3] +*Clear ) +*Clear ... +*Noclear secure3: +*Noclear ... +*Noclear ( +*Noclear bx r[0-3] +*Noclear | +*Noclear blx r[0-3] +*Noclear ) +*Noclear ... +*/ int secure3 (s_bar_ptr * s_bar_p) { return (*s_bar_p) (); } +/* +*Clear nonsecure4: +*Clear ... +*Clear blxns r[0-3] +*Clear ... +*Noclear nonsecure4: +*Noclear ... +*Noclear bl __gnu_cmse_nonsecure_call +*Noclear ... +*/ int nonsecure4 (void) { return ns_foo (); } +/* +*Clear nonsecure5: +*Clear ... +*Clear blxns r[0-3] +*Clear ... +*Noclear nonsecure5: +*Noclear ... +*Noclear bl __gnu_cmse_nonsecure_call +*Noclear ... +*/ int nonsecure5 (void) { return (*ns_foo2) (); } +/* +*Clear secure4: +*Clear ... +*Clear ( +*Clear bx r[0-3] +*Clear | +*Clear blx r[0-3] +*Clear ) +*Clear ... +*Noclear secure4: +*Noclear ... +*Noclear ( +*Noclear bx r[0-3] +*Noclear | +*Noclear blx r[0-3] +*Noclear ) +*Noclear ... +*/ int secure4 (void) { return s_bar (); } +/* +*Clear secure5: +*Clear ... +*Clear ( +*Clear bx r[0-3] +*Clear | +*Clear blx r[0-3] +*Clear ) +*Clear ... +*Noclear secure5: +*Noclear ... +*Noclear ( +*Noclear bx r[0-3] +*Noclear | +*Noclear blx r[0-3] +*Noclear ) +*Noclear ... +*/ int secure5 (void) { return (*s_bar2) (); } - -/* ARMv8-M expectation. */ -/* { dg-final { scan-assembler-times "bl\\s+__gnu_cmse_nonsecure_call" 6 { target { ! arm_cmse_clear_ok } } } } */ - -/* ARMv8.1-M expectation. */ -/* { dg-final { scan-assembler-times "blxns" 6 { target arm_cmse_clear_ok } } } */
2020-04-06 Christophe Lyon <christophe.l...@linaro.org> gcc/testsuite/ * gcc.target/arm/cmse/cmse-15.c: Use check-function-bodies.