2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
[official-gcc.git] / gcc / testsuite / gcc.dg / sibcall-6.c
blob771a14e8b567258ffec7a7b635a525275b2dfccc
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-*-* x86_64-*-*} } */
10 /* { dg-options "-O2 -foptimize-sibling-calls" } */
12 int foo (int);
13 int bar (int);
15 int (*ptr) (int);
16 int *f_addr;
18 int
19 main ()
21 ptr = bar;
22 foo (7);
23 exit (0);
26 int
27 bar (b)
28 int b;
30 if (f_addr == (int*) __builtin_return_address (0))
31 return b;
32 else
33 abort ();
36 int
37 foo (f)
38 int f;
40 f_addr = (int*) __builtin_return_address (0);
41 return (*ptr)(f);