This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: PATCH: Turn on -fomit-frame-pointer by default for 32bit Linux/x86
- From: Jack Howarth <howarth at bromo dot med dot uc dot edu>
- To: Uros Bizjak <ubizjak at gmail dot com>
- Cc: "H.J. Lu" <hjl dot tools at gmail dot com>, GCC Patches <gcc-patches at gcc dot gnu dot org>, Richard Guenther <rguenther at suse dot de>, Jakub Jelinek <jakub at redhat dot com>, Mark Mitchell <mark at codesourcery dot com>, Richard Henderson <rth at redhat dot com>, jh at suse dot cz, Andi Kleen <andi at firstfloor dot org>, Andrew Haley <aph at redhat dot com>, David Daney <ddaney at caviumnetworks dot com>, Xinliang David Li <davidxl at google dot com>, Chris Lattner <clattner at apple dot com>, Gerald Pfeifer <gerald at pfeifer dot com>
- Date: Thu, 12 Aug 2010 13:39:11 -0400
- Subject: Re: PATCH: Turn on -fomit-frame-pointer by default for 32bit Linux/x86
- References: <AANLkTinbviPWO-hDfgL=31x=st_LA2frCPPYXtscEAhX@mail.gmail.com> <AANLkTim1L=eJGVO92S8_g+VP1ZUF4-O2O8KBUMB1UcwB@mail.gmail.com> <AANLkTi=7pqkdQjtDbqTSh-TAEa1L3TjBXgzXX2=znS4M@mail.gmail.com> <AANLkTi=FxbGb=sqr-+L0_tHwunFQS+0AqabarkEG10n7@mail.gmail.com> <AANLkTikUX0WLkiBFF+1eE8X44PsKyVNL6GNShPapoGo-@mail.gmail.com> <20100812172246.GB25488@bromo.med.uc.edu> <AANLkTind4=ouDoCMRPuRs2yFXduX=s2vBV65q7ZWaD1A@mail.gmail.com>
On Thu, Aug 12, 2010 at 07:26:37PM +0200, Uros Bizjak wrote:
> On Thu, Aug 12, 2010 at 7:22 PM, Jack Howarth <howarth@bromo.med.uc.edu> wrote:
>
> >> >>>> 2010-08-12 ÂH.J. Lu Â<hongjiu.lu@intel.com>
> >> >>>> Â Â Â Â Â ÂUros Bizjak Â<ubizjak@gmail.com>
> >> >>>>
> >> >>>> Â Â Â Â* config.gcc: Handle --enable-frame-pointer.
> >> >>>>
> >> >>>> Â Â Â Â* configure.ac: Add --enable-frame-pointer.
> >> >>>> Â Â Â Â* configure: Regenerated.
> >> >>>>
> >> >>>> Â Â Â Â* config/i386/i386.c (USE_IX86_FRAME_POINTER): Default to 0.
> >> >>>> Â Â Â Â(override_options): Enable -fomit-frame-pointer for 32bit code
> >> >>>> Â Â Â Âif compiling for TARGET_MACHO and not optimizing for size
> >> >>>> Â Â Â Âunless configured with --enable-frame-pointer. ÂEnable
> >> >>>> Â Â Â Â-fasynchronous-unwind-tables unless configured with
> >> >>>> Â Â Â Â--enable-frame-pointer. ÂEnable -maccumulate-outgoing-args
> >> >>>> Â Â Â Âby default unless configured with --enable-frame-pointer.
> >> >>>>
> >> >>>
> >> >>> Please change the ChangeLog text to something like:
> >> >>>
> >> >>> If not configured with --enable-frame-pointer, enable
> >> >>> -fomit-frame-pointer (but not for TARGET_MACHO or when optimizing for
> >> >>> size), enable -fasynchronous-unwind-tables and
> >> >>> -maccumulate-outgoing-args by default.
> >> >>>
> >> >>
> >> >> I checked it in with updated ChangeLog.
> >> >>
> >> >> How should we document it? We currently have
> >> >>
> >> >> --
> >> >> @item -fomit-frame-pointer
> >> >> @opindex fomit-frame-pointer
> >> >> Don't keep the frame pointer in a register for functions that
> >> >> don't need one. ÂThis avoids the instructions to save, set up and
> >> >> restore frame pointers; it also makes an extra register available
> >> >> in many functions. Â@strong{It also makes debugging impossible on
> >> >> some machines.}
> >> >>
> >> >> On some machines, such as the VAX, this flag has no effect, because
> >> >> the standard calling sequence automatically handles the frame pointer
> >> >> and nothing is saved by pretending it doesn't exist. ÂThe
> >> >> machine-description macro @code{FRAME_POINTER_REQUIRED} controls
> >> >> whether a target machine supports this flag. Â@xref{Registers,,Register
> >> >> Usage, gccint, GNU Compiler Collection (GCC) Internals}.
> >> >>
> >> >> Enabled at levels @option{-O}, @option{-O2}, @option{-O3}, @option{-Os}.
> >> >> --
> >> >>
> >> >> It was never correct for x86 and is wrong today.
> >> >
> >> > Perhaps something like:
> >> >
> >> > Index: invoke.texi
> >> > ===================================================================
> >> > --- invoke.texi (revision 163191)
> >> > +++ invoke.texi (working copy)
> >> > @@ -5993,6 +5993,11 @@
> >> > Âwhether a target machine supports this flag. Â@xref{Registers,,Register
> >> > ÂUsage, gccint, GNU Compiler Collection (GCC) Internals}.
> >> >
> >> > +Starting from GCC version 4.6, the default setting for 32-bit x86 targets
> >> > +has been changed to @option{-fomit-frame-pointer}. New behavior can be
> >> > +reverted back to @option{-fno-omit-frame-pointer} by configuring GCC with
> >> > +the @option{--enable-frame-pointer} configure option.
> >> > +
> >> > ÂEnabled at levels @option{-O}, @option{-O2}, @option{-O3}, @option{-Os}.
> >> >
> >> > Â@item -foptimize-sibling-calls
> >> >
> >>
> >> We default to --disable-frame-pointer only for 32bit x86 Linux and
> >> MACHO target always has -fno-omit-frame-pointer as default.
> >
> > HJ,
> > ÂI thought that, in i386.c, we only had omit-frame-pointer disabled
> > for 64-bit, no?
>
> We don't ENABLE it for 32bit MACHO now.
>
> BTW: If someone figures why "... for now" (and if perhaps that time
> already passed), we can easily fix the condition. ATM it just mirrors
> the 64bit one.
The only comment I can find in Apple's documentation on this is at...
http://developer.apple.com/mac/library/documentation/DeveloperTools/Conceptual/LowLevelABI/130-IA-32_Function_Calling_Conventions/IA32.html
The saved frame pointer (optional) contains the base address of the callerâs stack frame.
You can use the gcc -fomit-frame-pointer option to make the compiler not save, set up, and restore the frame pointer in function calls that donât need one, making the EBP register available for general use. However, doing so may impair debugging.
So it sounds like the same issue on linux. Would the debugging impairment be any different on
Mac OS X than on Linux (at least for the FSF gdb)?
Jack
>
> Uros.