summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/stack-usage-1.c
diff options
context:
space:
mode:
authorupstream source tree <ports@midipix.org>2015-03-15 20:14:05 -0400
committerupstream source tree <ports@midipix.org>2015-03-15 20:14:05 -0400
commit554fd8c5195424bdbcabf5de30fdc183aba391bd (patch)
tree976dc5ab7fddf506dadce60ae936f43f58787092 /gcc/testsuite/gcc.dg/stack-usage-1.c
downloadcbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.bz2
cbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.xz
obtained gcc-4.6.4.tar.bz2 from upstream website;upstream
verified gcc-4.6.4.tar.bz2.sig; imported gcc-4.6.4 source tree from verified upstream tarball. downloading a git-generated archive based on the 'upstream' tag should provide you with a source tree that is binary identical to the one extracted from the above tarball. if you have obtained the source via the command 'git clone', however, do note that line-endings of files in your working directory might differ from line-endings of the respective files in the upstream repository.
Diffstat (limited to 'gcc/testsuite/gcc.dg/stack-usage-1.c')
-rw-r--r--gcc/testsuite/gcc.dg/stack-usage-1.c58
1 files changed, 58 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/stack-usage-1.c b/gcc/testsuite/gcc.dg/stack-usage-1.c
new file mode 100644
index 000000000..7de282df2
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/stack-usage-1.c
@@ -0,0 +1,58 @@
+/* { dg-do compile } */
+/* { dg-options "-fstack-usage" } */
+
+/* This is aimed at testing basic support for -fstack-usage in the back-ends.
+ See the SPARC back-end for an example (grep flag_stack_usage in sparc.c).
+ Once it is implemented, adjust SIZE below so that the stack usage for the
+ function FOO is reported as 256 or 264 in the stack usage (.su) file.
+ Then check that this is the actual stack usage in the assembly file. */
+
+#if defined(__i386__)
+# define SIZE 248
+#elif defined(__x86_64__)
+# define SIZE 356
+#elif defined (__sparc__)
+# if defined (__arch64__)
+# define SIZE 76
+# else
+# define SIZE 160
+# endif
+#elif defined(__hppa__)
+# define SIZE 192
+#elif defined (__alpha__)
+# define SIZE 240
+#elif defined (__ia64__)
+# define SIZE 272
+#elif defined(__mips__)
+# if defined (__mips_abicalls) \
+ || (defined _MIPS_SIM && (_MIPS_SIM ==_ABIN32 || _MIPS_SIM==_ABI64))
+# define SIZE 240
+# else
+# define SIZE 248
+# endif
+#elif defined (__powerpc__) || defined (__PPC__) || defined (__ppc__) \
+ || defined (__POWERPC__) || defined (PPC) || defined (_IBMR2)
+# define SIZE 240
+#elif defined (__AVR__)
+# define SIZE 254
+#elif defined (__s390x__)
+# define SIZE 96 /* 256 - 160 bytes for register save area */
+#elif defined (__s390__)
+# define SIZE 160 /* 256 - 96 bytes for register save area */
+#elif defined (__SPU__)
+# define SIZE 224
+#elif defined (__sh__)
+# define SIZE 252
+#else
+# define SIZE 256
+#endif
+
+int foo (void)
+{
+ char arr[SIZE];
+ arr[0] = 1;
+ return 0;
+}
+
+/* { dg-final { scan-stack-usage "foo\t\(256|264\)\tstatic" } } */
+/* { dg-final { cleanup-stack-usage } } */