https://gcc.gnu.org/g:11b4f8ca5cbff912ef0a5e28dfe9afebde4c2d51
commit r16-7961-g11b4f8ca5cbff912ef0a5e28dfe9afebde4c2d51 Author: Richard Earnshaw <[email protected]> Date: Mon Mar 9 14:42:38 2026 +0000 arm: testsuite: Improve stability of tests for pr45701 These tests have always been a bit flaky, but I noticed that they were often running with completely unsuitable options (eg expecting tailcalls to happen on Thumb1). So I took the opportunity while fixing that to improve their overall stability by removing most of the code that was trying to push up the register pressure and replacing it with a simple asm statement. Doing this has the added advantage that it removes the issues that -mpure-code can cause since the test no-longer needs to access global variables. gcc/testsuite/ChangeLog: * gcc.target/arm/pr45701-1.c: Rework test to avoid global variables. Require arm_arch_v7a_thumb as the effective target. * gcc.target/arm/pr45701-2.c: Likewise. * gcc.target/arm/pr45701-3.c: Likewise. Diff: --- gcc/testsuite/gcc.target/arm/pr45701-1.c | 26 +++++++++----------------- gcc/testsuite/gcc.target/arm/pr45701-2.c | 28 +++++++++------------------- gcc/testsuite/gcc.target/arm/pr45701-3.c | 26 +++++++++----------------- 3 files changed, 27 insertions(+), 53 deletions(-) diff --git a/gcc/testsuite/gcc.target/arm/pr45701-1.c b/gcc/testsuite/gcc.target/arm/pr45701-1.c index 15913d8d6b12..adb9740a4d96 100644 --- a/gcc/testsuite/gcc.target/arm/pr45701-1.c +++ b/gcc/testsuite/gcc.target/arm/pr45701-1.c @@ -1,26 +1,18 @@ -/* { dg-do compile } */ -/* { dg-skip-if "" { ! { arm_thumb1_ok || arm_thumb2_ok } } } */ -/* { dg-options "-mthumb -Os" } */ -/* { dg-final { scan-assembler "push\t\{r3" { target { ! arm*-*-uclinuxfdpiceabi } } } } */ -/* { dg-final { scan-assembler-not "\[^\-e\]r8" { target { ! arm*-*-uclinuxfdpiceabi } } } } */ +/* { dg-require-effective-target arm_arch_v7a_thumb_ok } */ +/* { dg-options "-Os" } */ +/* { dg-add-options arm_arch_v7a_thumb } */ +/* { dg-final { scan-assembler "push\t\{r3" } } */ +/* { dg-final { scan-assembler-not "push\t.*r8" } } */ -extern int hist_verify; -extern int a1; extern char *pre_process_line (char*); -extern char* str_cpy (char*, char*); -extern int str_len (char*); -extern char* x_malloc (int); -#define savestring(x) (char *)str_cpy (x_malloc (1 + str_len (x)), (x)) +extern char* x_strdup (const char*); char * history_expand_line_internal (char* line) { char *new_line; - int old_verify; - int a = a1; - old_verify = hist_verify; - hist_verify = 0; new_line = pre_process_line (line); - hist_verify = old_verify + a; - return (new_line == line) ? savestring (line) : new_line; + asm ("nop": : :"r4","r5","r6"); + return (new_line == line) ? x_strdup (line) : new_line; } + diff --git a/gcc/testsuite/gcc.target/arm/pr45701-2.c b/gcc/testsuite/gcc.target/arm/pr45701-2.c index bb2d36e0e0ab..5fbc3981194e 100644 --- a/gcc/testsuite/gcc.target/arm/pr45701-2.c +++ b/gcc/testsuite/gcc.target/arm/pr45701-2.c @@ -1,28 +1,18 @@ -/* { dg-do compile } */ -/* { dg-skip-if "" { ! { arm_thumb1_ok || arm_thumb2_ok } } } */ -/* { dg-options "-mthumb -Os" } */ -/* { dg-final { scan-assembler "push\t\{r3" { target { ! arm*-*-uclinuxfdpiceabi } } } } */ -/* { dg-final { scan-assembler-not "\[^\-e\]r8" { target { ! arm*-*-uclinuxfdpiceabi } } } } */ +/* { dg-require-effective-target arm_arch_v7a_thumb_ok } */ +/* { dg-options "-Os" } */ +/* { dg-add-options arm_arch_v7a_thumb } */ +/* { dg-final { scan-assembler "push\t\{r3" } } */ +/* { dg-final { scan-assembler-not "push\t.*r8" } } */ -extern int hist_verify; -extern int a1; extern char *pre_process_line (char*); -extern char* savestring1 (char*, char*); -extern char* str_cpy (char*, char*); -extern int str_len (char*); -extern char* x_malloc (int); -#define savestring(x) (char *)str_cpy (x_malloc (1 + str_len (x)), (x)) - +extern char* x_strdup (const char*); +extern char* x_strdup2 (const char*, const char*); char * history_expand_line_internal (char* line) { char *new_line; - int old_verify; - int a = a1; - old_verify = hist_verify; - hist_verify = 0; new_line = pre_process_line (line); - hist_verify = old_verify + a; + asm ("nop": : :"r4","r5","r6"); /* Two tail calls here, but r3 is not used to pass values. */ - return (new_line == line) ? savestring (line) : savestring1 (new_line, line); + return (new_line == line) ? x_strdup (line) : x_strdup2 (new_line, line); } diff --git a/gcc/testsuite/gcc.target/arm/pr45701-3.c b/gcc/testsuite/gcc.target/arm/pr45701-3.c index 452c398f92cd..98c8172a9d74 100644 --- a/gcc/testsuite/gcc.target/arm/pr45701-3.c +++ b/gcc/testsuite/gcc.target/arm/pr45701-3.c @@ -1,28 +1,20 @@ -/* { dg-do compile } */ -/* { dg-require-effective-target arm_thumb2_ok } */ -/* { dg-options "-mthumb -Os" } */ +/* { dg-require-effective-target arm_arch_v7a_thumb_ok } */ +/* { dg-options "-Os" } */ +/* { dg-add-options arm_arch_v7a_thumb } */ /* { dg-final { scan-assembler "push\t.*r8" } } */ -/* { dg-final { scan-assembler-not "push\t*r3" } } */ +/* { dg-final { scan-assembler-not "push\t.*r3" } } */ -extern int hist_verify; extern char *pre_process_line (char*); -extern char* savestring1 (char*, char*, int, int); -extern char* str_cpy (char*, char*); -extern int str_len (char*); -extern char* x_malloc (int); -#define savestring(x) (char *)str_cpy (x_malloc (1 + str_len (x)), (x)) +extern char* x_strdup (const char*); +extern char* x_strdup2 (const char*, const char*, int, int); char * history_expand_line_internal (char* line) { char *new_line; - int old_verify; - - old_verify = hist_verify; - hist_verify = 0; new_line = pre_process_line (line); - hist_verify = old_verify; + asm ("nop": : :"r4","r5","r6"); /* Two tail calls here, but r3 is used to pass values. */ - return (new_line == line) ? savestring (line) : - savestring1 (new_line, line, 0, old_verify+1); + return (new_line == line) ? x_strdup (line) : + x_strdup2 (new_line, line, 0, 1); }
