1 /* { dg-require-effective-target return_address } */
2 /* { dg-options "-finstrument-functions" } */
3 /* { dg-xfail-run-if "" { powerpc-ibm-aix* } } */
5 extern void abort (void);
7 #define ASSERT(X) if (!(X)) abort ();
8 #define NOCHK __attribute__ ((no_instrument_function))
10 int entry_calls
, exit_calls
;
11 void (*last_fn_entered
)();
12 void (*last_fn_exited
)();
14 __attribute__ ((noinline
))
17 __attribute__ ((noinline
))
20 ASSERT (last_fn_entered
== foo
);
23 __attribute__ ((noinline
))
26 ASSERT (entry_calls
== 1 && exit_calls
== 0);
27 ASSERT (last_fn_entered
== foo2
);
29 ASSERT (entry_calls
== 2 && exit_calls
== 1);
30 ASSERT (last_fn_entered
== foo
);
31 ASSERT (last_fn_exited
== foo
);
34 __attribute__ ((noinline
))
35 void nfoo (void) NOCHK
;
38 ASSERT (entry_calls
== 2 && exit_calls
== 2);
39 ASSERT (last_fn_entered
== foo
);
40 ASSERT (last_fn_exited
== foo2
);
42 ASSERT (entry_calls
== 3 && exit_calls
== 3);
43 ASSERT (last_fn_entered
== foo
);
44 ASSERT (last_fn_exited
== foo
);
49 ASSERT (entry_calls
== 0 && exit_calls
== 0);
53 ASSERT (entry_calls
== 2 && exit_calls
== 2);
54 ASSERT (last_fn_entered
== foo
);
55 ASSERT (last_fn_exited
== foo2
);
59 ASSERT (entry_calls
== 3 && exit_calls
== 3);
60 ASSERT (last_fn_entered
== foo
);
65 void __cyg_profile_func_enter (void (*fn
)(), void (*parent
)()) NOCHK
;
66 void __cyg_profile_func_exit (void (*fn
)(), void (*parent
)()) NOCHK
;
68 __attribute__ ((noinline
))
69 void __cyg_profile_func_enter (void (*fn
)(), void (*parent
)())
74 __attribute__ ((noinline
))
75 void __cyg_profile_func_exit (void (*fn
)(), void (*parent
)())