This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH, testsuite] Add dg-require-stack-size


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:
...
diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp
index 4f9bf46..cafea26 100644
--- a/gcc/testsuite/lib/target-supports.exp
+++ b/gcc/testsuite/lib/target-supports.exp
@@ -511,6 +511,7 @@ proc check_effective_target_trampolines { } {
 # Return 1 if target has limited stack size.

 proc check_effective_target_stack_size { } {
+    return 1
     if [target_info exists gcc,stack_size] {
        return 1
     }
@@ -522,6 +523,7 @@ proc check_effective_target_stack_size { } {
 proc dg-effective-target-value { effective_target } {
     if { "$effective_target" == "stack_size" } {
        if [check_effective_target_stack_size] {
+           return 8192
            return [target_info gcc,stack_size]
        }
     }
...
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
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 } {

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]