Using both -fomit-frame-pointer and -momit-leaf-frame-pointer _enables_ frame pointers for non-leaf functions. > cat x.c int foo(void) { return 0; } int bar(void) { return foo() + 1; } > gcc-3.4 -O2 -fomit-frame-pointer -c x.c && objdump -d x.o [...] 00000010 <bar>: 10: e8 fc ff ff ff call 11 <bar+0x1> 15: 40 inc %eax 16: c3 ret [...] > gcc-3.4 -O2 -fomit-frame-pointer -momit-leaf-frame-pointer -c x.c && objdump -d x.o [...] 00000010 <bar>: 10: 55 push %ebp 11: 89 e5 mov %esp,%ebp 13: e8 fc ff ff ff call 14 <bar+0x4> 18: 5d pop %ebp 19: 40 inc %eax 1a: c3 ret [...] This check in i386.c ix86_frame_pointer_required() could be the cause: /* In override_options, TARGET_OMIT_LEAF_FRAME_POINTER turns off the frame pointer by default. Turn it back on now if we've not got a leaf function. */ if (TARGET_OMIT_LEAF_FRAME_POINTER && (!current_function_is_leaf)) return 1;
Roger?
Subject: Bug 18759 CVSROOT: /cvs/gcc Module name: gcc Changes by: sayle@gcc.gnu.org 2004-12-02 21:19:35 Modified files: gcc : ChangeLog gcc/config/i386: i386.c Log message: PR target/18759 * config/i386/i386.c (override_options): If -fomit-frame-pointer has already been specified, ignore the -momit-leaf-frame-pointer option. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.6689&r2=2.6690 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/config/i386/i386.c.diff?cvsroot=gcc&r1=1.747&r2=1.748
Fixed on the mainline.
Might this be a candidate for 3.3/3.4 backporting ?
I'm backporting this patch to csl-sol210-3_4-branch. In theory there's a regression on vanilla 3.4 if you build pr9771-1.c with -momit-leaf-frame-pointer in addition to the options specified in that testcase (then this bug causes it to fail); it's just the Solaris 10 port which isn't in vanilla 3.4 which makes this more visible by having -momit-leaf-frame-pointer on by default when optimizing.
Subject: Bug 18759 CVSROOT: /cvs/gcc Module name: gcc Branch: csl-sol210-3_4-branch Changes by: jsm28@gcc.gnu.org 2005-05-03 21:54:14 Modified files: . : ChangeLog.csl gcc/config/i386: i386.c Log message: Backport from mainline: 2004-12-02 Roger Sayle <roger@eyesopen.com> PR target/18759 * config/i386/i386.c (override_options): If -fomit-frame-pointer has already been specified, ignore the -momit-leaf-frame-pointer option. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/ChangeLog.csl.diff?cvsroot=gcc&only_with_tag=csl-sol210-3_4-branch&r1=1.1.2.16&r2=1.1.2.17 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/config/i386/i386.c.diff?cvsroot=gcc&only_with_tag=csl-sol210-3_4-branch&r1=1.635.2.15.2.2&r2=1.635.2.15.2.3