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]

-Os & inlining functions used only once


Hi!

I'm looking for a way to instruct GCC to inline all static
functions which are used only once.  The point is just to save
the extra bytes required to make the calls and returns.

-finline-functions seems a good candidate but it doesn't appear
to works with -Os:

~/tmp % cat a.c
static int foo (void) { return 1; }
int main (void) { return foo (); }
~/tmp % gcc -Os -finline-functions a.c -S
~/tmp % objdump -S a.o
        
a.o:     file format elf32-i386

Disassembly of section .text:

00000000 <foo>:
   0:   55                      push   %ebp
   1:   89 e5                   mov    %esp,%ebp
   3:   b8 01 00 00 00          mov    $0x1,%eax
   8:   c9                      leave  
   9:   c3                      ret    
   a:   89 f6                   mov    %esi,%esi

0000000c <main>:
   c:   55                      push   %ebp
   d:   89 e5                   mov    %esp,%ebp
   f:   83 ec 08                sub    $0x8,%esp
  12:   e8 e9 ff ff ff          call   0 <foo>
  17:   c9                      leave  
  18:   c3                      ret    
  19:   8d 76 00                lea    0x0(%esi),%esi
~/tmp % gcc -v
Reading specs from /usr/lib/gcc-lib/i386-linux/2.95.3/specs
gcc version 2.95.3 20010315 (Debian release)


Any hint why it doesn't work?  Before looking at the code I
thought that -Os would have done this job for free.

Thanks
-- 
Alexandre Duret-Lutz


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