aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/gcc.dg/sibcall-4.c
diff options
context:
space:
mode:
authorBen Cheng <bccheng@google.com>2014-03-25 22:37:19 -0700
committerBen Cheng <bccheng@google.com>2014-03-25 22:37:19 -0700
commit1bc5aee63eb72b341f506ad058502cd0361f0d10 (patch)
treec607e8252f3405424ff15bc2d00aa38dadbb2518 /gcc-4.9/gcc/testsuite/gcc.dg/sibcall-4.c
parent283a0bf58fcf333c58a2a92c3ebbc41fb9eb1fdb (diff)
downloadtoolchain_gcc-1bc5aee63eb72b341f506ad058502cd0361f0d10.tar.gz
toolchain_gcc-1bc5aee63eb72b341f506ad058502cd0361f0d10.tar.bz2
toolchain_gcc-1bc5aee63eb72b341f506ad058502cd0361f0d10.zip
Initial checkin of GCC 4.9.0 from trunk (r208799).
Change-Id: I48a3c08bb98542aa215912a75f03c0890e497dba
Diffstat (limited to 'gcc-4.9/gcc/testsuite/gcc.dg/sibcall-4.c')
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.dg/sibcall-4.c79
1 files changed, 79 insertions, 0 deletions
diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/sibcall-4.c b/gcc-4.9/gcc/testsuite/gcc.dg/sibcall-4.c
new file mode 100644
index 000000000..a66ed0798
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/gcc.dg/sibcall-4.c
@@ -0,0 +1,79 @@
+/* Simple check that sibling calls are performed from a
+ void non-leaf-function taking no arguments calling a function which
+ is about the same as itself.
+
+ Copyright (C) 2002 Free Software Foundation Inc.
+ Contributed by Hans-Peter Nilsson <hp@bitrange.com> */
+
+/* { dg-do run { xfail { { cris-*-* crisv32-*-* h8300-*-* hppa*64*-*-* m32r-*-* mcore-*-* mn10300-*-* nds32*-*-* xstormy16-*-* v850*-*-* vax-*-* xtensa*-*-* } || { arm*-*-* && { ! arm32 } } } } } */
+/* -mlongcall disables sibcall patterns. */
+/* { dg-skip-if "" { powerpc*-*-* } { "-mlongcall" } { "" } } */
+/* { dg-options "-O2 -foptimize-sibling-calls" } */
+
+/* The option -foptimize-sibling-calls is the default, but serves as
+ marker. This test is xfailed on targets without sibcall patterns
+ (except targets where the test does not work due to the return address
+ not saved on the regular stack). */
+
+extern void abort (void);
+extern void exit (int);
+
+/* Sibcalls are not supported in MIPS16 mode, which has direct calls but
+ not direct jumps. */
+#ifdef __mips
+#define ATTR __attribute__((nomips16))
+#else
+#define ATTR
+#endif
+
+static ATTR void recurser_void1 (void);
+static ATTR void recurser_void2 (void);
+extern void track (void);
+
+int n = 0;
+int main ()
+{
+ recurser_void1 ();
+ exit (0);
+}
+
+/* The functions should get the same stack-frame, and best way to make it
+ reasonably sure is to make them have the same contents (regarding the
+ n tests). */
+
+static void __attribute__((noinline)) ATTR
+recurser_void1 (void)
+{
+ if (n == 0 || n == 7 || n == 8)
+ track ();
+
+ if (n == 10)
+ return;
+ n++;
+ recurser_void2 ();
+}
+
+static void __attribute__((noinline)) ATTR
+recurser_void2 (void)
+{
+ if (n == 0 || n == 7 || n == 8)
+ track ();
+
+ if (n == 10)
+ return;
+ n++;
+ recurser_void1 ();
+}
+
+void *trackpoint;
+
+void __attribute__ ((noinline))
+track ()
+{
+ char stackpos[1];
+
+ if (n == 0)
+ trackpoint = stackpos;
+ else if ((n != 7 && n != 8) || trackpoint != stackpos)
+ abort ();
+}