diff mbox series

Add gcc.dg/stack-check-16.c

Message ID 20180119112204.GT2063@tucnak
State New
Headers show
Series Add gcc.dg/stack-check-16.c | expand

Commit Message

Jakub Jelinek Jan. 19, 2018, 11:22 a.m. UTC
Hi!

This patch adds a new testcases, not exactly sure what is the exact
origin and what was the problem.  The changes I've done are:
1) macroize, so that the test is just a few lines rather than 160KB,
   verified -fdump-tree-gimple printf call is identical between this
   and the original test
2) remove optimize(0) attribute, the test is compiled with -O0
3) use __builtin_alloca instead of alloca and add mtrace prototype,
   remove -w because no warnings are emitted any longer

The test passes at least on x86_64-linux with -m32/-m64.  Ok for trunk?

2018-01-19  Jeff Law  <law@redhat.com>
	    Jakub Jelinek  <jakub@redhat.com>

	* gcc.dg/stack-check-16.c: New test.


	Jakub

Comments

Jeff Law Jan. 19, 2018, 6:08 p.m. UTC | #1
On 01/19/2018 04:22 AM, Jakub Jelinek wrote:
> Hi!
> 
> This patch adds a new testcases, not exactly sure what is the exact
> origin and what was the problem.  The changes I've done are:
> 1) macroize, so that the test is just a few lines rather than 160KB,
>    verified -fdump-tree-gimple printf call is identical between this
>    and the original test
> 2) remove optimize(0) attribute, the test is compiled with -O0
> 3) use __builtin_alloca instead of alloca and add mtrace prototype,
>    remove -w because no warnings are emitted any longer
> 
> The test passes at least on x86_64-linux with -m32/-m64.  Ok for trunk?
> 
> 2018-01-19  Jeff Law  <law@redhat.com>
> 	    Jakub Jelinek  <jakub@redhat.com>
> 
> 	* gcc.dg/stack-check-16.c: New test.
OK.

I've been wandering my mailboxes to find the discussion which led to
this test, but can't seem to find it.  Based on the structure of the
test I'm pretty sure it is related to a large outgoing argument area.

THe fact that it wasn't submitted upstream, but was in the aarch64
bundle means it was probably related to the need to probe the outgoing
argument area which is specific to aarch64.

Without any scanning of dump files or assembly output it must have been
an ICE in that code.  The thing that worries me is I can't recall fixing
such an ICE!

But again, OK for the trunk.

Jeff
diff mbox series

Patch

--- gcc/testsuite/gcc.dg/stack-check-16.c.jj	2018-01-19 11:58:39.325950389 +0100
+++ gcc/testsuite/gcc.dg/stack-check-16.c	2018-01-19 11:50:34.856026594 +0100
@@ -0,0 +1,36 @@ 
+/* { dg-do compile } */
+/* { dg-options "-fstack-clash-protection" } */
+/* { dg-require-effective-target supports_stack_clash_protection } */
+
+int printf (const char *, ...);
+void blah (char *space) { }
+void mtrace (void);
+
+int do_test (void)
+{
+    blah (__builtin_alloca (10));
+    mtrace ();
+    printf (
+#define A(a) "%" #a "$s"
+#define B(a) A(a)
+#define C(a,b,c,d) B(a##b##c##d)
+#define D(a,b,c) C(a,b,c,1) C(a,b,c,2) C(a,b,c,3) C(a,b,c,4) C(a,b,c,5) \
+		 C(a,b,c,6) C(a,b,c,7) C(a,b,c,8) C(a,b,c,9)
+#define E(a,b,c) C(a,b,c,0) D(a,b,c)
+#define F(a,b) E(a,b,1) E(a,b,2) E(a,b,3) E(a,b,4) E(a,b,5) \
+	       E(a,b,6) E(a,b,7) E(a,b,8) E(a,b,9)
+#define G(a,b) E(a,b,0) F(a,b)
+#define H(a) G(a,1) G(a,2) G(a,3) G(a,4) G(a,5) G(a,6) G(a,7) G(a,8) G(a,9)
+#define I(a) G(a,0) H(a)
+#define J I(1) I(2) I(3) I(4) I(5) I(6) I(7) I(8) I(9)
+	    D(,,)
+	    F(,)
+	    H()
+	    J
+	    C(10,0,0,0) C(10,0,0,1),
+#undef A
+#define A(a) "a",
+	    I(0) J
+	    "\n");
+  return 0;
+}