Add __builtion_unreachable to vector::size(), vector::capacity()
[official-gcc.git] / gcc / testsuite / gcc.dg / stack-usage-1.c
blob21cce0f440c53753f700abba6f69890afd1a8c93
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__)
15 # define SIZE (256-4)
16 #elif defined(__i386__)
17 # define SIZE 248
18 #elif defined(__x86_64__)
19 # ifndef _WIN64
20 # define SIZE 356
21 # else
22 # define SIZE (256 - 24)
23 # endif
24 #elif defined (__sparc__)
25 # if defined (__arch64__)
26 # define SIZE 76
27 # else
28 # define SIZE 160
29 # endif
30 #elif defined(__hppa__)
31 # define SIZE 192
32 #elif defined (__alpha__)
33 # define SIZE 240
34 #elif defined (__ia64__)
35 # define SIZE 272
36 #elif defined(__mips__)
37 # if defined (__mips_abicalls) \
38 || (defined _MIPS_SIM && (_MIPS_SIM ==_ABIN32 || _MIPS_SIM==_ABI64))
39 # define SIZE 240
40 # else
41 # define SIZE 248
42 # endif
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__)
48 # if _CALL_ELF == 2
49 # define SIZE 208
50 # else
51 # define SIZE 180
52 # endif
53 #elif defined (__powerpc__) || defined (__PPC__) || defined (__ppc__) \
54 || defined (__POWERPC__) || defined (PPC) || defined (_IBMR2)
55 # if defined (__ALTIVEC__)
56 # if defined (__APPLE__)
57 # define SIZE 204
58 # else
59 # define SIZE 220
60 # endif
61 # elif defined (_AIX)
62 # define SIZE 208
63 # else
64 # define SIZE 240
65 # endif
66 #elif defined (__riscv)
67 # if defined (__riscv_32e)
68 # define SIZE 252
69 # else
70 # define SIZE 240
71 # endif
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 */
75 #else
76 # define SIZE 252 /* 256 - 2 bytes for Y - 2 bytes for return address */
77 #endif
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__)
85 # define SIZE 254
86 #elif defined (__sh__)
87 # define SIZE 252
88 #elif defined (__frv__)
89 # define SIZE 248
90 #elif defined (xstormy16)
91 # define SIZE 254
92 #elif defined (__nios2__)
93 # define SIZE 252
94 #elif defined (__PRU__)
95 # define SIZE 252
96 #elif defined (__v850__)
97 #define SIZE 260
98 #elif defined (__mn10300__)
99 #define SIZE 252
100 #elif defined (__H8300SX__) || defined (__H8300S__) || defined (__H8300H__) || defined (__H8300__)
101 #define SIZE 252
102 #elif defined (__M32R__)
103 #define SIZE 252
104 #elif defined (__csky__)
105 # define SIZE 252
106 #elif defined (__CRIS__)
107 # define SIZE 252
108 #elif defined (__loongarch_lp64)
109 # define SIZE 240 /* 256 - 8 bytes for $fp, and 8 bytes for a temp value */
110 #else
111 # define SIZE 256
112 #endif
114 int foo (void)
116 char arr[SIZE];
117 arr[0] = 1;
118 return 0;
121 /* { dg-final { scan-stack-usage "foo\t\(256|264\)\tstatic" } } */
122 /* { dg-final { cleanup-stack-usage } } */