public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* how to avoid default inlining of static functions at O3   ?
@ 2008-09-26 19:00 john
  2008-09-26 19:17 ` Mihai Donțu
  2008-09-26 21:03 ` Brian Dessent
  0 siblings, 2 replies; 7+ messages in thread
From: john @ 2008-09-26 19:00 UTC (permalink / raw)
  To: gcc-help

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

/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)"


      Unlimited freedom, unlimited storage. Get it now, on http://help.yahoo.com/l/in/yahoo/mail/yahoomail/tools/tools-08.html/

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: how to avoid default inlining of static functions at O3   ?
  2008-09-26 19:00 how to avoid default inlining of static functions at O3 ? john
@ 2008-09-26 19:17 ` Mihai Donțu
  2008-09-26 19:28   ` john
  2008-09-26 21:03 ` Brian Dessent
  1 sibling, 1 reply; 7+ messages in thread
From: Mihai Donțu @ 2008-09-26 19:17 UTC (permalink / raw)
  To: gcc-help, fromu2john

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

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: how to avoid default inlining of static functions at O3   ?
  2008-09-26 19:17 ` Mihai Donțu
@ 2008-09-26 19:28   ` john
  2008-09-26 20:41     ` Eljay Love-Jensen
  2008-09-29  0:04     ` Mihai Donțu
  0 siblings, 2 replies; 7+ messages in thread
From: john @ 2008-09-26 19:28 UTC (permalink / raw)
  To: gcc-help, Mihai Donțu

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. ? 


Regards,
--John


--- On Sat, 27/9/08, Mihai Donțu <mihai.dontu@gmail.com> wrote:

> From: Mihai Donțu <mihai.dontu@gmail.com>
> Subject: Re: how to avoid default inlining of static functions at O3   ?
> To: gcc-help@gcc.gnu.org, fromu2john@yahoo.com
> 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@ymail.com or yourname@rocketmail.com. Click here http://in.promos.yahoo.com/address

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: how to avoid default inlining of static functions at O3   ?
  2008-09-26 19:28   ` john
@ 2008-09-26 20:41     ` Eljay Love-Jensen
  2008-09-29  0:04     ` Mihai Donțu
  1 sibling, 0 replies; 7+ messages in thread
From: Eljay Love-Jensen @ 2008-09-26 20:41 UTC (permalink / raw)
  To: fromu2john, GCC-help

Hi John,

On my system, the flag differences between -O2 and -O3 are that -O3 also
enables:
-fgcse-after-reload
-finline-functions
-funswitch-loops

That may not be the same on your platform, however.

You can do this:

echo '' | g++ -O2 -fverbose-asm -S -x c++ - -o O2.txt
echo '' | g++ -O3 -fverbose-asm -S -x c++ - -o O3.txt

And then compare the flag differences on your platform.

Note, I do not know if there are other optimizations enabled by -O3 that do
not have associated flags.

Most optimizations do *NOT* have a knob to enable/disable.  But, perhaps,
most of those non-twiddle-able optimizations are already enabled at -O2.

HTH,
--Eljay

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: how to avoid default inlining of static functions at O3   ?
  2008-09-26 19:00 how to avoid default inlining of static functions at O3 ? john
  2008-09-26 19:17 ` Mihai Donțu
@ 2008-09-26 21:03 ` Brian Dessent
  1 sibling, 0 replies; 7+ messages in thread
From: Brian Dessent @ 2008-09-26 21:03 UTC (permalink / raw)
  To: fromu2john; +Cc: gcc-help

john wrote:

> 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 ?

That's kind of contradictory to what -O3 means, though.  -O3 tells gcc
to favor speed at any cost so in effect you are telling it to enable all
the optimizations that it might otherwise consider a poor tradeoff
because they bloat code size with extra inlining.  Consider using -Os if
you want less inlining.

Brian

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: how to avoid default inlining of static functions at O3   ?
  2008-09-26 19:28   ` john
  2008-09-26 20:41     ` Eljay Love-Jensen
@ 2008-09-29  0:04     ` Mihai Donțu
  2008-09-29 10:07       ` john
  1 sibling, 1 reply; 7+ messages in thread
From: Mihai Donțu @ 2008-09-29  0:04 UTC (permalink / raw)
  To: fromu2john; +Cc: gcc-help

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@gmail.com> wrote:
> > From: Mihai Donțu <mihai.dontu@gmail.com>
> > Subject: Re: how to avoid default inlining of static functions at O3   ?
> > To: gcc-help@gcc.gnu.org, fromu2john@yahoo.com
> > 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

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: how to avoid default inlining of static functions at O3   ?
  2008-09-29  0:04     ` Mihai Donțu
@ 2008-09-29 10:07       ` john
  0 siblings, 0 replies; 7+ messages in thread
From: john @ 2008-09-29 10:07 UTC (permalink / raw)
  To: Mihai Donțu; +Cc: gcc-help

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@gmail.com> wrote:

> From: Mihai Donțu <mihai.dontu@gmail.com>
> Subject: Re: how to avoid default inlining of static functions at O3   ?
> To: fromu2john@yahoo.com
> Cc: gcc-help@gcc.gnu.org
> 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@gmail.com> wrote:
> > > From: Mihai Donțu <mihai.dontu@gmail.com>
> > > Subject: Re: how to avoid default inlining of
> static functions at O3   ?
> > > To: gcc-help@gcc.gnu.org, fromu2john@yahoo.com
> > > 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@ymail.com or yourname@rocketmail.com. Click here http://in.promos.yahoo.com/address

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2008-09-29 10:07 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-09-26 19:00 how to avoid default inlining of static functions at O3 ? john
2008-09-26 19:17 ` Mihai Donțu
2008-09-26 19:28   ` john
2008-09-26 20:41     ` Eljay Love-Jensen
2008-09-29  0:04     ` Mihai Donțu
2008-09-29 10:07       ` john
2008-09-26 21:03 ` Brian Dessent

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).