This commit was manufactured by cvs2svn to create branch
[official-gcc.git] / gcc / testsuite / gcc.dg / sibcall-6.c
blobbb855108ee172ac0fc6df9833672f86331eef1d1
1 /* A simple check to see whether indirect calls are
2 being sibcall optimized on targets that do support
3 this notion, i.e. have the according call patterns
4 in place.
6 Copyright (C) 2002 Free Software Foundation Inc.
7 Contributed by Andreas Bauer <baueran@in.tum.de> */
9 /* { dg-do run { target i?86-*-* s390*-*-* x86_64-*-*} } */
10 /* { dg-options "-O2 -foptimize-sibling-calls" } */
12 extern void abort (void);
13 extern void exit (int);
15 int foo (int);
16 int bar (int);
18 int (*ptr) (int);
19 int *f_addr;
21 int
22 main ()
24 ptr = bar;
25 foo (7);
26 exit (0);
29 int
30 bar (b)
31 int b;
33 if (f_addr == (int*) __builtin_return_address (0))
34 return b;
35 else
36 abort ();
39 int
40 foo (f)
41 int f;
43 f_addr = (int*) __builtin_return_address (0);
44 return (*ptr)(f);