Use -fomit-frame-pointer when no debugging info is required

Cosmin Truta cosmin@cs.toronto.edu
Fri Dec 29 15:18:00 GMT 2000


On Thu, 28 Dec 2000, Geert Bosch wrote:

> On Thu, 28 Dec 2000 08:01:21 -0500, Cosmin Truta wrote:
> 
> > I would like to suggest you a patch that may enable "-fomit-frame-pointer"
> > even in the configurations that need a frame pointer (that is, when
> > CAN_DEBUG_WITHOUT_FP is zero), in case that "-g" is not found in the
> > command line [snip]
>   
> It essential that we generate byte-for-byte identical code whether -g is 
> present or not. Otherwise, we'd soon find ourselves in a situation where
> we have programs that run fine with -g, but mysteriously fail without
> debugging enabled.

You mean that it is possible to have buggy versions of gcc that will
produce erroneous code when -fomit-frame-pointer is on? That would be too
bad...

Or, are you saying that it is possible for one to write in asm language
and to have the programs running with -g (and without -fomit-frame-pointer)
and to have a surprise when -g is off?
The same thing can happen when using different optimization options: -O1,
-O2 and so on.

> I'm sympathetic to your viewpoint that there should be some optimization
> flag that will enable all optimizations even if they make debugging almost
> impossible. This flag should enable the register renaming
> optimization, as well as omit the frame pointer on targets that cannot
> debug without it, but such an optimization should surely not depend 
> on -g being present on the command line.

There are some possibilities:

-O4 - optimize even more - try all the possible optimizations, including
  the very expensive ones, and those which are gdb-unsafe
  (I think the new major version of gcc could be a good reason for adding 
  a new optimization level)

-Ox - ditto
  (this has the advantage that it is commonly known among other compilers
  as an option that causes the maximum opt. possible, and the disadvantage
  that the gcc cmd line will yield errors if only gcc-2.x is installed in
  the system -- unsuitable for portable makefiles)
  -- this could work either in conjunction with -O1, -O2 etc., or alone.

-fgdb-unsafe - will enable all the optimizations that are gdb-unsafe,
  i.e. -fomit-frame-pointer, -frename-registers, and all the future
  other possibilities that might appear

-Og - the same meaning (I would personally go for this instead of
  -fgdb-unsafe)

I would really like to have an easy way of enabling all the possible
optimizations in gcc.

Cosmin



More information about the Gcc-patches mailing list