On Dec 30, 2011, at 3:20 PM, Richard Guenther wrote:

> On Sat, Dec 24, 2011 at 8:00 PM, Steven Bosscher <stevenb....@gmail.com> 
> wrote:
>> On Tue, Dec 20, 2011 at 9:46 AM, Tristan Gingold <ging...@adacore.com> wrote:
>>> Hi,
>>> 
>>> currently alpha/vms backend emits a trampoline entry point for all nested 
>>> functions.  This is a waste of code space, as although nested functions are 
>>> very common in Ada, address of nested functions are only seldom taken.
>>> 
>>> The fact that the address of a function is taken seems only be available in 
>>> cgraph.  Is it OK to use cgraph in alpha.c ?
>> 
>> Since no-one has answered yet, I'll just toss in my $0.02.
>> (Hold on to them a bit, they may be worth a million Euro soon :-)
>> 
>> I think that in general you cannot rely on cgraph in the backends,
>> this has to be analyzed case-by-case. In your case I'm not sure, but I
>> think it should be OK.
>> 
>> Your patch uses cgraph in alpha_start_function, which is apparently
>> only used for the target hook ASM_DECLARE_FUNCTION_NAME. This hook is
>> called from varasm.c:assemble_start_function(), and this is in turn
>> only called from final.c:rest_of_handle_final() to generate assembly
>> from RTL, and from cgraphunit.c:assemble_thunk() to output assembly
>> for MI thunks. AFAICT cgraph should be correct and complete at the
>> stage when those two functions are called. Therefore your patch should
>> be OK.
>> 
>> Perhaps Honza can throw in his 0.02h?
> 
> Err - are not _all_ backends using trampolines to represent address-taken
> nested functions?

No.

>  At least I remeber to see them for x86 and plain C
> nested functions as well.  So - is this really a target issue?

Yes.

>  At the time
> the address of a nested fn is taken the C frontend arranges to (dynamically?)
> create the trampoline via some built-in.

Some backends (AIX, ia64, powerpc64-elf, VMS) don't need trampolines at all 
because they use function descriptors.

Tristan.

Reply via email to