OSDN Git Service

Revert delta 190174
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gcc.dg / stack-usage-1.c
1 /* { dg-do compile } */
2 /* { dg-options "-fstack-usage" } */
3
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.  */
9
10 #if defined(__i386__)
11 #  define SIZE 248
12 #elif defined(__x86_64__)
13 #  ifndef _WIN64
14 #    define SIZE 356
15 #  else
16 #    define SIZE (256 - 24)
17 #  endif
18 #elif defined (__sparc__)
19 #  if defined (__arch64__)
20 #    define SIZE 76
21 #  else
22 #    define SIZE 160
23 #  endif
24 #elif defined(__hppa__)
25 #  define SIZE 192
26 #elif defined (__alpha__)
27 #  define SIZE 240
28 #elif defined (__ia64__)
29 #  define SIZE 272
30 #elif defined(__mips__)
31 #  if defined (__mips_abicalls) \
32       || (defined _MIPS_SIM && (_MIPS_SIM ==_ABIN32 || _MIPS_SIM==_ABI64))
33 #    define SIZE 240
34 #  else
35 #    define SIZE 248
36 #  endif
37 #elif defined (__powerpc64__) || defined (__ppc64__) || defined (__POWERPC64__) \
38       || defined (__PPC64__)
39 #  define SIZE 180
40 #elif defined (__powerpc__) || defined (__PPC__) || defined (__ppc__) \
41       || defined (__POWERPC__) || defined (PPC) || defined (_IBMR2)
42 #  if defined (__ALTIVEC__)
43 #    if defined (__APPLE__)
44 #      define SIZE 204
45 #    else
46 #      define SIZE 220
47 #    endif
48 #  else
49 #    define SIZE 240
50 #  endif
51 #elif defined (__AVR__)
52 #  define SIZE 254
53 #elif defined (__s390x__)
54 #  define SIZE 96  /* 256 - 160 bytes for register save area */
55 #elif defined (__s390__)
56 #  define SIZE 160 /* 256 -  96 bytes for register save area */
57 #elif defined (__SPU__)
58 #  define SIZE 224
59 #elif defined (__epiphany__)
60 #  define SIZE (256 - __EPIPHANY_STACK_OFFSET__)
61 #elif defined (__sh__)
62 #  define SIZE 252
63 #else
64 #  define SIZE 256
65 #endif
66
67 int foo (void)
68 {
69   char arr[SIZE];
70   arr[0] = 1;
71   return 0;
72 }
73
74 /* { dg-final { scan-stack-usage "foo\t\(256|264\)\tstatic" } } */
75 /* { dg-final { cleanup-stack-usage } } */