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]
Other format: [Raw text]

Re: [Valgrind-developers] Memcheck optimisation level; Makefile.amincludes



[CC'ing to gcc list; GCC readers, we're puzzled that -fomit-frame-pointer seems to increase file sizes on x86... can anyone help?]



On Wed, 25 Aug 2004, Julian Seward wrote:


-fomit-frame-pointer is pretty dubious as an optimisation these days.
It seems to generally increase code size, which eliminates any other
improvement it might have (at least with Linux; not sure about V).

Any time I've benchmarked its effects recently, they have been in the zero-to-negative range, rather than positive. And yes, it always seems to result in increased code size.

That's a pretty strange considering the purpose is purportedly to make %ebp available for use, thereby reducing spill traffic etc. Usually, giving reg-alloc more regs to play with is helpful.

Yes... the gcc man page says about -fomit-frame-pointer:


  This avoids the instructions to save, set up and restore
  frame pointers; it also makes an extra register available in many
  functions.

Any idea why it doesn't help?

It does seem very odd, but I've confirmed that -fomit-frame-pointer increases code sizes, here are the numbers:


normal -fomit-fp %diff

  addrcheck/vgskin_addrcheck.so       141359  149215   +5.6%
  cachegrind/vgskin_cachegrind.so      66020   71684   +8.6%
  corecheck/vgskin_corecheck.so        21359   21359    0%
  helgrind/vgskin_helgrind.so          86305   92089   +6.7%
  lackey/vgskin_lackey.so              26577   27229   +2.4%
  massif/vgskin_massif.so              63368   67824   +7.0%
  memcheck/vgskin_memcheck.so         242314  261238   +7.8%
  none/vgskin_none.so                  21249   21249    0%


That's with GCC 3.2.2, on x86. Compile flags are:


   $(WERROR) -Winline -Wall -Wshadow -O -fomit-frame-pointer \
                -mpreferred-stack-boundary=2 -g

except that vgskin_memcheck.so uses -O2. The shared objects are just linked with -shared in the standard way; and the .o files going into the .so files have similar code size increases with -fomit-fp.

(I'm not sure where $(WERROR) comes from, is that a Make built-in?)


The weird thing is, when I look at the object code everything appears as you'd expect, ie. the -fomit-fp code looks smaller. Eg. the sizes of "objdump -d lackey/vgskin_lackey.so" are:


  normal:     34169
  -fomit-fp:  32872

ie. -fomit-fp is smaller.

And here's some representative output of "objdump -d lackey/vgskin_lackey.so"

normal:

   00000e27 <add_one_BB>:
     e27:       55                      push   %ebp
     e28:       89 e5                   mov    %esp,%ebp
     e2a:       83 05 98 27 00 00 01    addl   $0x1,0x2798
     e31:       83 15 9c 27 00 00 00    adcl   $0x0,0x279c
     e38:       83 05 a8 27 00 00 01    addl   $0x1,0x27a8
     e3f:       83 15 ac 27 00 00 00    adcl   $0x0,0x27ac
     e46:       c9                      leave
     e47:       c3                      ret

-fomit-fp:

   00000e23 <add_one_BB>:
     e23:       83 05 78 27 00 00 01    addl   $0x1,0x2778
     e2a:       83 15 7c 27 00 00 00    adcl   $0x0,0x277c
     e31:       83 05 88 27 00 00 01    addl   $0x1,0x2788
     e38:       83 15 8c 27 00 00 00    adcl   $0x0,0x278c
     e3f:       c3                      ret

As you'd expect, the -fomit-fp code is shorter.

So why are the total file sizes larger with -fomit-frame-pointer? Do any GCC people know?

Thanks.

N


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