Add new test to verify that the array index, limit, and stride are
[official-gcc.git] / gcc / testsuite / gcc.dg / stack-usage-1.c
blobb6524f9a1255566d70eee6afcd206381867e88ed
1 /* { dg-do compile } */
2 /* { dg-options "-fstack-usage" } */
4 /* This is aimed at testing basic support for -fstack-usage in the back-ends.
5 See the SPARC back-end for example (grep flag_stack_usage_info in sparc.c).
6 Once it is implemented, adjust SIZE below so that the stack usage for the
7 function FOO is reported as 256 or 264 in the stack usage (.su) file.
8 Then check that this is the actual stack usage in the assembly file. */
10 #if defined(__aarch64__)
11 # define SIZE 256 /* No frame pointer for leaf functions (default) */
12 #elif defined(__i386__)
13 # define SIZE 248
14 #elif defined(__x86_64__)
15 # ifndef _WIN64
16 # define SIZE 356
17 # else
18 # define SIZE (256 - 24)
19 # endif
20 #elif defined (__sparc__)
21 # if defined (__arch64__)
22 # define SIZE 76
23 # else
24 # define SIZE 160
25 # endif
26 #elif defined(__hppa__)
27 # define SIZE 192
28 #elif defined (__alpha__)
29 # define SIZE 240
30 #elif defined (__ia64__)
31 # define SIZE 272
32 #elif defined(__mips__)
33 # if defined (__mips_abicalls) \
34 || (defined _MIPS_SIM && (_MIPS_SIM ==_ABIN32 || _MIPS_SIM==_ABI64))
35 # define SIZE 240
36 # else
37 # define SIZE 248
38 # endif
39 #elif defined (__powerpc64__) || defined (__ppc64__) || defined (__POWERPC64__) \
40 || defined (__PPC64__)
41 # define SIZE 180
42 #elif defined (__powerpc__) || defined (__PPC__) || defined (__ppc__) \
43 || defined (__POWERPC__) || defined (PPC) || defined (_IBMR2)
44 # if defined (__ALTIVEC__)
45 # if defined (__APPLE__)
46 # define SIZE 204
47 # else
48 # define SIZE 220
49 # endif
50 # else
51 # define SIZE 240
52 # endif
53 #elif defined (__AVR__)
54 # define SIZE 254
55 #elif defined (__s390x__)
56 # define SIZE 96 /* 256 - 160 bytes for register save area */
57 #elif defined (__s390__)
58 # define SIZE 160 /* 256 - 96 bytes for register save area */
59 #elif defined (__SPU__)
60 # define SIZE 224
61 #elif defined (__epiphany__)
62 # define SIZE (256 - __EPIPHANY_STACK_OFFSET__)
63 #elif defined (__RL78__)
64 # define SIZE 254
65 #elif defined (__sh__)
66 # define SIZE 252
67 #elif defined (__frv__)
68 # define SIZE 248
69 #elif defined (xstormy16)
70 # define SIZE 254
71 #else
72 # define SIZE 256
73 #endif
75 int foo (void)
77 char arr[SIZE];
78 arr[0] = 1;
79 return 0;
82 /* { dg-final { scan-stack-usage "foo\t\(256|264\)\tstatic" } } */
83 /* { dg-final { cleanup-stack-usage } } */