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.
This commit is contained in:
Richard Earnshaw
2026-03-09 14:42:38 +00:00
parent 24d41d10f2
commit 11b4f8ca5c
3 changed files with 27 additions and 53 deletions

View File

@@ -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;
}

View File

@@ -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);
}

View File

@@ -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);
}