1 /* { dg-do compile } */
2 /* { dg-options "-fstack-usage -fno-stack-protector" } */
3 /* nvptx doesn't have a reg allocator, and hence no stack usage data. */
4 /* { dg-skip-if "" { nvptx-*-* } } */
6 /* This is aimed at testing basic support for -fstack-usage in the back-ends.
7 See the SPARC back-end for example (grep flag_stack_usage_info in sparc.c).
8 Once it is implemented, adjust SIZE below so that the stack usage for the
9 function FOO is reported as 256 or 264 in the stack usage (.su) file.
10 Then check that this is the actual stack usage in the assembly file. */
12 #if defined(__aarch64__)
13 # define SIZE 256 /* No frame pointer for leaf functions (default) */
14 #elif defined(__arc__)
16 #elif defined(__i386__)
18 #elif defined(__x86_64__)
22 # define SIZE (256 - 24)
24 #elif defined (__sparc__)
25 # if defined (__arch64__)
30 #elif defined(__hppa__)
32 #elif defined (__alpha__)
34 #elif defined (__ia64__)
36 #elif defined(__mips__)
37 # if defined (__mips_abicalls) \
38 || (defined _MIPS_SIM && (_MIPS_SIM ==_ABIN32 || _MIPS_SIM==_ABI64))
43 #elif defined (__nds32__)
44 # define SIZE 248 /* 256 - 8 bytes, only $fp and padding bytes are saved in
45 the register save area under O0 optimization level. */
46 #elif defined (__powerpc64__) || defined (__ppc64__) || defined (__POWERPC64__) \
47 || defined (__PPC64__)
53 #elif defined (__powerpc__) || defined (__PPC__) || defined (__ppc__) \
54 || defined (__POWERPC__) || defined (PPC) || defined (_IBMR2)
55 # if defined (__ALTIVEC__)
56 # if defined (__APPLE__)
66 #elif defined (__riscv)
67 # if defined (__riscv_32e)
72 #elif defined (__AVR__)
73 #if defined (__AVR_3_BYTE_PC__ )
74 # define SIZE 251 /* 256 - 2 bytes for Y - 3 bytes for return address */
76 # define SIZE 252 /* 256 - 2 bytes for Y - 2 bytes for return address */
78 #elif defined (__s390x__)
79 # define SIZE 96 /* 256 - 160 bytes for register save area */
80 #elif defined (__s390__)
81 # define SIZE 160 /* 256 - 96 bytes for register save area */
82 #elif defined (__epiphany__)
83 # define SIZE (256 - __EPIPHANY_STACK_OFFSET__)
84 #elif defined (__RL78__)
86 #elif defined (__sh__)
88 #elif defined (__frv__)
90 #elif defined (xstormy16)
92 #elif defined (__nios2__)
94 #elif defined (__PRU__)
96 #elif defined (__v850__)
98 #elif defined (__mn10300__)
100 #elif defined (__H8300SX__) || defined (__H8300S__) || defined (__H8300H__) || defined (__H8300__)
102 #elif defined (__M32R__)
104 #elif defined (__csky__)
106 #elif defined (__CRIS__)
108 #elif defined (__loongarch_lp64)
109 # define SIZE 240 /* 256 - 8 bytes for $fp, and 8 bytes for a temp value */
121 /* { dg-final { scan-stack-usage "foo\t\(256|264\)\tstatic" } } */
122 /* { dg-final { cleanup-stack-usage } } */