Re: how to avoid default inlining of static functions at O3 ?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



ok, looks like default inlining is happening with -O2 as well but doesnt happen with O1. Seeing the extra optimizations that come with O2, i see that -funit-at-a-time is the option that is causing this inlining of static functions. Looking at the man pages, i see that there are other parameters that depend on this flag (large-function-insns, large-function-growth, inline-unit-growth). 


I am not sure how much of performance impact it will be if i put -fno-unit-at-a-time along with O3.  


Regards,
--John




--- On Mon, 29/9/08, Mihai DonÈu <mihai.dontu@xxxxxxxxx> wrote:

> From: Mihai DonÈu <mihai.dontu@xxxxxxxxx>
> Subject: Re: how to avoid default inlining of static functions at O3   ?
> To: fromu2john@xxxxxxxxx
> Cc: gcc-help@xxxxxxxxxxx
> Date: Monday, 29 September, 2008, 5:33 AM
> On Friday 26 September 2008, john wrote:
> > Thanks Mihai DonÃu. Is there any compiler option
> where i can disable
> > inlining for all the static functions of a program
> instead of doing that
> > with __attribute__((noinline)) for each function
> inside the code. ?
> 
> I am not aware of such an option or attribute. Sorry.
> 
> > --- On Sat, 27/9/08, Mihai DonÈu
> <mihai.dontu@xxxxxxxxx> wrote:
> > > From: Mihai DonÈu <mihai.dontu@xxxxxxxxx>
> > > Subject: Re: how to avoid default inlining of
> static functions at O3   ?
> > > To: gcc-help@xxxxxxxxxxx, fromu2john@xxxxxxxxx
> > > Date: Saturday, 27 September, 2008, 12:46 AM
> > >
> > > On Friday 26 September 2008, john wrote:
> > > > Hi,
> > > >      I am using gcc 3.4.6 (gcc version 3.4.6
> 20060404
> > >
> > > (Red Hat 3.4.6-3))
> > >
> > > > and trying a simple C program which was
> given at the
> > >
> > > end of this mail along
> > >
> > > > with its assembly code.
> > > >
> > > > I am compiling the program using -O3
> > >
> > > From gcc info page (function attributes):
> > >    `noinline': This function attribute
> prevents a
> > > function from being
> > > considered for inlining.
> > >
> > > __attribute__((noinline)) static void test2();
> > >
> > > > /usr/bin/gcc  -c -pipe -m32 -D_REENTRANT
> -fPIC -W
> > >
> > > -Wall -Wextra -O -O3
> > >
> > > > -DSERVER -DMONITORS
> > >
> > > -DHA_KEY='"NONE"' test.c -S -o
> test.s
> > >
> > > > I see that at optimization level O3, the
> compiler is
> > >
> > > defaultly inlining my
> > >
> > > > static functions. Is there a way to avoid
> inlining
> > >
> > > static functions for C
> > >
> > > > programs ?
> > > >
> > > >
> > > > -fno-inline may avoid inlining all
> functions. There is
> > >
> > > -fno-default-inline,
> > >
> > > > but that is for C++.
> > > >
> > > > Thanks for any help in advance,
> > > > Regards
> > > > --John
> > > >
> > > >
> > > >
> > > > #include<stdio.h>
> > > > void test(int a, int b, int c)
> > > > {
> > > >         int d;
> > > >         d=a*b*c;
> > > >         printf("%d * %d * %d is
> > >
> > > %d\n",a,b,c,d);
> > >
> > > > }
> > > >
> > > >
> > > >
> > > > static void test2(int a, int b, int c)
> > > > {
> > > >          int d;
> > > >          d=a+b+c;
> > > >          printf("%d + %d + %d is
> > >
> > > %d\n",a,b,c,d);
> > >
> > > > }
> > > >
> > > > int main(int argc, char *argv[])
> > > > {
> > > >         test(1,2,3);
> > > >         test2(4,5,6);
> > > > }
> > > >
> > > >
> > > >
> > > >         .file   "test.c"
> > > >         .section
> > >
> > > .rodata.str1.1,"aMS",@
> > >
> > > > progbits,1
> > > > ..LC0:
> > > >         .string "%d * %d * %d is
> %d\n"
> > > >         .text
> > > >         .p2align 2,,3
> > > > ..globl test
> > > >         .type   test, @function
> > > > test:
> > > >         pushl   %ebp
> > > >         movl    %esp, %ebp
> > > >         pushl   %esi
> > > >         movl    8(%ebp), %esi
> > > >         movl    12(%ebp), %ecx
> > > >         movl    %esi, %eax
> > > >         pushl   %ebx
> > > >         movl    16(%ebp), %edx
> > > >         imull   %ecx, %eax
> > > >         subl    $12, %esp
> > > >         imull   %edx, %eax
> > > >         pushl   %eax
> > > >         pushl   %edx
> > > >         pushl   %ecx
> > > >         call    .L2
> > > > ..L2:
> > > >         popl    %ebx
> > > >         addl   
> $_GLOBAL_OFFSET_TABLE_+[.-.L2] , %ebx
> > > >         pushl   %esi
> > > >         leal    .LC0@GOTOFF(%ebx), %eax
> > > >         pushl   %eax
> > > >         call    printf@PLT
> > > >         leal    -8(%ebp), %esp
> > > >         popl    %ebx
> > > >         popl    %esi
> > > >         leave
> > > >         ret
> > > >         .size   test, .-test
> > > >         .section        .rodata.str1.1
> > > > ..LC1:
> > > >         .string "%d + %d + %d is
> %d\n"
> > > >         .text
> > > >         .p2align 2,,3
> > > > ..globl main
> > > >         .type   main, @function
> > > > main:
> > > >         pushl   %ebp
> > > >         movl    %esp, %ebp
> > > >         pushl   %ebx
> > > >         pushl   %eax
> > > >         andl    $-16, %esp
> > > >         subl    $20, %esp
> > > >         pushl   $3
> > > >         pushl   $2
> > > >         pushl   $1
> > > >         call    .L5
> > > > ..L5:
> > > >         popl    %ebx
> > > >         addl   
> $_GLOBAL_OFFSET_TABLE_+[.-.L5] , %ebx
> > > >         call    test@PLT
> > > >         movl    $15, (%esp)
> > > >         pushl   $6
> > > >         pushl   $5
> > > >         pushl   $4
> > > >         leal    .LC1@GOTOFF(%ebx), %eax
> > > >         pushl   %eax
> > > >         call    printf@PLT
> > > >         addl    $32, %esp
> > > >         movl    -4(%ebp), %ebx
> > > >         leave
> > > >         ret
> > > >         .size   main, .-main
> > > >         .section
> > >
> > > .note.GNU-stack,"",@progbits
> > >
> > > >         .ident  "GCC: (GNU) 3.4.6
> 20060404 (Red
> > >
> > > Hat 3.4.6-3)"
> 
> -- 
> Mihai DonÈu


      Get an email ID as yourname@xxxxxxxxx or yourname@xxxxxxxxxxxxxxx Click here http://in.promos.yahoo.com/address



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux