]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
arm: testsuite: Improve stability of tests for pr45701
authorRichard Earnshaw <rearnsha@arm.com>
Mon, 9 Mar 2026 14:42:38 +0000 (14:42 +0000)
committerRichard Earnshaw <rearnsha@arm.com>
Mon, 9 Mar 2026 16:41:22 +0000 (16:41 +0000)
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
gcc/testsuite/gcc.target/arm/pr45701-2.c
gcc/testsuite/gcc.target/arm/pr45701-3.c

index 15913d8d6b12af638819f7032c4832c0623ddd1f..adb9740a4d965b658486792c4123f318e51a4cee 100644 (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;
 }
+
index bb2d36e0e0ab9f5a90c935380d3666bf50f551c6..5fbc3981194e12097072a3912ef47cee41724c1d 100644 (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);
 }
index 452c398f92cd8f6b8b072fe083fcb4e7fde19d54..98c8172a9d7406f569f3171bec4289792fdaf7bc 100644 (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);
 }