OSDN Git Service

gcc/
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gcc.dg / sibcall-3.c
1 /* Simple check that sibling calls are performed from a
2    void non-leaf-function taking one int argument calling a function which
3    is about the same as itself.
4
5    Copyright (C) 2002 Free Software Foundation Inc.
6    Contributed by Hans-Peter Nilsson  <hp@bitrange.com>  */
7
8 /* { dg-do run { xfail arc-*-* avr-*-* c4x-*-* cris-*-* h8300-*-* ip2k-*-* m32r-*-* m68hc1?-*-* m681?-*-* m680*-*-* m68k-*-* mcore-*-* mips*-*-* mn10300-*-* ns32k-*-* s390*-*-* xstormy16-*-* v850*-*-* vax-*-* xtensa-*-* } } */
9 /* { dg-options "-O2 -foptimize-sibling-calls" } */
10
11 /* The option -foptimize-sibling-calls is the default, but serves as
12    marker.  This test is xfailed on targets without sibcall patterns
13    (except targets where the test does not work due to the return address
14    not saved on the regular stack).  */
15
16 static void recurser_void1 (int);
17 static void recurser_void2 (int);
18 extern void track (int);
19
20 int main ()
21 {
22   recurser_void1 (0);
23   exit (0);
24 }
25
26 /* The functions should get the same stack-frame, and best way to make it
27    reasonably sure is to make them have the same contents (regarding the
28    n tests).  */
29
30 static void
31 recurser_void1 (int n)
32 {
33   if (n == 0 || n == 7 || n == 8)
34     track (n);
35
36   if (n == 10)
37     return;
38
39   recurser_void2 (n + 1);
40 }
41
42 static void
43 recurser_void2 (int n)
44 {
45   if (n == 0 || n == 7 || n == 8)
46     track (n);
47
48   if (n == 10)
49     return;
50
51   recurser_void1 (n + 1);
52 }
53
54 void *trackpoint;
55
56 void
57 track (int n)
58 {
59   char stackpos[1];
60
61   if (n == 0)
62     trackpoint = stackpos;
63   else if ((n != 7 && n != 8) || trackpoint != stackpos)
64     abort ();
65 }