diff mbox series

[testsuite] Add dg-require-stack-size

Message ID 50f58c99-a635-6aa1-7b6f-cccd990db8ab@mentor.com
State New
Headers show
Series [testsuite] Add dg-require-stack-size | expand

Commit Message

Tom de Vries Oct. 16, 2017, 10:16 a.m. UTC
Hi,

I noticed gcc.dg/tree-ssa/ldist-27.c failing for nvptx due to a too 
large stack size.

I started updating the testcase using "dg-add-options stack_size", but 
came across dg-require-support and realized I could make a 
dg-require-stack-size directive with an argument, and use that instead.

With the patch applied, the test still passes on x86_64, and by mocking 
up limited stack space like this:
...
...
it's listed as unsupported instead.

The info entry looks like:
...
'dg-require-stack-size SIZE'
      Skip the test if the target does not support a stack size of SIZE.
...

OK for trunk?

Thanks,
- Tom

Comments

Mike Stump Oct. 17, 2017, 4:14 p.m. UTC | #1
On Oct 16, 2017, at 3:16 AM, Tom de Vries <Tom_deVries@mentor.com> wrote:
> 
> I noticed gcc.dg/tree-ssa/ldist-27.c failing for nvptx due to a too large stack size.

> OK for trunk?

Hum.  There is an existing mechanism (find-grep STACK_SIZE) in the tree to handle the same issue.  Did you consider using it?

I think I like the, trim the test case down solution better and STACK_SIZE can drive that.  Maybe a tree-saa person to weigh in on the test case.

But, if the optimization pass likes large things, certainly the patch is Ok.
Tom de Vries Oct. 18, 2017, 9:37 a.m. UTC | #2
On 10/17/2017 06:14 PM, Mike Stump wrote:
> On Oct 16, 2017, at 3:16 AM, Tom de Vries <Tom_deVries@mentor.com> wrote:
>>
>> I noticed gcc.dg/tree-ssa/ldist-27.c failing for nvptx due to a too large stack size.
> 
>> OK for trunk?
> 
> Hum.  There is an existing mechanism (find-grep STACK_SIZE) in the tree to handle the same issue.  Did you consider using it?

Yes (As I mentioned, I considered using dg-add-options stack_size, which 
sets STACK_SIZE).

> 
> I think I like the, trim the test case down solution better and STACK_SIZE can drive that.  Maybe a tree-saa person to weigh in on the test case.
> 

I see. I dropped the test-case from this version of the patch.

> But, if the optimization pass likes large things, certainly the patch is Ok.
> 

I've used the new directive on existing test-cases that use STACK_SIZE 
but do no trimming, replacing f.i.:
...
#define STACK_REQUIREMENT (40000 * 4 + 256)
#if defined (STACK_SIZE) && STACK_SIZE < STACK_REQUIREMENT
main () { exit (0); }
#else
/* program */
#endif
...
with:
...
/* { dg-require-stack-size "40000 * 4 + 256" } */

/* program */
...

I'll commit after testing, unless there are further objections.

Thanks,
- Tom
Add dg-require-stack-size

2017-10-16  Tom de Vries  <tom@codesourcery.com>

	* lib/target-supports-dg.exp (dg-require-stack-size): New proc.
	* gcc.c-torture/execute/20030209-1.c: Use dg-require-stack-size.
	* gcc.c-torture/execute/20040805-1.c: Same.
	* gcc.c-torture/execute/920410-1.c: Same.
	* gcc.c-torture/execute/921113-1.c: Same.
	* gcc.c-torture/execute/921208-2.c: Same.
	* gcc.c-torture/execute/comp-goto-1.c: Same.
	* gcc.c-torture/execute/pr20621-1.c: Same.
	* gcc.c-torture/execute/pr28982b.c: Same.
	* gcc.dg/tree-prof/comp-goto-1.c: Same.

	* doc/sourcebuild.texi (Test Directives, Variants of
	dg-require-support): Add dg-require-stack-size.

---
 gcc/doc/sourcebuild.texi                          |  3 +++
 gcc/testsuite/gcc.c-torture/execute/20030209-1.c  | 16 +---------------
 gcc/testsuite/gcc.c-torture/execute/20040805-1.c  |  4 ++--
 gcc/testsuite/gcc.c-torture/execute/920410-1.c    |  8 ++------
 gcc/testsuite/gcc.c-torture/execute/921113-1.c    |  8 +-------
 gcc/testsuite/gcc.c-torture/execute/921208-2.c    |  9 +--------
 gcc/testsuite/gcc.c-torture/execute/comp-goto-1.c |  4 ++--
 gcc/testsuite/gcc.c-torture/execute/pr20621-1.c   |  7 ++-----
 gcc/testsuite/gcc.c-torture/execute/pr28982b.c    |  6 +-----
 gcc/testsuite/gcc.dg/tree-prof/comp-goto-1.c      |  4 ++--
 gcc/testsuite/lib/target-supports-dg.exp          | 15 +++++++++++++++
 11 files changed, 32 insertions(+), 52 deletions(-)

diff --git a/gcc/doc/sourcebuild.texi b/gcc/doc/sourcebuild.texi
index a2f0429..7d6d4a3 100644
--- a/gcc/doc/sourcebuild.texi
+++ b/gcc/doc/sourcebuild.texi
@@ -2358,6 +2358,9 @@ Skip the test if the target does not support the @code{-fstack-check}
 option.  If @var{check} is @code{""}, support for @code{-fstack-check}
 is checked, for @code{-fstack-check=("@var{check}")} otherwise.
 
+@item dg-require-stack-size @var{size}
+Skip the test if the target does not support a stack size of @var{size}.
+
 @item dg-require-visibility @var{vis}
 Skip the test if the target does not support the @code{visibility} attribute.
 If @var{vis} is @code{""}, support for @code{visibility("hidden")} is
diff --git a/gcc/testsuite/gcc.c-torture/execute/20030209-1.c b/gcc/testsuite/gcc.c-torture/execute/20030209-1.c
index 8f076ec..52f71ec 100644
--- a/gcc/testsuite/gcc.c-torture/execute/20030209-1.c
+++ b/gcc/testsuite/gcc.c-torture/execute/20030209-1.c
@@ -1,12 +1,5 @@
-/* { dg-add-options stack_size } */
+/* { dg-require-stack-size "8*100*100" } */
 
-#ifdef STACK_SIZE
-#if STACK_SIZE < 8*100*100
-#define SKIP
-#endif
-#endif
-
-#ifndef SKIP
 double x[100][100];
 int main ()
 {
@@ -18,10 +11,3 @@ int main ()
     abort ();
   exit (0);
 }
-#else
-int
-main ()
-{
-  exit (0);
-}
-#endif
diff --git a/gcc/testsuite/gcc.c-torture/execute/20040805-1.c b/gcc/testsuite/gcc.c-torture/execute/20040805-1.c
index d3208d6..f311092 100644
--- a/gcc/testsuite/gcc.c-torture/execute/20040805-1.c
+++ b/gcc/testsuite/gcc.c-torture/execute/20040805-1.c
@@ -1,6 +1,6 @@
-/* { dg-add-options stack_size } */
+/* { dg-require-stack-size "0x12000" } */
 
-#if __INT_MAX__ < 32768 || (defined(STACK_SIZE) && STACK_SIZE < 0x12000)
+#if __INT_MAX__ < 32768
 int main () { exit (0); }
 #else
 int a[2] = { 2, 3 };
diff --git a/gcc/testsuite/gcc.c-torture/execute/920410-1.c b/gcc/testsuite/gcc.c-torture/execute/920410-1.c
index 44a72bd..daeff5e 100644
--- a/gcc/testsuite/gcc.c-torture/execute/920410-1.c
+++ b/gcc/testsuite/gcc.c-torture/execute/920410-1.c
@@ -1,8 +1,4 @@
-/* { dg-add-options stack_size } */
+/* { dg-require-stack-size "40000 * 4 + 256" } */
 
-#define STACK_REQUIREMENT (40000 * 4 + 256)
-#if defined (STACK_SIZE) && STACK_SIZE < STACK_REQUIREMENT
-main () { exit (0); }
-#else
 main(){int d[40000];d[0]=0;exit(0);}
-#endif
+
diff --git a/gcc/testsuite/gcc.c-torture/execute/921113-1.c b/gcc/testsuite/gcc.c-torture/execute/921113-1.c
index d3e44e3..824e69f 100644
--- a/gcc/testsuite/gcc.c-torture/execute/921113-1.c
+++ b/gcc/testsuite/gcc.c-torture/execute/921113-1.c
@@ -1,9 +1,4 @@
-/* { dg-add-options stack_size } */
-
-#define STACK_REQUIREMENT (128 * 128 * 4 + 1024)
-#if defined (STACK_SIZE) && STACK_SIZE < STACK_REQUIREMENT
-main () { exit (0); }
-#else
+/* { dg-require-stack-size "128 * 128 * 4 + 1024" } */
 
 typedef struct {
   float wsx;
@@ -62,4 +57,3 @@ main()
   exit(0);
 }
 
-#endif
diff --git a/gcc/testsuite/gcc.c-torture/execute/921208-2.c b/gcc/testsuite/gcc.c-torture/execute/921208-2.c
index da9ee52..01e14f8 100644
--- a/gcc/testsuite/gcc.c-torture/execute/921208-2.c
+++ b/gcc/testsuite/gcc.c-torture/execute/921208-2.c
@@ -1,10 +1,5 @@
 /* { dg-require-effective-target untyped_assembly } */
-/* { dg-add-options stack_size } */
-
-#define STACK_REQUIREMENT (100000 * 4 + 1024)
-#if defined (STACK_SIZE) && STACK_SIZE < STACK_REQUIREMENT
-main () { exit (0); }
-#else
+/* { dg-require-stack-size "100000 * 4 + 1024" } */
 
 g(){}
 
@@ -25,5 +20,3 @@ main ()
   f();
   exit(0);
 }
-
-#endif
diff --git a/gcc/testsuite/gcc.c-torture/execute/comp-goto-1.c b/gcc/testsuite/gcc.c-torture/execute/comp-goto-1.c
index 2a84052..4379fe7 100644
--- a/gcc/testsuite/gcc.c-torture/execute/comp-goto-1.c
+++ b/gcc/testsuite/gcc.c-torture/execute/comp-goto-1.c
@@ -1,9 +1,9 @@
 /* { dg-require-effective-target label_values } */
-/* { dg-add-options stack_size } */
+/* { dg-require-stack-size "4000" } */
 
 #include <stdlib.h>
 
-#if (!defined(STACK_SIZE) || STACK_SIZE >= 4000) && __INT_MAX__ >= 2147483647
+#if __INT_MAX__ >= 2147483647
 typedef unsigned int uint32;
 typedef signed int sint32;
 
diff --git a/gcc/testsuite/gcc.c-torture/execute/pr20621-1.c b/gcc/testsuite/gcc.c-torture/execute/pr20621-1.c
index 9d0119b..b2a9785 100644
--- a/gcc/testsuite/gcc.c-torture/execute/pr20621-1.c
+++ b/gcc/testsuite/gcc.c-torture/execute/pr20621-1.c
@@ -1,12 +1,9 @@
-/* { dg-add-options stack_size } */
+/* { dg-require-stack-size "0x10000" } */
 
 /* When generating o32 MIPS PIC, main's $gp save slot was out of range
    of a single load instruction.  */
 struct big { int i[sizeof (int) >= 4 && sizeof (void *) >= 4 ? 0x4000 : 4]; };
 struct big gb;
 int foo (struct big b, int x) { return b.i[x]; }
-#if defined(STACK_SIZE) && STACK_SIZE <= 0x10000
-int main (void) { return 0; }
-#else
 int main (void) { return foo (gb, 0) + foo (gb, 1); }
-#endif
+
diff --git a/gcc/testsuite/gcc.c-torture/execute/pr28982b.c b/gcc/testsuite/gcc.c-torture/execute/pr28982b.c
index f28425e..b68fa9a 100644
--- a/gcc/testsuite/gcc.c-torture/execute/pr28982b.c
+++ b/gcc/testsuite/gcc.c-torture/execute/pr28982b.c
@@ -1,11 +1,8 @@
-/* { dg-add-options stack_size } */
+/* { dg-require-stack-size "0x80100" } */
 
 /* Like pr28982a.c, but with the spill slots outside the range of
    a single sp-based load on ARM.  This test tests for cases where
    the addresses in the base and index reloads require further reloads.  */
-#if defined(STACK_SIZE) && STACK_SIZE <= 0x80100
-int main (void) { return 0; }
-#else
 #define NITER 4
 #define NVARS 20
 #define MULTI(X) \
@@ -57,4 +54,3 @@ main (void)
       return 1;
   return 0;
 }
-#endif
diff --git a/gcc/testsuite/gcc.dg/tree-prof/comp-goto-1.c b/gcc/testsuite/gcc.dg/tree-prof/comp-goto-1.c
index fe768f9..baed1e3 100644
--- a/gcc/testsuite/gcc.dg/tree-prof/comp-goto-1.c
+++ b/gcc/testsuite/gcc.dg/tree-prof/comp-goto-1.c
@@ -1,11 +1,11 @@
 /* { dg-require-effective-target freorder } */
 /* { dg-require-effective-target label_values } */
 /* { dg-options "-O2 -freorder-blocks-and-partition" } */
-/* { dg-add-options stack_size } */
+/* { dg-require-stack-size "4000" } */
 
 #include <stdlib.h>
 
-#if (!defined(STACK_SIZE) || STACK_SIZE >= 4000) && __INT_MAX__ >= 2147483647
+#if __INT_MAX__ >= 2147483647
 typedef unsigned int uint32;
 typedef signed int sint32;
 
diff --git a/gcc/testsuite/lib/target-supports-dg.exp b/gcc/testsuite/lib/target-supports-dg.exp
index d50d8b0..6080421f 100644
--- a/gcc/testsuite/lib/target-supports-dg.exp
+++ b/gcc/testsuite/lib/target-supports-dg.exp
@@ -180,6 +180,21 @@ proc dg-require-iconv { args } {
     }
 }
 
+# If this target does not have sufficient stack size, skip this test.
+
+proc dg-require-stack-size { args } {
+    if { ![is-effective-target stack_size] } {
+	return
+    }
+    
+    set stack_size [dg-effective-target-value stack_size]
+    set required [expr [lindex $args 1]]
+    if { $stack_size < $required } {
+	upvar dg-do-what dg-do-what
+        set dg-do-what [list [lindex ${dg-do-what} 0] "N" "P"]
+    }
+}
+
 # If this target does not support named sections skip this test.
 
 proc dg-require-named-sections { args } {
diff mbox series

Patch

Add dg-require-stack-size

2017-10-16  Tom de Vries  <tom@codesourcery.com>

	* gcc.dg/tree-ssa/ldist-27.c: Use dg-require-stack-size.
	* lib/target-supports-dg.exp (dg-require-stack-size): New proc.

	* doc/sourcebuild.texi (Test Directives, Variants of
	dg-require-support): Add dg-require-stack-size.

---
 gcc/doc/sourcebuild.texi                 |  3 +++
 gcc/testsuite/gcc.dg/tree-ssa/ldist-27.c |  1 +
 gcc/testsuite/lib/target-supports-dg.exp | 15 +++++++++++++++
 3 files changed, 19 insertions(+)

diff --git a/gcc/doc/sourcebuild.texi b/gcc/doc/sourcebuild.texi
index a2f0429..7d6d4a3 100644
--- a/gcc/doc/sourcebuild.texi
+++ b/gcc/doc/sourcebuild.texi
@@ -2358,6 +2358,9 @@  Skip the test if the target does not support the @code{-fstack-check}
 option.  If @var{check} is @code{""}, support for @code{-fstack-check}
 is checked, for @code{-fstack-check=("@var{check}")} otherwise.
 
+@item dg-require-stack-size @var{size}
+Skip the test if the target does not support a stack size of @var{size}.
+
 @item dg-require-visibility @var{vis}
 Skip the test if the target does not support the @code{visibility} attribute.
 If @var{vis} is @code{""}, support for @code{visibility("hidden")} is
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ldist-27.c b/gcc/testsuite/gcc.dg/tree-ssa/ldist-27.c
index 3580c65..dd0e705 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/ldist-27.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/ldist-27.c
@@ -1,5 +1,6 @@ 
 /* { dg-do run } */
 /* { dg-options "-O3 -ftree-loop-distribute-patterns -fdump-tree-ldist-details" } */
+/* { dg-require-stack-size "484000" } */
 
 #define M (300)
 #define N (200)
diff --git a/gcc/testsuite/lib/target-supports-dg.exp b/gcc/testsuite/lib/target-supports-dg.exp
index d50d8b0..999034c 100644
--- a/gcc/testsuite/lib/target-supports-dg.exp
+++ b/gcc/testsuite/lib/target-supports-dg.exp
@@ -180,6 +180,21 @@  proc dg-require-iconv { args } {
     }
 }
 
+# If this target does not have sufficient stack size, skip this test.
+
+proc dg-require-stack-size { args } {
+    if { ![is-effective-target stack_size] } {
+	return
+    }
+    
+    set stack_size [dg-effective-target-value stack_size]
+    set required [lindex $args 1]
+    if { $stack_size < $required } {
+	upvar dg-do-what dg-do-what
+        set dg-do-what [list [lindex ${dg-do-what} 0] "N" "P"]
+    }
+}
+
 # If this target does not support named sections skip this test.
 
 proc dg-require-named-sections { args } {