libffi: Fix 32-bit SPARC structure passing [PR115681]
[official-gcc.git] / gcc / testsuite / gcc.dg / sibcall-1.c
blobf2bd3ade217674c345037ddda66d45368f9575be
1 /* Simple check that sibling calls are performed from a
2 void non-leaf-function taking one int argument calling itself.
4 Copyright (C) 2002 Free Software Foundation Inc.
5 Contributed by Hans-Peter Nilsson <hp@bitrange.com> */
7 /* { dg-do run } */
8 /* { dg-options "-O2 -foptimize-sibling-calls" } */
10 /* See note in recurser_void() as to why we disable threading. */
11 /* { dg-additional-options "-fdisable-tree-thread1" } */
13 /* The option -foptimize-sibling-calls is the default, but serves as
14 marker. Self-recursion tail calls are optimized for all targets,
15 regardless of presence of sibcall patterns. */
17 extern void abort (void);
18 extern void exit (int);
20 extern void recurser_void (int);
21 extern void track (int);
23 int main ()
25 recurser_void (0);
26 exit (0);
29 void
30 recurser_void (int n)
32 /* In some architectures like ppc64*, jump threading may thread
33 paths such that there are two calls into track(), one for
34 track(0) and one for track(7). The track(7) call can be
35 transformed into a jump instead of a call, which means that
36 different calls into track() may end up with a different
37 &stackpos. This is the reason we disable jump threading for this
38 test. */
39 if (n == 0 || n == 7)
40 track (n);
42 if (n == 10)
43 return;
45 recurser_void (n + 1);
48 void *trackpoint;
50 void __attribute__ ((noipa))
51 track (int n)
53 char stackpos[1];
55 if (n == 0)
56 trackpoint = stackpos;
57 else if (n != 7 || trackpoint != stackpos)
58 abort ();