This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Like __cyg_profile_func_exit but with the return value instead of the call site
- From: Ian Lance Taylor <iant at google dot com>
- To: Laurent Burgy <laurent dot burgy at gmail dot com>
- Cc: gcc-help at gnu dot org
- Date: Fri, 21 Aug 2009 07:36:38 -0700
- Subject: Re: Like __cyg_profile_func_exit but with the return value instead of the call site
- References: <e625a54d0908201205k115b951ay466cf610f06b4a2a@mail.gmail.com>
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