This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

RE: -Os & inlining functions used only once



>> -finline-functions seems a good candidate but it doesn't appear
>> to works with -Os:
>
>If -Os is active and you also request inlining, the only functions that
>get inlined are those that are so small that the inlined code is about the
>same size as the code to pass the arguments and call the function (meaning
>that we save space no matter how many copies we inline).

  That is precisely the case here, since the inlined code amounts to
replacing  "call _foo" with "movl $1,%eax".  If you replace -Os with -O,
you get the expected results:

---
$ objdump -d a.O.o    [compiled as gcc -O -finline-functions -c a.c]

a.O.o:     file format pe-i386

Disassembly of section .text:

00000000 <_main>:
   0:   55                      push   %ebp
   1:   89 e5                   mov    %esp,%ebp
   3:   83 ec 08                sub    $0x8,%esp
   6:   e8 00 00 00 00          call   b <_main+0xb>
   b:   b8 01 00 00 00          mov    $0x1,%eax
  10:   89 ec                   mov    %ebp,%esp
  12:   5d                      pop    %ebp
  13:   c3                      ret
-----
$ cat a.Os.s        [compiled as gcc -Os -finline-functions -c a.c]
        .file   "a.c"
gcc2_compiled.:
___gnu_compiled_c:
.text
        .align 4
        .def    _foo;   .scl    3;      .type   32;     .endef
_foo:
        pushl %ebp
        movl $1,%eax
        movl %esp,%ebp
        movl %ebp,%esp
        popl %ebp
        ret
        .def    ___main;        .scl    2;      .type   32;     .endef
        .align 4
.globl _main
        .def    _main;  .scl    2;      .type   32;     .endef
_main:
        pushl %ebp
        movl %esp,%ebp
        subl $8,%esp
        call ___main
        call _foo
        movl %ebp,%esp
        popl %ebp
        ret
----


     DaveK
-- 
"screams erupted at a Seattle hotel where Microsoft founder Bill Gates was
addressing an education and technology conference. He was whisked away as
his audience bolted for the exits. Some audience members were knocked down
by others trying to get out."
       -- CNN 2/28/01


**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.

This footnote also confirms that this email message has been swept by
MIMEsweeper for the presence of computer viruses.

www.mimesweeper.com
**********************************************************************


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]