public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH, testsuite] Add effective target stack_size
@ 2017-06-09 14:24 Tom de Vries
  2017-06-09 15:25 ` Mike Stump
                   ` (2 more replies)
  0 siblings, 3 replies; 14+ messages in thread
From: Tom de Vries @ 2017-06-09 14:24 UTC (permalink / raw)
  To: GCC Patches; +Cc: Mike Stump, Rainer Orth

[-- Attachment #1: Type: text/plain, Size: 949 bytes --]

Hi,

this patch adds effective target stack_size.


Atm, -DSTACK_SIZE=<value> is defined at top-level in gcc_target_compile 
resulting in the macro being passed down to ~30k compilations. The macro 
is used in just 37 testcases.

The patch defines an effective target stack_size, which is used in 
individual test-cases to add -DSTACK_SIZE=<value> using:
- dg-additional-options, and
- a new directive dg-effective-target-value to get the value.


gccint.info (edited for long lines):
...
7.2.3.12 Other attributes
.........................

'stack_size'
      Target has limited stack size.  The stack size limit can be
      obtained using '[dg-effective-target-value stack_size]'.  For
      example:
           /* { dg-additional-options
	         "-DSTACK_SIZE=[dg-effective-target-value stack_size]"
                  { target { stack_size } } } */
...

Lightly tested sofar.

OK for trunk if x86_64 and nvptx testing succeeds?

Thanks,
- Tom

[-- Attachment #2: 0001-Add-effective-target-stack_size.patch --]
[-- Type: text/x-patch, Size: 26448 bytes --]

Add effective target stack_size

2017-06-09  Tom de Vries  <tom@codesourcery.com>

	* lib/target-supports.exp (check_effective_target_stack_size)
	(dg-effective-target-value): New proc.
	* lib/gcc.exp (gcc_target_compile): Remove adding of DSTACK_SIZE to
	additional_flags.
	* lib/objc.exp (objc_target_compile): Same.
	* lib/profopt.exp (profopt-get-options): Allow dg-additional-options.
	* g++.old-deja/g++.eh/badalloc1.C: Add -DSTACK_SIZE=<value> using
	dg-additional-options.
	* gcc.c-torture/compile/20080806-1.c: Same.
	* gcc.c-torture/compile/920723-1.c: Same.
	* gcc.c-torture/compile/930621-1.c: Same.
	* gcc.c-torture/compile/991214-2.c: Same.
	* gcc.c-torture/compile/bcopy.c: Same.
	* gcc.c-torture/compile/memtst.c: Same.
	* gcc.c-torture/compile/msp.c: Same.
	* gcc.c-torture/compile/stuct.c: Same.
	* gcc.c-torture/execute/20011008-3.c: Same.
	* gcc.c-torture/execute/20030209-1.c: Same.
	* gcc.c-torture/execute/20031012-1.c: Same.
	* gcc.c-torture/execute/20040805-1.c: Same.
	* gcc.c-torture/execute/920410-1.c: Same.
	* gcc.c-torture/execute/920501-7.c: Same.
	* gcc.c-torture/execute/921113-1.c: Same.
	* gcc.c-torture/execute/921202-1.c: Same.
	* gcc.c-torture/execute/921208-2.c: Same.
	* gcc.c-torture/execute/930106-1.c: Same.
	* gcc.c-torture/execute/930406-1.c: Same.
	* gcc.c-torture/execute/950221-1.c: Same.
	* gcc.c-torture/execute/960521-1.c: Same.
	* gcc.c-torture/execute/980605-1.c: Same.
	* gcc.c-torture/execute/comp-goto-1.c: Same.
	* gcc.c-torture/execute/comp-goto-2.c: Same.
	* gcc.c-torture/execute/memcpy-1.c: Same.
	* gcc.c-torture/execute/multi-ix.c: Same.
	* gcc.c-torture/execute/nestfunc-4.c: Same.
	* gcc.c-torture/execute/pr20621-1.c: Same.
	* gcc.c-torture/execute/pr23135.c: Same.
	* gcc.c-torture/execute/pr28982b.c: Same.
	* gcc.dg/loop-3.c: Same.
	* gcc.dg/struct-ret-3.c: Same.
	* gcc.dg/torture/stackalign/comp-goto-1.c: Same.
	* gcc.dg/torture/stackalign/non-local-goto-4.c: Same.
	* gcc.dg/tree-prof/comp-goto-1.c: Same.
	* gcc.dg/tree-prof/pr44777.c: Same.

	* doc/sourcebuild.texi (Effective-Target Keywords, Other attributes):
	Document effective target stack_size.

---
 gcc/doc/sourcebuild.texi                            |  7 +++++++
 gcc/testsuite/g++.old-deja/g++.eh/badalloc1.C       |  1 +
 gcc/testsuite/gcc.c-torture/compile/20080806-1.c    |  2 ++
 gcc/testsuite/gcc.c-torture/compile/920723-1.c      |  1 +
 gcc/testsuite/gcc.c-torture/compile/930621-1.c      |  2 ++
 gcc/testsuite/gcc.c-torture/compile/991214-2.c      |  2 ++
 gcc/testsuite/gcc.c-torture/compile/bcopy.c         |  2 ++
 gcc/testsuite/gcc.c-torture/compile/memtst.c        |  2 ++
 gcc/testsuite/gcc.c-torture/compile/msp.c           |  2 ++
 gcc/testsuite/gcc.c-torture/compile/stuct.c         |  2 ++
 gcc/testsuite/gcc.c-torture/execute/20011008-3.c    |  2 ++
 gcc/testsuite/gcc.c-torture/execute/20030209-1.c    |  2 ++
 gcc/testsuite/gcc.c-torture/execute/20031012-1.c    |  2 ++
 gcc/testsuite/gcc.c-torture/execute/20040805-1.c    |  2 ++
 gcc/testsuite/gcc.c-torture/execute/920410-1.c      |  2 ++
 gcc/testsuite/gcc.c-torture/execute/920501-7.c      |  1 +
 gcc/testsuite/gcc.c-torture/execute/921113-1.c      |  2 ++
 gcc/testsuite/gcc.c-torture/execute/921202-1.c      |  2 ++
 gcc/testsuite/gcc.c-torture/execute/921208-2.c      |  2 ++
 gcc/testsuite/gcc.c-torture/execute/930106-1.c      |  2 ++
 gcc/testsuite/gcc.c-torture/execute/930406-1.c      |  2 ++
 gcc/testsuite/gcc.c-torture/execute/950221-1.c      |  2 ++
 gcc/testsuite/gcc.c-torture/execute/960521-1.c      |  2 ++
 gcc/testsuite/gcc.c-torture/execute/980605-1.c      |  2 ++
 gcc/testsuite/gcc.c-torture/execute/comp-goto-1.c   |  1 +
 gcc/testsuite/gcc.c-torture/execute/comp-goto-2.c   |  1 +
 gcc/testsuite/gcc.c-torture/execute/memcpy-1.c      |  2 ++
 gcc/testsuite/gcc.c-torture/execute/multi-ix.c      |  2 ++
 gcc/testsuite/gcc.c-torture/execute/nestfunc-4.c    |  2 ++
 gcc/testsuite/gcc.c-torture/execute/pr20621-1.c     |  2 ++
 gcc/testsuite/gcc.c-torture/execute/pr23135.c       |  2 ++
 gcc/testsuite/gcc.c-torture/execute/pr28982b.c      |  2 ++
 gcc/testsuite/gcc.dg/loop-3.c                       |  1 +
 gcc/testsuite/gcc.dg/struct-ret-3.c                 |  3 ++-
 .../gcc.dg/torture/stackalign/comp-goto-1.c         |  1 +
 .../gcc.dg/torture/stackalign/non-local-goto-4.c    |  1 +
 gcc/testsuite/gcc.dg/tree-prof/comp-goto-1.c        |  2 ++
 gcc/testsuite/gcc.dg/tree-prof/pr44777.c            |  2 ++
 gcc/testsuite/lib/gcc.exp                           |  3 ---
 gcc/testsuite/lib/objc.exp                          |  4 ----
 gcc/testsuite/lib/profopt.exp                       |  1 +
 gcc/testsuite/lib/target-supports.exp               | 21 +++++++++++++++++++++
 42 files changed, 95 insertions(+), 8 deletions(-)

diff --git a/gcc/doc/sourcebuild.texi b/gcc/doc/sourcebuild.texi
index 841e75a..cdb3a2c 100644
--- a/gcc/doc/sourcebuild.texi
+++ b/gcc/doc/sourcebuild.texi
@@ -2093,6 +2093,13 @@ Target supports section anchors.
 @item short_enums
 Target defaults to short enums.
 
+@item stack_size
+Target has limited stack size.  The stack size limit can be obtained using
+@code{[dg-effective-target-value stack_size]}.  For example:
+@smallexample
+/* @{ dg-additional-options "-DSTACK_SIZE=[dg-effective-target-value stack_size]" @{ target @{ stack_size @} @} @} */
+@end smallexample
+
 @item static
 Target supports @option{-static}.
 
diff --git a/gcc/testsuite/g++.old-deja/g++.eh/badalloc1.C b/gcc/testsuite/g++.old-deja/g++.eh/badalloc1.C
index 31c7300..f63d5c6 100644
--- a/gcc/testsuite/g++.old-deja/g++.eh/badalloc1.C
+++ b/gcc/testsuite/g++.old-deja/g++.eh/badalloc1.C
@@ -3,6 +3,7 @@
 // itself call malloc(), and will fail if there is no more
 // memory available.
 // { dg-do run { xfail { { xstormy16-*-* *-*-darwin[3-7]* } || vxworks_rtp } } }
+// { dg-additional-options "-DSTACK_SIZE=[dg-effective-target-value stack_size]" { target { stack_size } } }
 // Copyright (C) 2000, 2002, 2003, 2010, 2012, 2014 Free Software Foundation, Inc.
 // Contributed by Nathan Sidwell 6 June 2000 <nathan@codesourcery.com>
 
diff --git a/gcc/testsuite/gcc.c-torture/compile/20080806-1.c b/gcc/testsuite/gcc.c-torture/compile/20080806-1.c
index c54e739..d0ee9cc 100644
--- a/gcc/testsuite/gcc.c-torture/compile/20080806-1.c
+++ b/gcc/testsuite/gcc.c-torture/compile/20080806-1.c
@@ -1,3 +1,5 @@
+/* { dg-additional-options "-DSTACK_SIZE=[dg-effective-target-value stack_size]" { target { stack_size } } } */
+
 /* This used to ICE on s390x due to a reload bug.  */
 
 #if defined(STACK_SIZE) && (STACK_SIZE < 65536)
diff --git a/gcc/testsuite/gcc.c-torture/compile/920723-1.c b/gcc/testsuite/gcc.c-torture/compile/920723-1.c
index 69b031e..c6351c37 100644
--- a/gcc/testsuite/gcc.c-torture/compile/920723-1.c
+++ b/gcc/testsuite/gcc.c-torture/compile/920723-1.c
@@ -1,3 +1,4 @@
+/* { dg-additional-options "-DSTACK_SIZE=[dg-effective-target-value stack_size]" { target { stack_size } } } */
 
 #if defined(STACK_SIZE) && STACK_SIZE < 65536
 # define GITT_SIZE 75
diff --git a/gcc/testsuite/gcc.c-torture/compile/930621-1.c b/gcc/testsuite/gcc.c-torture/compile/930621-1.c
index 4199bbe..13e997a 100644
--- a/gcc/testsuite/gcc.c-torture/compile/930621-1.c
+++ b/gcc/testsuite/gcc.c-torture/compile/930621-1.c
@@ -1,3 +1,5 @@
+/* { dg-additional-options "-DSTACK_SIZE=[dg-effective-target-value stack_size]" { target { stack_size } } } */
+
 #if defined(STACK_SIZE) && (STACK_SIZE < 65536)
 # define BYTEMEM_SIZE 10000L
 #endif
diff --git a/gcc/testsuite/gcc.c-torture/compile/991214-2.c b/gcc/testsuite/gcc.c-torture/compile/991214-2.c
index 3e18d21..32dad4ff 100644
--- a/gcc/testsuite/gcc.c-torture/compile/991214-2.c
+++ b/gcc/testsuite/gcc.c-torture/compile/991214-2.c
@@ -1,3 +1,5 @@
+/* { dg-additional-options "-DSTACK_SIZE=[dg-effective-target-value stack_size]" { target { stack_size } } } */
+
 #if defined(STACK_SIZE) && (STACK_SIZE < 65536)
 # define HISTO_SIZE 9
 #else
diff --git a/gcc/testsuite/gcc.c-torture/compile/bcopy.c b/gcc/testsuite/gcc.c-torture/compile/bcopy.c
index aed994e..cb7c05d 100644
--- a/gcc/testsuite/gcc.c-torture/compile/bcopy.c
+++ b/gcc/testsuite/gcc.c-torture/compile/bcopy.c
@@ -1,3 +1,5 @@
+/* { dg-additional-options "-DSTACK_SIZE=[dg-effective-target-value stack_size]" { target { stack_size } } } */
+
 void
 bcopy1 (s, d, c)
      long long *s;
diff --git a/gcc/testsuite/gcc.c-torture/compile/memtst.c b/gcc/testsuite/gcc.c-torture/compile/memtst.c
index b5ef260..e165a22 100644
--- a/gcc/testsuite/gcc.c-torture/compile/memtst.c
+++ b/gcc/testsuite/gcc.c-torture/compile/memtst.c
@@ -1,3 +1,5 @@
+/* { dg-additional-options "-DSTACK_SIZE=[dg-effective-target-value stack_size]" { target { stack_size } } } */
+
 #ifdef STACK_SIZE
 #define SIZE STACK_SIZE / 8
 #else
diff --git a/gcc/testsuite/gcc.c-torture/compile/msp.c b/gcc/testsuite/gcc.c-torture/compile/msp.c
index 5d350fd..594cecb 100644
--- a/gcc/testsuite/gcc.c-torture/compile/msp.c
+++ b/gcc/testsuite/gcc.c-torture/compile/msp.c
@@ -1,3 +1,5 @@
+/* { dg-additional-options "-DSTACK_SIZE=[dg-effective-target-value stack_size]" { target { stack_size } } } */
+
 #ifdef STACK_SIZE
 # define A_SIZE (STACK_SIZE/sizeof(int))
 #else
diff --git a/gcc/testsuite/gcc.c-torture/compile/stuct.c b/gcc/testsuite/gcc.c-torture/compile/stuct.c
index deb838d..59acd57 100644
--- a/gcc/testsuite/gcc.c-torture/compile/stuct.c
+++ b/gcc/testsuite/gcc.c-torture/compile/stuct.c
@@ -1,3 +1,5 @@
+/* { dg-additional-options "-DSTACK_SIZE=[dg-effective-target-value stack_size]" { target { stack_size } } } */
+
 #ifdef STACK_SIZE
 #define SIZE STACK_SIZE / 8
 #else
diff --git a/gcc/testsuite/gcc.c-torture/execute/20011008-3.c b/gcc/testsuite/gcc.c-torture/execute/20011008-3.c
index 3244b0a..2fd6871 100644
--- a/gcc/testsuite/gcc.c-torture/execute/20011008-3.c
+++ b/gcc/testsuite/gcc.c-torture/execute/20011008-3.c
@@ -1,3 +1,5 @@
+/* { dg-additional-options "-DSTACK_SIZE=[dg-effective-target-value stack_size]" { target { stack_size } } } */
+
 extern void exit (int);
 extern void abort (void);
 
diff --git a/gcc/testsuite/gcc.c-torture/execute/20030209-1.c b/gcc/testsuite/gcc.c-torture/execute/20030209-1.c
index 5845d67..72c1e55 100644
--- a/gcc/testsuite/gcc.c-torture/execute/20030209-1.c
+++ b/gcc/testsuite/gcc.c-torture/execute/20030209-1.c
@@ -1,3 +1,5 @@
+/* { dg-additional-options "-DSTACK_SIZE=[dg-effective-target-value stack_size]" { target { stack_size } } } */
+
 #ifdef STACK_SIZE
 #if STACK_SIZE < 8*100*100
 #define SKIP
diff --git a/gcc/testsuite/gcc.c-torture/execute/20031012-1.c b/gcc/testsuite/gcc.c-torture/execute/20031012-1.c
index a1f3de8..db7f3fa 100644
--- a/gcc/testsuite/gcc.c-torture/execute/20031012-1.c
+++ b/gcc/testsuite/gcc.c-torture/execute/20031012-1.c
@@ -1,3 +1,5 @@
+/* { dg-additional-options "-DSTACK_SIZE=[dg-effective-target-value stack_size]" { target { stack_size } } } */
+
 /* PR optimization/8750
    Used to fail under Cygwin with 
    -O2 -fomit-frame-pointer        
diff --git a/gcc/testsuite/gcc.c-torture/execute/20040805-1.c b/gcc/testsuite/gcc.c-torture/execute/20040805-1.c
index f09fc49..4e978f5 100644
--- a/gcc/testsuite/gcc.c-torture/execute/20040805-1.c
+++ b/gcc/testsuite/gcc.c-torture/execute/20040805-1.c
@@ -1,3 +1,5 @@
+/* { dg-additional-options "-DSTACK_SIZE=[dg-effective-target-value stack_size]" { target { stack_size } } } */
+
 #if __INT_MAX__ < 32768 || (defined(STACK_SIZE) && STACK_SIZE < 0x12000)
 int main () { exit (0); }
 #else
diff --git a/gcc/testsuite/gcc.c-torture/execute/920410-1.c b/gcc/testsuite/gcc.c-torture/execute/920410-1.c
index f5180f0..50bc417 100644
--- a/gcc/testsuite/gcc.c-torture/execute/920410-1.c
+++ b/gcc/testsuite/gcc.c-torture/execute/920410-1.c
@@ -1,3 +1,5 @@
+/* { dg-additional-options "-DSTACK_SIZE=[dg-effective-target-value stack_size]" { target { stack_size } } } */
+
 #define STACK_REQUIREMENT (40000 * 4 + 256)
 #if defined (STACK_SIZE) && STACK_SIZE < STACK_REQUIREMENT
 main () { exit (0); }
diff --git a/gcc/testsuite/gcc.c-torture/execute/920501-7.c b/gcc/testsuite/gcc.c-torture/execute/920501-7.c
index d05ac61..5cced09 100644
--- a/gcc/testsuite/gcc.c-torture/execute/920501-7.c
+++ b/gcc/testsuite/gcc.c-torture/execute/920501-7.c
@@ -1,5 +1,6 @@
 /* { dg-require-effective-target label_values } */
 /* { dg-require-effective-target trampolines } */
+/* { dg-additional-options "-DSTACK_SIZE=[dg-effective-target-value stack_size]" { target { stack_size } } } */
 
 #ifdef STACK_SIZE
 #define DEPTH ((STACK_SIZE) / 512 + 1)
diff --git a/gcc/testsuite/gcc.c-torture/execute/921113-1.c b/gcc/testsuite/gcc.c-torture/execute/921113-1.c
index 78972bc..24c4952 100644
--- a/gcc/testsuite/gcc.c-torture/execute/921113-1.c
+++ b/gcc/testsuite/gcc.c-torture/execute/921113-1.c
@@ -1,3 +1,5 @@
+/* { dg-additional-options "-DSTACK_SIZE=[dg-effective-target-value stack_size]" { target { stack_size } } } */
+
 #define STACK_REQUIREMENT (128 * 128 * 4 + 1024)
 #if defined (STACK_SIZE) && STACK_SIZE < STACK_REQUIREMENT
 main () { exit (0); }
diff --git a/gcc/testsuite/gcc.c-torture/execute/921202-1.c b/gcc/testsuite/gcc.c-torture/execute/921202-1.c
index 935975d..530fad0 100644
--- a/gcc/testsuite/gcc.c-torture/execute/921202-1.c
+++ b/gcc/testsuite/gcc.c-torture/execute/921202-1.c
@@ -1,4 +1,6 @@
 /* { dg-require-effective-target untyped_assembly } */
+/* { dg-additional-options "-DSTACK_SIZE=[dg-effective-target-value stack_size]" { target { stack_size } } } */
+
 #ifndef STACK_SIZE
 #define	VLEN	2055
 #else
diff --git a/gcc/testsuite/gcc.c-torture/execute/921208-2.c b/gcc/testsuite/gcc.c-torture/execute/921208-2.c
index f01b572..f18f2c8 100644
--- a/gcc/testsuite/gcc.c-torture/execute/921208-2.c
+++ b/gcc/testsuite/gcc.c-torture/execute/921208-2.c
@@ -1,4 +1,6 @@
 /* { dg-require-effective-target untyped_assembly } */
+/* { dg-additional-options "-DSTACK_SIZE=[dg-effective-target-value stack_size]" { target { stack_size } } } */
+
 #define STACK_REQUIREMENT (100000 * 4 + 1024)
 #if defined (STACK_SIZE) && STACK_SIZE < STACK_REQUIREMENT
 main () { exit (0); }
diff --git a/gcc/testsuite/gcc.c-torture/execute/930106-1.c b/gcc/testsuite/gcc.c-torture/execute/930106-1.c
index 8081f92..41add7d 100644
--- a/gcc/testsuite/gcc.c-torture/execute/930106-1.c
+++ b/gcc/testsuite/gcc.c-torture/execute/930106-1.c
@@ -1,3 +1,5 @@
+/* { dg-additional-options "-DSTACK_SIZE=[dg-effective-target-value stack_size]" { target { stack_size } } } */
+
 #if defined (STACK_SIZE)
 #define DUMMY_SIZE 9
 #else
diff --git a/gcc/testsuite/gcc.c-torture/execute/930406-1.c b/gcc/testsuite/gcc.c-torture/execute/930406-1.c
index 9728eab..0d6b0fb 100644
--- a/gcc/testsuite/gcc.c-torture/execute/930406-1.c
+++ b/gcc/testsuite/gcc.c-torture/execute/930406-1.c
@@ -1,3 +1,5 @@
+/* { dg-additional-options "-DSTACK_SIZE=[dg-effective-target-value stack_size]" { target { stack_size } } } */
+
 f()
 {
   int x = 1;
diff --git a/gcc/testsuite/gcc.c-torture/execute/950221-1.c b/gcc/testsuite/gcc.c-torture/execute/950221-1.c
index d67da5b..aa71024 100644
--- a/gcc/testsuite/gcc.c-torture/execute/950221-1.c
+++ b/gcc/testsuite/gcc.c-torture/execute/950221-1.c
@@ -1,3 +1,5 @@
+/* { dg-additional-options "-DSTACK_SIZE=[dg-effective-target-value stack_size]" { target { stack_size } } } */
+
 struct parsefile
 {
   long fd;
diff --git a/gcc/testsuite/gcc.c-torture/execute/960521-1.c b/gcc/testsuite/gcc.c-torture/execute/960521-1.c
index 9fc5821..fc69ff9 100644
--- a/gcc/testsuite/gcc.c-torture/execute/960521-1.c
+++ b/gcc/testsuite/gcc.c-torture/execute/960521-1.c
@@ -1,3 +1,5 @@
+/* { dg-additional-options "-DSTACK_SIZE=[dg-effective-target-value stack_size]" { target { stack_size } } } */
+
 #include <stdlib.h>
 
 int *a, *b;
diff --git a/gcc/testsuite/gcc.c-torture/execute/980605-1.c b/gcc/testsuite/gcc.c-torture/execute/980605-1.c
index 2fc2691..9185f2b 100644
--- a/gcc/testsuite/gcc.c-torture/execute/980605-1.c
+++ b/gcc/testsuite/gcc.c-torture/execute/980605-1.c
@@ -1,3 +1,5 @@
+/* { dg-additional-options "-DSTACK_SIZE=[dg-effective-target-value stack_size]" { target { stack_size } } } */
+
 #include <stdio.h>
 
 #ifndef STACK_SIZE
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 d01f96b..3bc00ef 100644
--- a/gcc/testsuite/gcc.c-torture/execute/comp-goto-1.c
+++ b/gcc/testsuite/gcc.c-torture/execute/comp-goto-1.c
@@ -1,4 +1,5 @@
 /* { dg-require-effective-target label_values } */
+/* { dg-additional-options "-DSTACK_SIZE=[dg-effective-target-value stack_size]" { target { stack_size } } } */
 
 #include <stdlib.h>
 
diff --git a/gcc/testsuite/gcc.c-torture/execute/comp-goto-2.c b/gcc/testsuite/gcc.c-torture/execute/comp-goto-2.c
index eaf83d8..21a1e6f 100644
--- a/gcc/testsuite/gcc.c-torture/execute/comp-goto-2.c
+++ b/gcc/testsuite/gcc.c-torture/execute/comp-goto-2.c
@@ -1,5 +1,6 @@
 /* { dg-require-effective-target label_values } */
 /* { dg-require-effective-target trampolines } */
+/* { dg-additional-options "-DSTACK_SIZE=[dg-effective-target-value stack_size]" { target { stack_size } } } */
 
 /* A slight variation of 920501-7.c.  */
 
diff --git a/gcc/testsuite/gcc.c-torture/execute/memcpy-1.c b/gcc/testsuite/gcc.c-torture/execute/memcpy-1.c
index 684854b..e94ab8a 100644
--- a/gcc/testsuite/gcc.c-torture/execute/memcpy-1.c
+++ b/gcc/testsuite/gcc.c-torture/execute/memcpy-1.c
@@ -1,3 +1,5 @@
+/* { dg-additional-options "-DSTACK_SIZE=[dg-effective-target-value stack_size]" { target { stack_size } } } */
+
 #include <string.h>
 
 #if defined (STACK_SIZE)
diff --git a/gcc/testsuite/gcc.c-torture/execute/multi-ix.c b/gcc/testsuite/gcc.c-torture/execute/multi-ix.c
index 377f08c..8ab041b 100644
--- a/gcc/testsuite/gcc.c-torture/execute/multi-ix.c
+++ b/gcc/testsuite/gcc.c-torture/execute/multi-ix.c
@@ -1,3 +1,5 @@
+/* { dg-additional-options "-DSTACK_SIZE=[dg-effective-target-value stack_size]" { target { stack_size } } } */
+
 /* Test for a reload bug:
    if you have a memory reference using the indexed addressing
    mode, and the base address is a pseudo containing an address in the frame
diff --git a/gcc/testsuite/gcc.c-torture/execute/nestfunc-4.c b/gcc/testsuite/gcc.c-torture/execute/nestfunc-4.c
index e028166..ee5b376 100644
--- a/gcc/testsuite/gcc.c-torture/execute/nestfunc-4.c
+++ b/gcc/testsuite/gcc.c-torture/execute/nestfunc-4.c
@@ -1,3 +1,5 @@
+/* { dg-additional-options "-DSTACK_SIZE=[dg-effective-target-value stack_size]" { target { stack_size } } } */
+
 /* Origin: hp@bitrange.com
    Test that return values come out right from a 1000-level call chain to
    functions without parameters that each need at least one "long"
diff --git a/gcc/testsuite/gcc.c-torture/execute/pr20621-1.c b/gcc/testsuite/gcc.c-torture/execute/pr20621-1.c
index 57b3df7..4a55c97 100644
--- a/gcc/testsuite/gcc.c-torture/execute/pr20621-1.c
+++ b/gcc/testsuite/gcc.c-torture/execute/pr20621-1.c
@@ -1,3 +1,5 @@
+/* { dg-additional-options "-DSTACK_SIZE=[dg-effective-target-value stack_size]" { target { stack_size } } } */
+
 /* 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]; };
diff --git a/gcc/testsuite/gcc.c-torture/execute/pr23135.c b/gcc/testsuite/gcc.c-torture/execute/pr23135.c
index 378ebe7..31b4f8f 100644
--- a/gcc/testsuite/gcc.c-torture/execute/pr23135.c
+++ b/gcc/testsuite/gcc.c-torture/execute/pr23135.c
@@ -1,3 +1,5 @@
+/* { dg-additional-options "-DSTACK_SIZE=[dg-effective-target-value stack_size]" { target { stack_size } } } */
+
 /* Based on execute/simd-1.c, modified by joern.rennecke@st.com to
    trigger a reload bug.  Verified for gcc mainline from 20050722 13:00 UTC
    for sh-elf -m4 -O2.  */
diff --git a/gcc/testsuite/gcc.c-torture/execute/pr28982b.c b/gcc/testsuite/gcc.c-torture/execute/pr28982b.c
index 3f9f5ba..90d4a93 100644
--- a/gcc/testsuite/gcc.c-torture/execute/pr28982b.c
+++ b/gcc/testsuite/gcc.c-torture/execute/pr28982b.c
@@ -1,3 +1,5 @@
+/* { dg-additional-options "-DSTACK_SIZE=[dg-effective-target-value stack_size]" { target { stack_size } } } */
+
 /* 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.  */
diff --git a/gcc/testsuite/gcc.dg/loop-3.c b/gcc/testsuite/gcc.dg/loop-3.c
index 6bdb5ef..2c500d0 100644
--- a/gcc/testsuite/gcc.dg/loop-3.c
+++ b/gcc/testsuite/gcc.dg/loop-3.c
@@ -4,6 +4,7 @@
 /* { dg-do compile } */
 /* { dg-options "-O3" } */
 /* { dg-options "-O3 -mtune=i386" { target { { i?86-*-* x86_64-*-* } && ia32 } } } */
+/* { dg-additional-options "-DSTACK_SIZE=[dg-effective-target-value stack_size]" { target { stack_size } } } */
 
 #if defined(STACK_SIZE) && (STACK_SIZE < 65536)
 # define BYTEMEM_SIZE 10000L
diff --git a/gcc/testsuite/gcc.dg/struct-ret-3.c b/gcc/testsuite/gcc.dg/struct-ret-3.c
index 36cc87e..c6f87ac 100644
--- a/gcc/testsuite/gcc.dg/struct-ret-3.c
+++ b/gcc/testsuite/gcc.dg/struct-ret-3.c
@@ -2,7 +2,8 @@
 /* Origin: Peeter Joot <peeterj@ca.ibm.com> */
 
 /* { dg-do run { target *-*-linux* *-*-gnu* } } */
-
+/* { dg-additional-options "-DSTACK_SIZE=[dg-effective-target-value stack_size]" { target { stack_size } } } */
+ 
 #include <sys/mman.h>
 #include <string.h>
 #include <stdio.h>
diff --git a/gcc/testsuite/gcc.dg/torture/stackalign/comp-goto-1.c b/gcc/testsuite/gcc.dg/torture/stackalign/comp-goto-1.c
index 98a47a8..726bb20 100644
--- a/gcc/testsuite/gcc.dg/torture/stackalign/comp-goto-1.c
+++ b/gcc/testsuite/gcc.dg/torture/stackalign/comp-goto-1.c
@@ -1,6 +1,7 @@
 /* { dg-do run } */
 /* { dg-require-effective-target label_values } */
 /* { dg-require-effective-target trampolines } */
+/* { dg-additional-options "-DSTACK_SIZE=[dg-effective-target-value stack_size]" { target { stack_size } } } */
 
 #ifdef STACK_SIZE
 #define DEPTH ((STACK_SIZE) / 512 + 1)
diff --git a/gcc/testsuite/gcc.dg/torture/stackalign/non-local-goto-4.c b/gcc/testsuite/gcc.dg/torture/stackalign/non-local-goto-4.c
index 591428d..90ca71c 100644
--- a/gcc/testsuite/gcc.dg/torture/stackalign/non-local-goto-4.c
+++ b/gcc/testsuite/gcc.dg/torture/stackalign/non-local-goto-4.c
@@ -2,6 +2,7 @@
 /* { dg-require-effective-target nonlocal_goto } */
 /* { dg-require-effective-target label_values } */
 /* { dg-require-effective-target trampolines } */
+/* { dg-additional-options "-DSTACK_SIZE=[dg-effective-target-value stack_size]" { target { stack_size } } } */
 
 extern void abort (void);
 extern void exit (int);
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 86e88ad..dd6774f 100644
--- a/gcc/testsuite/gcc.dg/tree-prof/comp-goto-1.c
+++ b/gcc/testsuite/gcc.dg/tree-prof/comp-goto-1.c
@@ -1,6 +1,8 @@
 /* { dg-require-effective-target freorder } */
 /* { dg-require-effective-target label_values } */
 /* { dg-options "-O2 -freorder-blocks-and-partition" } */
+/* { dg-additional-options "-DSTACK_SIZE=[dg-effective-target-value stack_size]" { target { stack_size } } } */
+
 #include <stdlib.h>
 
 #if (!defined(STACK_SIZE) || STACK_SIZE >= 4000) && __INT_MAX__ >= 2147483647
diff --git a/gcc/testsuite/gcc.dg/tree-prof/pr44777.c b/gcc/testsuite/gcc.dg/tree-prof/pr44777.c
index 4074b75..1249b5b 100644
--- a/gcc/testsuite/gcc.dg/tree-prof/pr44777.c
+++ b/gcc/testsuite/gcc.dg/tree-prof/pr44777.c
@@ -2,6 +2,8 @@
 /* { dg-require-effective-target label_values } */
 /* { dg-require-effective-target trampolines } */
 /* { dg-options "-O0" } */
+/* { dg-additional-options "-DSTACK_SIZE=[dg-effective-target-value stack_size]" { target { stack_size } } } */
+
 /* A variant of gcc.c-torture/execute/comp-goto-2.c.  */
 
 extern void abort (void);
diff --git a/gcc/testsuite/lib/gcc.exp b/gcc/testsuite/lib/gcc.exp
index fd32a30..e4ac239 100644
--- a/gcc/testsuite/lib/gcc.exp
+++ b/gcc/testsuite/lib/gcc.exp
@@ -141,9 +141,6 @@ proc gcc_target_compile { source dest type options } {
 	lappend options "ldflags=$TEST_EXTRA_LIBS"
     }
 
-    if [target_info exists gcc,stack_size] {
-	lappend options "additional_flags=-DSTACK_SIZE=[target_info gcc,stack_size]"
-    }
     if [target_info exists gcc,signal_suppress] {
 	lappend options "additional_flags=-DSIGNAL_SUPPRESS"
     }
diff --git a/gcc/testsuite/lib/objc.exp b/gcc/testsuite/lib/objc.exp
index c8b9741..431754f 100644
--- a/gcc/testsuite/lib/objc.exp
+++ b/gcc/testsuite/lib/objc.exp
@@ -191,10 +191,6 @@ proc objc_target_compile { source dest type options } {
 	lappend options "ldflags=$wrap_flags"
     }
 
-    if [target_info exists objc,stack_size] {
-	lappend options "additional_flags=-DSTACK_SIZE=[target_info objc,stack_size]"
-    }
-
     # TEST_ALWAYS_FLAGS are flags that should be passed to every
     # compilation.  They are passed first to allow individual
     # tests to override them.
diff --git a/gcc/testsuite/lib/profopt.exp b/gcc/testsuite/lib/profopt.exp
index 77ffae0..6519c44 100644
--- a/gcc/testsuite/lib/profopt.exp
+++ b/gcc/testsuite/lib/profopt.exp
@@ -248,6 +248,7 @@ proc profopt-get-options { src } {
     foreach op $tmp {
 	set cmd [lindex $op 0]
 	if { ![string compare "dg-options" $cmd] \
+	     || ![string compare "dg-additional-options" $cmd] \
 	     || ![string compare "dg-skip-if" $cmd] \
 	     || ![string compare "dg-final-generate" $cmd] \
 	     || ![string compare "dg-final-use" $cmd] \
diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp
index d0b35be..a931c9c 100644
--- a/gcc/testsuite/lib/target-supports.exp
+++ b/gcc/testsuite/lib/target-supports.exp
@@ -504,6 +504,27 @@ proc check_effective_target_trampolines { } {
     return 1
 }
 
+# Return 1 if target has limited stack size.
+
+proc check_effective_target_stack_size { } {
+    if [target_info exists gcc,stack_size] {
+	return 1
+    }
+    return 0
+}
+
+# Return the value attribute of an effective target, otherwise return 0.
+
+proc dg-effective-target-value { effective_target } {
+    if { "$effective_target" == "stack_size" } {
+	if [check_effective_target_stack_size] {
+	    return [target_info gcc,stack_size]
+	}
+    }
+
+    return 0
+}
+
 # Return 1 if according to target_info struct and explicit target list
 # target disables -fdelete-null-pointer-checks.  Targets should return 0
 # if they simply default to -fno-delete-null-pointer-checks but obey

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH, testsuite] Add effective target stack_size
  2017-06-09 14:24 [PATCH, testsuite] Add effective target stack_size Tom de Vries
@ 2017-06-09 15:25 ` Mike Stump
  2017-06-12 12:28   ` Christophe Lyon
  2017-06-19 17:11   ` Add dg-add-options feature stack_size Tom de Vries
  2017-06-21 13:19 ` [PATCH, testsuite] Add effective target stack_size Jakub Jelinek
  2022-11-08 20:29 ` nvptx: stack size limits are relevant for execution only (was: [PATCH, testsuite] Add effective target stack_size) Thomas Schwinge
  2 siblings, 2 replies; 14+ messages in thread
From: Mike Stump @ 2017-06-09 15:25 UTC (permalink / raw)
  To: Tom de Vries; +Cc: GCC Patches, Rainer Orth

On Jun 9, 2017, at 7:24 AM, Tom de Vries <Tom_deVries@mentor.com> wrote:
> this patch adds effective target stack_size.

> OK for trunk if x86_64 and nvptx testing succeeds?

Ok.

The only last issue in this area that I know about is that there are a few more test cases that need up to 48 MB to run, the problem is that targets might have substantially less memory.  Stack size is one of the ways this problem can be exposed.  The failure to load case is or can be handled in other ways, but the dynamic allocation case I think is relatively poorly handled.  On my machine, I just punted by running on a virtual simulator that I pushed memory up to 48 MB and ignored the issue.  If anyone wants to try their hand at it, I'd be happy to review some patches.  For those on demand virtual memory systems, of course, the problem is invisible.  I didn't have any good ideas in this area.  Marking large memory test cases with size information, and then just trimming based upon size was my only thought.  Not exactly portable, as the exact size of any test case is of course target dependent; but, if we get close enough, it can provide enough of a solution I think.

If people have better ideas in this area, even if you don't want to implement them, it'd be nice to hear about them.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH, testsuite] Add effective target stack_size
  2017-06-09 15:25 ` Mike Stump
@ 2017-06-12 12:28   ` Christophe Lyon
  2017-06-12 14:29     ` Tom de Vries
  2017-06-19 17:11   ` Add dg-add-options feature stack_size Tom de Vries
  1 sibling, 1 reply; 14+ messages in thread
From: Christophe Lyon @ 2017-06-12 12:28 UTC (permalink / raw)
  To: Tom de Vries; +Cc: GCC Patches, Rainer Orth

Hi Tom,

On 9 June 2017 at 17:25, Mike Stump <mikestump@comcast.net> wrote:
> On Jun 9, 2017, at 7:24 AM, Tom de Vries <Tom_deVries@mentor.com> wrote:
>> this patch adds effective target stack_size.
>
>> OK for trunk if x86_64 and nvptx testing succeeds?
>
> Ok.
>
> The only last issue in this area that I know about is that there are a few more test cases that need up to 48 MB to run, the problem is that targets might have substantially less memory.  Stack size is one of the ways this problem can be exposed.  The failure to load case is or can be handled in other ways, but the dynamic allocation case I think is relatively poorly handled.  On my machine, I just punted by running on a virtual simulator that I pushed memory up to 48 MB and ignored the issue.  If anyone wants to try their hand at it, I'd be happy to review some patches.  For those on demand virtual memory systems, of course, the problem is invisible.  I didn't have any good ideas in this area.  Marking large memory test cases with size information, and then just trimming based upon size was my only thought.  Not exactly portable, as the exact size of any test case is of course target dependent; but, if we get close enough, it can provide enough of a solution I think.
>
> If people have better ideas in this area, even if you don't want to implement them, it'd be nice to hear about them.

After this commit (r249090), I've noticed that badalloc1.C fails at
execution on aarch64 and arm bare-metal targets.

It is compiled with -DSTACK_SIZE=16384, maybe that's too small?

Thanks,

Christophe

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH, testsuite] Add effective target stack_size
  2017-06-12 12:28   ` Christophe Lyon
@ 2017-06-12 14:29     ` Tom de Vries
  2017-06-19  9:21       ` Christophe Lyon
  0 siblings, 1 reply; 14+ messages in thread
From: Tom de Vries @ 2017-06-12 14:29 UTC (permalink / raw)
  To: Christophe Lyon; +Cc: GCC Patches, Rainer Orth

On 06/12/2017 02:28 PM, Christophe Lyon wrote:
> Hi Tom,
> 
> On 9 June 2017 at 17:25, Mike Stump <mikestump@comcast.net> wrote:
>> On Jun 9, 2017, at 7:24 AM, Tom de Vries <Tom_deVries@mentor.com> wrote:
>>> this patch adds effective target stack_size.
>>
>>> OK for trunk if x86_64 and nvptx testing succeeds?
>>
>> Ok.
>>
>> The only last issue in this area that I know about is that there are a few more test cases that need up to 48 MB to run, the problem is that targets might have substantially less memory.  Stack size is one of the ways this problem can be exposed.  The failure to load case is or can be handled in other ways, but the dynamic allocation case I think is relatively poorly handled.  On my machine, I just punted by running on a virtual simulator that I pushed memory up to 48 MB and ignored the issue.  If anyone wants to try their hand at it, I'd be happy to review some patches.  For those on demand virtual memory systems, of course, the problem is invisible.  I didn't have any good ideas in this area.  Marking large memory test cases with size information, and then just trimming based upon size was my only thought.  Not exactly portable, as the exact size of any test case is of course target dependent; but, if we get close enough, it can provide enough of a solution I think.
>>
>> If people have better ideas in this area, even if you don't want to implement them, it'd be nice to hear about them.
> 
> After this commit (r249090), I've noticed that badalloc1.C fails at
> execution on aarch64 and arm bare-metal targets.
> 
> It is compiled with -DSTACK_SIZE=16384, maybe that's too small?

I think that what's going on is the following:
- your board description file for aarch64 and arm bare-metal sets
   gcc,stack_size
- before I committed the patch, STACK_SIZE was not defined when
   compiling this testcase, because the activated .exp files do not
   define it
- after I committed the patch, STACK_SIZE started to be defined, and
   the test started to fail

I'm not sure if this test was ever compiled with STACK_SIZE defined.

Either way, the test-case uses the presence of STACK_SIZE, not the 
actual value, so changing the value of gcc,stack_size won't make a 
difference.

Ideally you'd find out what the exact reason for the failure is, and 
update the test-case accordingly.

The easiest thing we can do is to remove the STACK_SIZE setting in the 
test-case (and to avoid confusion, remove all the dead 
STACK_SIZE-enabled code), which returns the status quo of before the patch.

Thanks,
- Tom

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH, testsuite] Add effective target stack_size
  2017-06-12 14:29     ` Tom de Vries
@ 2017-06-19  9:21       ` Christophe Lyon
  2017-06-19 15:42         ` Mike Stump
  0 siblings, 1 reply; 14+ messages in thread
From: Christophe Lyon @ 2017-06-19  9:21 UTC (permalink / raw)
  To: Tom de Vries; +Cc: GCC Patches, Rainer Orth

[-- Attachment #1: Type: text/plain, Size: 3497 bytes --]

On 12 June 2017 at 16:28, Tom de Vries <Tom_deVries@mentor.com> wrote:
> On 06/12/2017 02:28 PM, Christophe Lyon wrote:
>>
>> Hi Tom,
>>
>> On 9 June 2017 at 17:25, Mike Stump <mikestump@comcast.net> wrote:
>>>
>>> On Jun 9, 2017, at 7:24 AM, Tom de Vries <Tom_deVries@mentor.com> wrote:
>>>>
>>>> this patch adds effective target stack_size.
>>>
>>>
>>>> OK for trunk if x86_64 and nvptx testing succeeds?
>>>
>>>
>>> Ok.
>>>
>>> The only last issue in this area that I know about is that there are a
>>> few more test cases that need up to 48 MB to run, the problem is that
>>> targets might have substantially less memory.  Stack size is one of the ways
>>> this problem can be exposed.  The failure to load case is or can be handled
>>> in other ways, but the dynamic allocation case I think is relatively poorly
>>> handled.  On my machine, I just punted by running on a virtual simulator
>>> that I pushed memory up to 48 MB and ignored the issue.  If anyone wants to
>>> try their hand at it, I'd be happy to review some patches.  For those on
>>> demand virtual memory systems, of course, the problem is invisible.  I
>>> didn't have any good ideas in this area.  Marking large memory test cases
>>> with size information, and then just trimming based upon size was my only
>>> thought.  Not exactly portable, as the exact size of any test case is of
>>> course target dependent; but, if we get close enough, it can provide enough
>>> of a solution I think.
>>>
>>> If people have better ideas in this area, even if you don't want to
>>> implement them, it'd be nice to hear about them.
>>
>>
>> After this commit (r249090), I've noticed that badalloc1.C fails at
>> execution on aarch64 and arm bare-metal targets.
>>
>> It is compiled with -DSTACK_SIZE=16384, maybe that's too small?
>
>
> I think that what's going on is the following:
> - your board description file for aarch64 and arm bare-metal sets
>   gcc,stack_size
> - before I committed the patch, STACK_SIZE was not defined when
>   compiling this testcase, because the activated .exp files do not
>   define it
> - after I committed the patch, STACK_SIZE started to be defined, and
>   the test started to fail
>

I think you are right.

> I'm not sure if this test was ever compiled with STACK_SIZE defined.
>
> Either way, the test-case uses the presence of STACK_SIZE, not the actual
> value, so changing the value of gcc,stack_size won't make a difference.
>
> Ideally you'd find out what the exact reason for the failure is, and update
> the test-case accordingly.
>
> The easiest thing we can do is to remove the STACK_SIZE setting in the
> test-case (and to avoid confusion, remove all the dead STACK_SIZE-enabled
> code), which returns the status quo of before the patch.
>

I tried to compile with -DSTACK_SIZE & execute the test on x86, and
the first call to malloc() (as defined in the testcase) aborts. This call occurs
before entering main() and tries to allocate size=72704, which is
way larger than arena_size = 256 + 8 * 128 (=1280). This is with a
shared libstdc++.

Linking with -static also implies using
-Wl,--allow-multiple-definition, and leads
to a failure to allocate size=5280.

I too wonder whether the test ever worked with STACK_SIZE defined?
(Yet, arena_size was updated when PR64535 was fixed)

The attached patch removes the support for STACK_SIZE in the testcase
as you suggested, and it works fine (cross-tested on aarch64/arm targets)

OK for trunk?

Thanks,

Christophe


> Thanks,
> - Tom

[-- Attachment #2: badalloc.chlog.txt --]
[-- Type: text/plain, Size: 147 bytes --]

2017-06-19  Christophe Lyon  <christophe.lyon@linaro.org>

	gcc/testsuite/
	* g++.old-deja/g++.eh/badalloc1.C: Remove code path for
	-DSTACK_SIZE.

[-- Attachment #3: badalloc.patch.txt --]
[-- Type: text/plain, Size: 1587 bytes --]

diff --git a/gcc/testsuite/g++.old-deja/g++.eh/badalloc1.C b/gcc/testsuite/g++.old-deja/g++.eh/badalloc1.C
index f63d5c6..b660e84 100644
--- a/gcc/testsuite/g++.old-deja/g++.eh/badalloc1.C
+++ b/gcc/testsuite/g++.old-deja/g++.eh/badalloc1.C
@@ -3,7 +3,6 @@
 // itself call malloc(), and will fail if there is no more
 // memory available.
 // { dg-do run { xfail { { xstormy16-*-* *-*-darwin[3-7]* } || vxworks_rtp } } }
-// { dg-additional-options "-DSTACK_SIZE=[dg-effective-target-value stack_size]" { target { stack_size } } }
 // Copyright (C) 2000, 2002, 2003, 2010, 2012, 2014 Free Software Foundation, Inc.
 // Contributed by Nathan Sidwell 6 June 2000 <nathan@codesourcery.com>
 
@@ -16,12 +15,6 @@ extern "C" void *memcpy(void *, const void *, size_t);
 // libstdc++ requires a large initialization time allocation for the
 // emergency EH allocation pool.  Add that to the arena size.
 
-// Assume that STACK_SIZE defined implies a system that does not have a
-// large data space either, and additionally that we're not linking against
-// a shared libstdc++ (which requires quite a bit more initialization space).
-#ifdef STACK_SIZE
-const int arena_size = 256 + 8 * 128;
-#else
 #if defined(__FreeBSD__) || defined(__sun__) || defined(__hpux__)
 // FreeBSD, Solaris and HP-UX require even more space at initialization time.
 // FreeBSD 5 now requires over 131072 bytes.
@@ -32,7 +25,6 @@ const int arena_size = 262144 + 72 * 1024;
 // 32-bit-systems-based estimate.
 const int arena_size = 32768 * ((sizeof (void *) + 3)/4) + 72 * 1024;
 #endif
-#endif
 
 struct object
 {

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH, testsuite] Add effective target stack_size
  2017-06-19  9:21       ` Christophe Lyon
@ 2017-06-19 15:42         ` Mike Stump
  0 siblings, 0 replies; 14+ messages in thread
From: Mike Stump @ 2017-06-19 15:42 UTC (permalink / raw)
  To: Christophe Lyon; +Cc: Tom de Vries, GCC Patches, Rainer Orth

On Jun 19, 2017, at 2:21 AM, Christophe Lyon <christophe.lyon@linaro.org> wrote:
> 
> The attached patch removes the support for STACK_SIZE in the testcase
> as you suggested, and it works fine (cross-tested on aarch64/arm targets)
> 
> OK for trunk?

Ok.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Add dg-add-options feature stack_size
  2017-06-09 15:25 ` Mike Stump
  2017-06-12 12:28   ` Christophe Lyon
@ 2017-06-19 17:11   ` Tom de Vries
  2017-06-19 17:36     ` Mike Stump
  1 sibling, 1 reply; 14+ messages in thread
From: Tom de Vries @ 2017-06-19 17:11 UTC (permalink / raw)
  To: Mike Stump; +Cc: GCC Patches, Rainer Orth

[-- Attachment #1: Type: text/plain, Size: 1009 bytes --]

[ was: Re: [PATCH, testsuite] Add effective target stack_size ]

On 06/09/2017 05:25 PM, Mike Stump wrote:
> On Jun 9, 2017, at 7:24 AM, Tom de Vries<Tom_deVries@mentor.com>  wrote:
>> this patch adds effective target stack_size.
>> OK for trunk if x86_64 and nvptx testing succeeds?
> Ok.

Hi,

I came across dg-add-options, and wondered if adding a dg-add-options 
feature stack_size is a better way to make STACK_SIZE available.

Info looks like this:
...
7.2.3.12 Other attributes

'stack_size'
      Target has limited stack size.  The stack size limit can be
      obtained using the STACK_SIZE macro defined by *note
      'dg-add-options' feature 'stack_size': stack_size_ao.

7.2.4 Features for 'dg-add-options'

'stack_size'
      Add the flags needed to define macro STACK_SIZE and set it to the
      stack size limit associated with the *note 'stack_size' effective
      target: stack_size_et.
...

Incomplete (updated just one testcase) and untested.

OK if complete and tested?

Thanks,
- Tom

[-- Attachment #2: 0001-Add-dg-add-options-feature-stack_size.patch --]
[-- Type: text/x-patch, Size: 3259 bytes --]

Add dg-add-options feature stack_size

2017-06-19  Tom de Vries  <tom@codesourcery.com>

	* doc/sourcebuild.texi (Add Options, Features for dg-add-options): Add
	stack_size feature.
	(Effective-Target Keywords, Other attributes): Suggest using
	dg-add-options stack_size feature to get stack limit in stack_size
	effective target documentation.

	* lib/target-supports.exp (add_options_for_stack_size): New proc.
	* gcc.c-torture/execute/920501-7.c: Use dg-add-options stack_size.

---
 gcc/doc/sourcebuild.texi                       | 15 ++++++++++-----
 gcc/testsuite/gcc.c-torture/execute/920501-7.c |  2 +-
 gcc/testsuite/lib/target-supports.exp          | 11 +++++++++++
 3 files changed, 22 insertions(+), 6 deletions(-)

diff --git a/gcc/doc/sourcebuild.texi b/gcc/doc/sourcebuild.texi
index e5f0da6..7f5c2cf 100644
--- a/gcc/doc/sourcebuild.texi
+++ b/gcc/doc/sourcebuild.texi
@@ -2097,11 +2097,10 @@ Target supports section anchors.
 Target defaults to short enums.
 
 @item stack_size
-Target has limited stack size.  The stack size limit can be obtained using
-@code{[dg-effective-target-value stack_size]}.  For example:
-@smallexample
-/* @{ dg-additional-options "-DSTACK_SIZE=[dg-effective-target-value stack_size]" @{ target @{ stack_size @} @} @} */
-@end smallexample
+@anchor{stack_size_et}
+Target has limited stack size.  The stack size limit can be obtained using the
+STACK_SIZE macro defined by @ref{stack_size_ao,,@code{dg-add-options} feature
+@code{stack_size}}.
 
 @item static
 Target supports @option{-static}.
@@ -2282,6 +2281,12 @@ compliance mode.
 @code{mips16} function attributes.
 Only MIPS targets support this feature, and only then in certain modes.
 
+@item stack_size
+@anchor{stack_size_ao}
+Add the flags needed to define macro STACK_SIZE and set it to the stack size
+limit associated with the @ref{stack_size_et,,@code{stack_size} effective
+target}.
+
 @item tls
 Add the target-specific flags needed to use thread-local storage.
 @end table
diff --git a/gcc/testsuite/gcc.c-torture/execute/920501-7.c b/gcc/testsuite/gcc.c-torture/execute/920501-7.c
index 5cced09..1396eeb 100644
--- a/gcc/testsuite/gcc.c-torture/execute/920501-7.c
+++ b/gcc/testsuite/gcc.c-torture/execute/920501-7.c
@@ -1,6 +1,6 @@
 /* { dg-require-effective-target label_values } */
 /* { dg-require-effective-target trampolines } */
-/* { dg-additional-options "-DSTACK_SIZE=[dg-effective-target-value stack_size]" { target { stack_size } } } */
+/* { dg-add-options stack_size } */
 
 #ifdef STACK_SIZE
 #define DEPTH ((STACK_SIZE) / 512 + 1)
diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp
index 31701c2..502986e 100644
--- a/gcc/testsuite/lib/target-supports.exp
+++ b/gcc/testsuite/lib/target-supports.exp
@@ -7249,6 +7249,17 @@ proc add_options_for_double_vectors { flags } {
     return $flags
 }
 
+# Add to FLAGS the flags needed to define the STACK_SIZE macro.
+
+proc add_options_for_stack_size { flags } {
+    if [is-effective-target stack_size] {
+	set stack_size [dg-effective-target-value stack_size]
+	return "$flags -DSTACK_SIZE=$stack_size"
+    }
+
+    return $flags
+}
+
 # Return 1 if the target provides a full C99 runtime.
 
 proc check_effective_target_c99_runtime { } {

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Add dg-add-options feature stack_size
  2017-06-19 17:11   ` Add dg-add-options feature stack_size Tom de Vries
@ 2017-06-19 17:36     ` Mike Stump
  0 siblings, 0 replies; 14+ messages in thread
From: Mike Stump @ 2017-06-19 17:36 UTC (permalink / raw)
  To: Tom de Vries; +Cc: GCC Patches, Rainer Orth

On Jun 19, 2017, at 10:11 AM, Tom de Vries <Tom_deVries@mentor.com> wrote:
> 
> I came across dg-add-options, and wondered if adding a dg-add-options feature stack_size is a better way to make STACK_SIZE available.

I don't have a strong opinion here, but, it does look a tad simpler and nicer.

> OK if complete and tested?

Ok.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH, testsuite] Add effective target stack_size
  2017-06-09 14:24 [PATCH, testsuite] Add effective target stack_size Tom de Vries
  2017-06-09 15:25 ` Mike Stump
@ 2017-06-21 13:19 ` Jakub Jelinek
  2017-06-21 14:27   ` [testsuite, committed] Support dg-add-options in profopt.exp Tom de Vries
  2022-11-08 20:29 ` nvptx: stack size limits are relevant for execution only (was: [PATCH, testsuite] Add effective target stack_size) Thomas Schwinge
  2 siblings, 1 reply; 14+ messages in thread
From: Jakub Jelinek @ 2017-06-21 13:19 UTC (permalink / raw)
  To: Tom de Vries; +Cc: GCC Patches, Mike Stump, Rainer Orth

On Fri, Jun 09, 2017 at 04:24:30PM +0200, Tom de Vries wrote:
> 	* gcc.dg/tree-prof/comp-goto-1.c: Same.
> 	* gcc.dg/tree-prof/pr44777.c: Same.

> --- a/gcc/testsuite/gcc.dg/tree-prof/comp-goto-1.c
> +++ b/gcc/testsuite/gcc.dg/tree-prof/comp-goto-1.c
> @@ -1,6 +1,8 @@
>  /* { dg-require-effective-target freorder } */
>  /* { dg-require-effective-target label_values } */
>  /* { dg-options "-O2 -freorder-blocks-and-partition" } */
> +/* { dg-additional-options "-DSTACK_SIZE=[dg-effective-target-value stack_size]" { target { stack_size } } } */
> +
>  #include <stdlib.h>
>  
>  #if (!defined(STACK_SIZE) || STACK_SIZE >= 4000) && __INT_MAX__ >= 2147483647
> diff --git a/gcc/testsuite/gcc.dg/tree-prof/pr44777.c b/gcc/testsuite/gcc.dg/tree-prof/pr44777.c
> index 4074b75..1249b5b 100644
> --- a/gcc/testsuite/gcc.dg/tree-prof/pr44777.c
> +++ b/gcc/testsuite/gcc.dg/tree-prof/pr44777.c
> @@ -2,6 +2,8 @@
>  /* { dg-require-effective-target label_values } */
>  /* { dg-require-effective-target trampolines } */
>  /* { dg-options "-O0" } */
> +/* { dg-additional-options "-DSTACK_SIZE=[dg-effective-target-value stack_size]" { target { stack_size } } } */
> +
>  /* A variant of gcc.c-torture/execute/comp-goto-2.c.  */
>  
>  extern void abort (void);

I'm now seeing
WARNING: profopt.exp does not support dg-add-options
WARNING: profopt.exp does not support dg-add-options
so the above doesn't look correct.

	Jakub

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [testsuite, committed] Support dg-add-options in profopt.exp
  2017-06-21 13:19 ` [PATCH, testsuite] Add effective target stack_size Jakub Jelinek
@ 2017-06-21 14:27   ` Tom de Vries
  0 siblings, 0 replies; 14+ messages in thread
From: Tom de Vries @ 2017-06-21 14:27 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: GCC Patches, Mike Stump, Rainer Orth

[-- Attachment #1: Type: text/plain, Size: 2046 bytes --]

[ was: Re: [PATCH, testsuite] Add effective target stack_size ]

On 06/21/2017 03:19 PM, Jakub Jelinek wrote:
> On Fri, Jun 09, 2017 at 04:24:30PM +0200, Tom de Vries wrote:
>> 	* gcc.dg/tree-prof/comp-goto-1.c: Same.
>> 	* gcc.dg/tree-prof/pr44777.c: Same.
> 
>> --- a/gcc/testsuite/gcc.dg/tree-prof/comp-goto-1.c
>> +++ b/gcc/testsuite/gcc.dg/tree-prof/comp-goto-1.c
>> @@ -1,6 +1,8 @@
>>   /* { dg-require-effective-target freorder } */
>>   /* { dg-require-effective-target label_values } */
>>   /* { dg-options "-O2 -freorder-blocks-and-partition" } */
>> +/* { dg-additional-options "-DSTACK_SIZE=[dg-effective-target-value stack_size]" { target { stack_size } } } */
>> +
>>   #include <stdlib.h>
>>   
>>   #if (!defined(STACK_SIZE) || STACK_SIZE >= 4000) && __INT_MAX__ >= 2147483647
>> diff --git a/gcc/testsuite/gcc.dg/tree-prof/pr44777.c b/gcc/testsuite/gcc.dg/tree-prof/pr44777.c
>> index 4074b75..1249b5b 100644
>> --- a/gcc/testsuite/gcc.dg/tree-prof/pr44777.c
>> +++ b/gcc/testsuite/gcc.dg/tree-prof/pr44777.c
>> @@ -2,6 +2,8 @@
>>   /* { dg-require-effective-target label_values } */
>>   /* { dg-require-effective-target trampolines } */
>>   /* { dg-options "-O0" } */
>> +/* { dg-additional-options "-DSTACK_SIZE=[dg-effective-target-value stack_size]" { target { stack_size } } } */
>> +
>>   /* A variant of gcc.c-torture/execute/comp-goto-2.c.  */
>>   
>>   extern void abort (void);
> 
> I'm now seeing
> WARNING: profopt.exp does not support dg-add-options
> WARNING: profopt.exp does not support dg-add-options
> so the above doesn't look correct.

Thanks for pointing that out. I've double-checked, and the warnings did 
appear for me in the testlogs, but my automated test-comparison 
reporting did not pick up on that, I'll have to fix that.

Fixed the warnings by adding dg-add-options support in profopt-get-options.

Tested both test-cases on x86_64.

Tested both test-cases on x86_64 with effective target stack_size set to 
0, and verified that -DSTACK_SIZE=0 was passed.

Committed as obvious.

Thanks,
- Tom

[-- Attachment #2: 0002-Support-dg-add-options-in-profopt.exp.patch --]
[-- Type: text/x-patch, Size: 796 bytes --]

Support dg-add-options in profopt.exp

2017-06-21  Tom de Vries  <tom@codesourcery.com>

	* lib/profopt.exp (profopt-get-options): Support dg-add-options.

---
 gcc/testsuite/lib/profopt.exp | 1 +
 1 file changed, 1 insertion(+)

diff --git a/gcc/testsuite/lib/profopt.exp b/gcc/testsuite/lib/profopt.exp
index 6519c44..0ea8e7a 100644
--- a/gcc/testsuite/lib/profopt.exp
+++ b/gcc/testsuite/lib/profopt.exp
@@ -249,6 +249,7 @@ proc profopt-get-options { src } {
 	set cmd [lindex $op 0]
 	if { ![string compare "dg-options" $cmd] \
 	     || ![string compare "dg-additional-options" $cmd] \
+	     || ![string compare "dg-add-options" $cmd] \
 	     || ![string compare "dg-skip-if" $cmd] \
 	     || ![string compare "dg-final-generate" $cmd] \
 	     || ![string compare "dg-final-use" $cmd] \

^ permalink raw reply	[flat|nested] 14+ messages in thread

* nvptx: stack size limits are relevant for execution only (was: [PATCH, testsuite] Add effective target stack_size)
  2017-06-09 14:24 [PATCH, testsuite] Add effective target stack_size Tom de Vries
  2017-06-09 15:25 ` Mike Stump
  2017-06-21 13:19 ` [PATCH, testsuite] Add effective target stack_size Jakub Jelinek
@ 2022-11-08 20:29 ` Thomas Schwinge
  2022-11-25 11:09   ` [PING] " Thomas Schwinge
  2 siblings, 1 reply; 14+ messages in thread
From: Thomas Schwinge @ 2022-11-08 20:29 UTC (permalink / raw)
  To: Tom de Vries, gcc-patches, Mike Stump, Rainer Orth

[-- Attachment #1: Type: text/plain, Size: 784 bytes --]

Hi!

On 2017-06-09T16:24:30+0200, Tom de Vries <Tom_deVries@mentor.com> wrote:
> The patch defines an effective target stack_size, which is used in
> individual test-cases to add -DSTACK_SIZE=<value> [...]

> gccint.info (edited for long lines):
> ...
> 7.2.3.12 Other attributes
> .........................
>
> 'stack_size'
>       Target has limited stack size.  [...]

On top of that, OK to push the attached
"nvptx: stack size limits are relevant for execution only"?


Grüße
 Thomas


-----------------
Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht München, HRB 106955

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-nvptx-stack-size-limits-are-relevant-for-execution-o.patch --]
[-- Type: text/x-diff, Size: 2872 bytes --]

From 158a077129cb1579b93ddf440a5bb60b457e4b7c Mon Sep 17 00:00:00 2001
From: Thomas Schwinge <thomas@codesourcery.com>
Date: Tue, 8 Nov 2022 12:10:03 +0100
Subject: [PATCH] nvptx: stack size limits are relevant for execution only

For non-'dg-do run' test cases, that means: big 'dg-require-stack-size' need
not be UNSUPPORTED (and indeed now do all PASS), 'dg-add-options stack_size'
need not define (and thus limit) 'STACK_SIZE' (and still do all PASS).

Re "Find 'dg-do-what' in an outer frame", currently (sources not completely
clean, though), we've got:

    $ git grep -F 'check_effective_target_stack_size: found dg-do-what at level ' -- build-gcc/\*.log | sort | uniq -c
          6 build-gcc/gcc/testsuite/gcc/gcc.log:check_effective_target_stack_size: found dg-do-what at level 2
        267 build-gcc/gcc/testsuite/gcc/gcc.log:check_effective_target_stack_size: found dg-do-what at level 3
        239 build-gcc/gcc/testsuite/gcc/gcc.log:check_effective_target_stack_size: found dg-do-what at level 4

	gcc/testsuite/
	* lib/target-supports.exp (check_effective_target_stack_size): For
	nvptx target, stack size limits are relevant for execution only.
	gcc/
	* doc/sourcebuild.texi (stack_size): Update.
---
 gcc/doc/sourcebuild.texi              |  4 ++++
 gcc/testsuite/lib/target-supports.exp | 16 ++++++++++++++++
 2 files changed, 20 insertions(+)

diff --git a/gcc/doc/sourcebuild.texi b/gcc/doc/sourcebuild.texi
index 137f00aadc1f..5bbf6fc55909 100644
--- a/gcc/doc/sourcebuild.texi
+++ b/gcc/doc/sourcebuild.texi
@@ -2848,6 +2848,10 @@ Target has limited stack size.  The stack size limit can be obtained using the
 STACK_SIZE macro defined by @ref{stack_size_ao,,@code{dg-add-options} feature
 @code{stack_size}}.
 
+Note that for certain targets, stack size limits are relevant for
+execution only, and therefore considered only if @code{dg-do run} is
+in effect, otherwise unlimited.
+
 @item static
 Target supports @option{-static}.
 
diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp
index 750897d08548..39ed1723b03a 100644
--- a/gcc/testsuite/lib/target-supports.exp
+++ b/gcc/testsuite/lib/target-supports.exp
@@ -625,6 +625,22 @@ proc check_effective_target_trampolines { } {
 # Return 1 if target has limited stack size.
 
 proc check_effective_target_stack_size { } {
+    # For nvptx target, stack size limits are relevant for execution only.
+    if { [istarget nvptx-*-*] } {
+	# Find 'dg-do-what' in an outer frame.
+	set level 1
+	while true {
+	    upvar $level dg-do-what dg-do-what
+	    if [info exists dg-do-what] then break
+	    incr level
+	}
+	verbose "check_effective_target_stack_size: found dg-do-what at level $level" 2
+
+	if { ![string equal [lindex ${dg-do-what} 0] run] } {
+	    return 0
+	}
+    }
+
     if [target_info exists gcc,stack_size] {
 	return 1
     }
-- 
2.35.1


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PING] nvptx: stack size limits are relevant for execution only (was: [PATCH, testsuite] Add effective target stack_size)
  2022-11-08 20:29 ` nvptx: stack size limits are relevant for execution only (was: [PATCH, testsuite] Add effective target stack_size) Thomas Schwinge
@ 2022-11-25 11:09   ` Thomas Schwinge
  2022-12-20  7:55     ` [PING^2] " Thomas Schwinge
  0 siblings, 1 reply; 14+ messages in thread
From: Thomas Schwinge @ 2022-11-25 11:09 UTC (permalink / raw)
  To: Tom de Vries, gcc-patches, Mike Stump, Rainer Orth

[-- Attachment #1: Type: text/plain, Size: 889 bytes --]

Hi!

Ping.


Grüße
 Thomas


On 2022-11-08T21:29:49+0100, I wrote:
> Hi!
>
> On 2017-06-09T16:24:30+0200, Tom de Vries <Tom_deVries@mentor.com> wrote:
>> The patch defines an effective target stack_size, which is used in
>> individual test-cases to add -DSTACK_SIZE=<value> [...]
>
>> gccint.info (edited for long lines):
>> ...
>> 7.2.3.12 Other attributes
>> .........................
>>
>> 'stack_size'
>>       Target has limited stack size.  [...]
>
> On top of that, OK to push the attached
> "nvptx: stack size limits are relevant for execution only"?
>
>
> Grüße
>  Thomas


-----------------
Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht München, HRB 106955

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-nvptx-stack-size-limits-are-relevant-for-execution-o.patch --]
[-- Type: text/x-diff, Size: 2872 bytes --]

From 158a077129cb1579b93ddf440a5bb60b457e4b7c Mon Sep 17 00:00:00 2001
From: Thomas Schwinge <thomas@codesourcery.com>
Date: Tue, 8 Nov 2022 12:10:03 +0100
Subject: [PATCH] nvptx: stack size limits are relevant for execution only

For non-'dg-do run' test cases, that means: big 'dg-require-stack-size' need
not be UNSUPPORTED (and indeed now do all PASS), 'dg-add-options stack_size'
need not define (and thus limit) 'STACK_SIZE' (and still do all PASS).

Re "Find 'dg-do-what' in an outer frame", currently (sources not completely
clean, though), we've got:

    $ git grep -F 'check_effective_target_stack_size: found dg-do-what at level ' -- build-gcc/\*.log | sort | uniq -c
          6 build-gcc/gcc/testsuite/gcc/gcc.log:check_effective_target_stack_size: found dg-do-what at level 2
        267 build-gcc/gcc/testsuite/gcc/gcc.log:check_effective_target_stack_size: found dg-do-what at level 3
        239 build-gcc/gcc/testsuite/gcc/gcc.log:check_effective_target_stack_size: found dg-do-what at level 4

	gcc/testsuite/
	* lib/target-supports.exp (check_effective_target_stack_size): For
	nvptx target, stack size limits are relevant for execution only.
	gcc/
	* doc/sourcebuild.texi (stack_size): Update.
---
 gcc/doc/sourcebuild.texi              |  4 ++++
 gcc/testsuite/lib/target-supports.exp | 16 ++++++++++++++++
 2 files changed, 20 insertions(+)

diff --git a/gcc/doc/sourcebuild.texi b/gcc/doc/sourcebuild.texi
index 137f00aadc1f..5bbf6fc55909 100644
--- a/gcc/doc/sourcebuild.texi
+++ b/gcc/doc/sourcebuild.texi
@@ -2848,6 +2848,10 @@ Target has limited stack size.  The stack size limit can be obtained using the
 STACK_SIZE macro defined by @ref{stack_size_ao,,@code{dg-add-options} feature
 @code{stack_size}}.
 
+Note that for certain targets, stack size limits are relevant for
+execution only, and therefore considered only if @code{dg-do run} is
+in effect, otherwise unlimited.
+
 @item static
 Target supports @option{-static}.
 
diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp
index 750897d08548..39ed1723b03a 100644
--- a/gcc/testsuite/lib/target-supports.exp
+++ b/gcc/testsuite/lib/target-supports.exp
@@ -625,6 +625,22 @@ proc check_effective_target_trampolines { } {
 # Return 1 if target has limited stack size.
 
 proc check_effective_target_stack_size { } {
+    # For nvptx target, stack size limits are relevant for execution only.
+    if { [istarget nvptx-*-*] } {
+	# Find 'dg-do-what' in an outer frame.
+	set level 1
+	while true {
+	    upvar $level dg-do-what dg-do-what
+	    if [info exists dg-do-what] then break
+	    incr level
+	}
+	verbose "check_effective_target_stack_size: found dg-do-what at level $level" 2
+
+	if { ![string equal [lindex ${dg-do-what} 0] run] } {
+	    return 0
+	}
+    }
+
     if [target_info exists gcc,stack_size] {
 	return 1
     }
-- 
2.35.1


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PING^2] nvptx: stack size limits are relevant for execution only (was: [PATCH, testsuite] Add effective target stack_size)
  2022-11-25 11:09   ` [PING] " Thomas Schwinge
@ 2022-12-20  7:55     ` Thomas Schwinge
  2023-01-11 11:45       ` [PING^3] " Thomas Schwinge
  0 siblings, 1 reply; 14+ messages in thread
From: Thomas Schwinge @ 2022-12-20  7:55 UTC (permalink / raw)
  To: Tom de Vries, gcc-patches, Mike Stump, Rainer Orth

[-- Attachment #1: Type: text/plain, Size: 1003 bytes --]

Hi!

Ping.


Grüße
 Thomas


On 2022-11-25T12:09:36+0100, I wrote:
> Hi!
>
> Ping.
>
>
> Grüße
>  Thomas
>
>
> On 2022-11-08T21:29:49+0100, I wrote:
>> Hi!
>>
>> On 2017-06-09T16:24:30+0200, Tom de Vries <Tom_deVries@mentor.com> wrote:
>>> The patch defines an effective target stack_size, which is used in
>>> individual test-cases to add -DSTACK_SIZE=<value> [...]
>>
>>> gccint.info (edited for long lines):
>>> ...
>>> 7.2.3.12 Other attributes
>>> .........................
>>>
>>> 'stack_size'
>>>       Target has limited stack size.  [...]
>>
>> On top of that, OK to push the attached
>> "nvptx: stack size limits are relevant for execution only"?
>>
>>
>> Grüße
>>  Thomas


-----------------
Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht München, HRB 106955

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-nvptx-stack-size-limits-are-relevant-for-execution-o.patch --]
[-- Type: text/x-diff, Size: 2872 bytes --]

From 158a077129cb1579b93ddf440a5bb60b457e4b7c Mon Sep 17 00:00:00 2001
From: Thomas Schwinge <thomas@codesourcery.com>
Date: Tue, 8 Nov 2022 12:10:03 +0100
Subject: [PATCH] nvptx: stack size limits are relevant for execution only

For non-'dg-do run' test cases, that means: big 'dg-require-stack-size' need
not be UNSUPPORTED (and indeed now do all PASS), 'dg-add-options stack_size'
need not define (and thus limit) 'STACK_SIZE' (and still do all PASS).

Re "Find 'dg-do-what' in an outer frame", currently (sources not completely
clean, though), we've got:

    $ git grep -F 'check_effective_target_stack_size: found dg-do-what at level ' -- build-gcc/\*.log | sort | uniq -c
          6 build-gcc/gcc/testsuite/gcc/gcc.log:check_effective_target_stack_size: found dg-do-what at level 2
        267 build-gcc/gcc/testsuite/gcc/gcc.log:check_effective_target_stack_size: found dg-do-what at level 3
        239 build-gcc/gcc/testsuite/gcc/gcc.log:check_effective_target_stack_size: found dg-do-what at level 4

	gcc/testsuite/
	* lib/target-supports.exp (check_effective_target_stack_size): For
	nvptx target, stack size limits are relevant for execution only.
	gcc/
	* doc/sourcebuild.texi (stack_size): Update.
---
 gcc/doc/sourcebuild.texi              |  4 ++++
 gcc/testsuite/lib/target-supports.exp | 16 ++++++++++++++++
 2 files changed, 20 insertions(+)

diff --git a/gcc/doc/sourcebuild.texi b/gcc/doc/sourcebuild.texi
index 137f00aadc1f..5bbf6fc55909 100644
--- a/gcc/doc/sourcebuild.texi
+++ b/gcc/doc/sourcebuild.texi
@@ -2848,6 +2848,10 @@ Target has limited stack size.  The stack size limit can be obtained using the
 STACK_SIZE macro defined by @ref{stack_size_ao,,@code{dg-add-options} feature
 @code{stack_size}}.
 
+Note that for certain targets, stack size limits are relevant for
+execution only, and therefore considered only if @code{dg-do run} is
+in effect, otherwise unlimited.
+
 @item static
 Target supports @option{-static}.
 
diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp
index 750897d08548..39ed1723b03a 100644
--- a/gcc/testsuite/lib/target-supports.exp
+++ b/gcc/testsuite/lib/target-supports.exp
@@ -625,6 +625,22 @@ proc check_effective_target_trampolines { } {
 # Return 1 if target has limited stack size.
 
 proc check_effective_target_stack_size { } {
+    # For nvptx target, stack size limits are relevant for execution only.
+    if { [istarget nvptx-*-*] } {
+	# Find 'dg-do-what' in an outer frame.
+	set level 1
+	while true {
+	    upvar $level dg-do-what dg-do-what
+	    if [info exists dg-do-what] then break
+	    incr level
+	}
+	verbose "check_effective_target_stack_size: found dg-do-what at level $level" 2
+
+	if { ![string equal [lindex ${dg-do-what} 0] run] } {
+	    return 0
+	}
+    }
+
     if [target_info exists gcc,stack_size] {
 	return 1
     }
-- 
2.35.1


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PING^3] nvptx: stack size limits are relevant for execution only (was: [PATCH, testsuite] Add effective target stack_size)
  2022-12-20  7:55     ` [PING^2] " Thomas Schwinge
@ 2023-01-11 11:45       ` Thomas Schwinge
  0 siblings, 0 replies; 14+ messages in thread
From: Thomas Schwinge @ 2023-01-11 11:45 UTC (permalink / raw)
  To: Tom de Vries, gcc-patches, Mike Stump, Rainer Orth

[-- Attachment #1: Type: text/plain, Size: 1127 bytes --]

Hi!

Ping.


Grüße
 Thomas


On 2022-12-20T08:55:08+0100, I wrote:
> Hi!
>
> Ping.
>
>
> Grüße
>  Thomas
>
>
> On 2022-11-25T12:09:36+0100, I wrote:
>> Hi!
>>
>> Ping.
>>
>>
>> Grüße
>>  Thomas
>>
>>
>> On 2022-11-08T21:29:49+0100, I wrote:
>>> Hi!
>>>
>>> On 2017-06-09T16:24:30+0200, Tom de Vries <Tom_deVries@mentor.com> wrote:
>>>> The patch defines an effective target stack_size, which is used in
>>>> individual test-cases to add -DSTACK_SIZE=<value> [...]
>>>
>>>> gccint.info (edited for long lines):
>>>> ...
>>>> 7.2.3.12 Other attributes
>>>> .........................
>>>>
>>>> 'stack_size'
>>>>       Target has limited stack size.  [...]
>>>
>>> On top of that, OK to push the attached
>>> "nvptx: stack size limits are relevant for execution only"?
>>>
>>>
>>> Grüße
>>>  Thomas


-----------------
Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht München, HRB 106955

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-nvptx-stack-size-limits-are-relevant-for-execution-o.patch --]
[-- Type: text/x-diff, Size: 2872 bytes --]

From 158a077129cb1579b93ddf440a5bb60b457e4b7c Mon Sep 17 00:00:00 2001
From: Thomas Schwinge <thomas@codesourcery.com>
Date: Tue, 8 Nov 2022 12:10:03 +0100
Subject: [PATCH] nvptx: stack size limits are relevant for execution only

For non-'dg-do run' test cases, that means: big 'dg-require-stack-size' need
not be UNSUPPORTED (and indeed now do all PASS), 'dg-add-options stack_size'
need not define (and thus limit) 'STACK_SIZE' (and still do all PASS).

Re "Find 'dg-do-what' in an outer frame", currently (sources not completely
clean, though), we've got:

    $ git grep -F 'check_effective_target_stack_size: found dg-do-what at level ' -- build-gcc/\*.log | sort | uniq -c
          6 build-gcc/gcc/testsuite/gcc/gcc.log:check_effective_target_stack_size: found dg-do-what at level 2
        267 build-gcc/gcc/testsuite/gcc/gcc.log:check_effective_target_stack_size: found dg-do-what at level 3
        239 build-gcc/gcc/testsuite/gcc/gcc.log:check_effective_target_stack_size: found dg-do-what at level 4

	gcc/testsuite/
	* lib/target-supports.exp (check_effective_target_stack_size): For
	nvptx target, stack size limits are relevant for execution only.
	gcc/
	* doc/sourcebuild.texi (stack_size): Update.
---
 gcc/doc/sourcebuild.texi              |  4 ++++
 gcc/testsuite/lib/target-supports.exp | 16 ++++++++++++++++
 2 files changed, 20 insertions(+)

diff --git a/gcc/doc/sourcebuild.texi b/gcc/doc/sourcebuild.texi
index 137f00aadc1f..5bbf6fc55909 100644
--- a/gcc/doc/sourcebuild.texi
+++ b/gcc/doc/sourcebuild.texi
@@ -2848,6 +2848,10 @@ Target has limited stack size.  The stack size limit can be obtained using the
 STACK_SIZE macro defined by @ref{stack_size_ao,,@code{dg-add-options} feature
 @code{stack_size}}.
 
+Note that for certain targets, stack size limits are relevant for
+execution only, and therefore considered only if @code{dg-do run} is
+in effect, otherwise unlimited.
+
 @item static
 Target supports @option{-static}.
 
diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp
index 750897d08548..39ed1723b03a 100644
--- a/gcc/testsuite/lib/target-supports.exp
+++ b/gcc/testsuite/lib/target-supports.exp
@@ -625,6 +625,22 @@ proc check_effective_target_trampolines { } {
 # Return 1 if target has limited stack size.
 
 proc check_effective_target_stack_size { } {
+    # For nvptx target, stack size limits are relevant for execution only.
+    if { [istarget nvptx-*-*] } {
+	# Find 'dg-do-what' in an outer frame.
+	set level 1
+	while true {
+	    upvar $level dg-do-what dg-do-what
+	    if [info exists dg-do-what] then break
+	    incr level
+	}
+	verbose "check_effective_target_stack_size: found dg-do-what at level $level" 2
+
+	if { ![string equal [lindex ${dg-do-what} 0] run] } {
+	    return 0
+	}
+    }
+
     if [target_info exists gcc,stack_size] {
 	return 1
     }
-- 
2.35.1


^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2023-01-11 11:45 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-09 14:24 [PATCH, testsuite] Add effective target stack_size Tom de Vries
2017-06-09 15:25 ` Mike Stump
2017-06-12 12:28   ` Christophe Lyon
2017-06-12 14:29     ` Tom de Vries
2017-06-19  9:21       ` Christophe Lyon
2017-06-19 15:42         ` Mike Stump
2017-06-19 17:11   ` Add dg-add-options feature stack_size Tom de Vries
2017-06-19 17:36     ` Mike Stump
2017-06-21 13:19 ` [PATCH, testsuite] Add effective target stack_size Jakub Jelinek
2017-06-21 14:27   ` [testsuite, committed] Support dg-add-options in profopt.exp Tom de Vries
2022-11-08 20:29 ` nvptx: stack size limits are relevant for execution only (was: [PATCH, testsuite] Add effective target stack_size) Thomas Schwinge
2022-11-25 11:09   ` [PING] " Thomas Schwinge
2022-12-20  7:55     ` [PING^2] " Thomas Schwinge
2023-01-11 11:45       ` [PING^3] " Thomas Schwinge

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).