(root)/
gcc-13.2.0/
gcc/
testsuite/
gcc.dg/
stack-check-8.c
       1  /* { dg-do run } */
       2  /* { dg-options "-O2 -fstack-clash-protection -Wno-psabi -fno-optimize-sibling-calls --param stack-clash-protection-probe-interval=12 --param stack-clash-protection-guard-size=12" } */
       3  /* { dg-require-effective-target supports_stack_clash_protection } */
       4  
       5  
       6  typedef float V __attribute__((vector_size (32)));
       7  
       8  __attribute__((noinline, noclone)) void
       9  foo (char *p)
      10  {
      11    asm volatile ("" : : "r" (p) : "memory");
      12  }
      13  
      14  __attribute__((noinline, noclone)) int
      15  f0 (int x, int y)
      16  {
      17    asm volatile ("" : : : "memory");  
      18    return x + y;
      19  }
      20  
      21  __attribute__((noinline, noclone)) void
      22  f1 (void)
      23  {
      24    char buf[64];
      25    foo (buf);
      26  }
      27  
      28  __attribute__((noinline, noclone)) void
      29  f2 (void)
      30  {
      31    char buf[12000];
      32    foo (buf);
      33  }
      34  
      35  __attribute__((noinline, noclone)) void
      36  f3 (void)
      37  {
      38    char buf[131072];
      39    foo (buf);
      40  }
      41  
      42  __attribute__((noinline, noclone)) void
      43  f4 (int x)
      44  {
      45    char vla[x];
      46    foo (vla);
      47  }
      48  
      49  __attribute__((noinline, noclone)) void
      50  f5 (int x)
      51  {
      52    char buf[12000];
      53    foo (buf);
      54    {
      55      char vla[x];
      56      foo (vla);
      57    }
      58    {
      59      char vla[x];
      60      foo (vla);
      61    }
      62  }
      63  
      64  V v;
      65  
      66  __attribute__((noinline, noclone)) int
      67  f6 (int x, int y, V a, V b, V c)
      68  {
      69    asm volatile ("" : : : "memory");  
      70    v = a + b + c;
      71    return x + y;
      72  }
      73  
      74  __attribute__((noinline, noclone)) void
      75  f7 (V a, V b, V c)
      76  {
      77    char buf[64];
      78    foo (buf);
      79    v = a + b + c;
      80  }
      81  
      82  __attribute__((noinline, noclone)) void
      83  f8 (V a, V b, V c)
      84  {
      85    char buf[12000];
      86    foo (buf);
      87    v = a + b + c;
      88  }
      89  
      90  __attribute__((noinline, noclone)) void
      91  f9 (V a, V b, V c)
      92  {
      93    char buf[131072];
      94    foo (buf);
      95    v = a + b + c;
      96  }
      97  
      98  __attribute__((noinline, noclone)) void
      99  f10 (int x, V a, V b, V c)
     100  {
     101    char vla[x];
     102    foo (vla);
     103    v = a + b + c;
     104  }
     105  
     106  __attribute__((noinline, noclone)) void
     107  f11 (int x, V a, V b, V c)
     108  {
     109    char buf[12000];
     110    foo (buf);
     111    v = a + b + c;
     112    {
     113      char vla[x];
     114      foo (vla);
     115    }
     116    {
     117      char vla[x];
     118      foo (vla);
     119    }
     120  }
     121  
     122  int
     123  main ()
     124  {
     125    f0 (2, 3);
     126    f1 ();
     127    f2 ();
     128    f3 ();
     129    f4 (12000);
     130    f5 (12000);
     131    f6 (2, 3, v, v, v);
     132    f7 (v, v, v);
     133    f8 (v, v, v);
     134    f9 (v, v, v);
     135    f10 (12000, v, v, v);
     136    f11 (12000, v, v, v);
     137    return 0;
     138  }
     139