OSDN Git Service

* gcc.dg/sibcall-3.c: Skip on PowerPC targets when -mlongcall.
[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-*-* hppa*64*-*-* m32r-*-* m68hc1?-*-* m681?-*-* m680*-*-* m68k-*-* mcore-*-* mn10300-*-* xstormy16-*-* v850*-*-* vax-*-* xtensa-*-* } } */
9 /* -mlongcall disables sibcall patterns.  */
10 /* { dg-skip-if "" { powerpc*-*-* } { "-mlongcall" } { "" } } */
11 /* { dg-options "-O2 -foptimize-sibling-calls" } */
12
13 /* The option -foptimize-sibling-calls is the default, but serves as
14    marker.  This test is xfailed on targets without sibcall patterns
15    (except targets where the test does not work due to the return address
16    not saved on the regular stack).  */
17
18 extern void abort (void);
19 extern void exit (int);
20
21 static void recurser_void1 (int);
22 static void recurser_void2 (int);
23 extern void track (int);
24
25 int main ()
26 {
27   recurser_void1 (0);
28   exit (0);
29 }
30
31 /* The functions should get the same stack-frame, and best way to make it
32    reasonably sure is to make them have the same contents (regarding the
33    n tests).  */
34
35 static void __attribute__((noinline))
36 recurser_void1 (int n)
37 {
38   if (n == 0 || n == 7 || n == 8)
39     track (n);
40
41   if (n == 10)
42     return;
43
44   recurser_void2 (n + 1);
45 }
46
47 static void __attribute__((noinline))
48 recurser_void2 (int n)
49 {
50   if (n == 0 || n == 7 || n == 8)
51     track (n);
52
53   if (n == 10)
54     return;
55
56   recurser_void1 (n + 1);
57 }
58
59 void *trackpoint;
60
61 void
62 track (int n)
63 {
64   char stackpos[1];
65
66   if (n == 0)
67     trackpoint = stackpos;
68   else if ((n != 7 && n != 8) || trackpoint != stackpos)
69     abort ();
70 }