On Tue, Oct 13, 2009 at 5:18 PM, Bingfeng Mei <b...@broadcom.com> wrote:
>
>
>> -----Original Message-----
>> From: Richard Guenther [mailto:richard.guent...@gmail.com]
>> Sent: 13 October 2009 16:15
>> To: Bingfeng Mei
>> Cc: gcc@gcc.gnu.org
>> Subject: Re: LTO question
>>
>> On Tue, Oct 13, 2009 at 2:47 PM, Bingfeng Mei
>> <b...@broadcom.com> wrote:
>> > Hello,
>> > I just had the first taste with the latest LTO merge on our port.
>> > Compiler is configured with LTO enabled and built correctly.
>> > I tried the following example:
>> >
>> > a.c
>> > extern void foo(int);
>> > int main()
>> > {  foo(20);
>> >  return 1;
>> > }
>> >
>> > b.c
>> > #include <stdio.h>
>> > void foo(int c)
>> > {
>> >  printf("Hello world: %d\n", c);
>> > }
>> >
>> > compiled with:
>> > firepath-elf-gcc -flto a.c b.c -save-temps -O2
>> >
>> > I expected that foo should be inlined into main, but not.
>> Both functions
>> >  of main and foo are present in a.s, while b.s contains the
>> LTO code.
>> >
>> > Did I miss something here? Are there new hooks I should
>> specify or tune for
>> > LTO? I checked the up-to-date internal manual and found nothing.
>>
>> non-inline declared functions are inlined at -O2 only if doing so
>> does not increase program size.  Use -O3 or -finline-functions.
>
> But the function is only called once here. It should always decrease size 
> unless
> my cost function is terribly wrong.  I will check how other targets such as
> x86 do here.

The function is still exported if you do not use -fwhole-program.

Richard.

Reply via email to