Like __cyg_profile_func_exit but with the return value instead of the call site

Ian Lance Taylor iant@google.com
Fri Aug 21 15:07:00 GMT 2009


Laurent Burgy <laurent.burgy@gmail.com> writes:

> I wanted to develop something similar to __cyg_profile_func_exit but
> instead of having the call site I would like to have the actual value
> returned.
> With gcc-4.3.3, the expand_builtin_profile_func in builtins.c makes this call:
>   emit_library_call (which, LCT_NORMAL, VOIDmode, 2, this, Pmode,
> 		     expand_builtin_return_addr (BUILT_IN_RETURN_ADDRESS,
> 						 0),
> 		     Pmode);
>
>   Is there a way to replace expand_builtin_return_addr to get the
> value returned ?

In principle, sure, but it means some gcc hacking.  You'll have to
allocate a stack slot to hold the return value, record the stack slot in
cfun (adding a new field to struct function), and change
expand_builtin_return_address (or add a new builtin function) to return
the value in that slot.

But I don't see the advantage, given that you will have to change your
code anyhow to call expand_builtin_return_address.  The point of
__cyg_profile_func_exit is that you don't have to change your code.  If
you are going to change your code, there are probably much easier ways
to do this.

Ian



More information about the Gcc-help mailing list