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.
---
 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 15913d8d6b1..adb9740a4d9 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 bb2d36e0e0a..5fbc3981194 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 452c398f92c..98c8172a9d7 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);
 }
-- 
2.43.0

Reply via email to