This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Why doesn't -fomit-frame-pointer work(very well)?
- From: Peter Barada <pbarada at mail dot wm dot sps dot mot dot com>
- To: gcc at gcc dot gnu dot org
- Date: Mon, 1 Apr 2002 13:01:00 -0500
- Subject: Why doesn't -fomit-frame-pointer work(very well)?
I've noticed that gcc-3.0.4 doesn't eliminate the frame pointer very
well when asked to with -fomit-frame-pointer, at least for a compiler
configured for m68k-elf.
Here's a simple function that should easily have its frame pointer
elimintated, and when built with -m68000 -O -fomit-frame-pointer, doesn't:
typedef __builtin_va_list __gnuc_va_list;
typedef __gnuc_va_list va_list;
extern void putzi(char c, char **p);
extern int _vformat (void (*putsub)(char c, char **p),
char **putbuf, const char *fmt, va_list argp);
int printf(const char *template, ...)
{
int retval;
va_list args;
__builtin_stdarg_start((args),template);
retval = _vformat(putzi, (char **)0, template, args);
__builtin_va_end(args);
return (retval);
}
.file "z.c"
.text
.globl printf
.type printf,@function
printf:
link.w %a6,#0
pea 12(%a6)
move.l 8(%a6),-(%sp)
clr.l -(%sp)
pea putzi
jbsr _vformat
lea (16,%sp),%sp
unlk %a6
rts
The reason in this case is the instruction:
(gdb) where 3
#0 elimination_effects (x=0x4001c010, mem_mode=VOIDmode)
at /home/pbarada/work/cvs-wavemark/cross-linux-tools/gcc-304/gcc/reload1.c:2711
#1 0x08166133 in elimination_effects (x=0x401af9f0, mem_mode=VOIDmode)
at /home/pbarada/work/cvs-wavemark/cross-linux-tools/gcc-304/gcc/reload1.c:2852
#2 0x081665fe in eliminate_regs_in_insn (insn=0x400237e0, replace=0)
at /home/pbarada/work/cvs-wavemark/cross-linux-tools/gcc-304/gcc/reload1.c:3093
(More stack frames follow...)
(gdb) fra 2
#2 0x081665fe in eliminate_regs_in_insn (insn=0x400237e0, replace=0)
at /home/pbarada/work/cvs-wavemark/cross-linux-tools/gcc-304/gcc/reload1.c:3093
(gdb) call debug_rtx(insn)
(insn 17 14 19 (set (mem/f:SI (pre_dec:SI (reg/f:SI 15 %sp)) 0)
(plus:SI (reg/f:SI 14 %a6)
(const_int 12 [0xc]))) 60 {pushasi} (nil)
(nil))
SInce it references both the stack and the frame pointer then the code
declares that its impossible to eliminate it(via
reg_eliminate[0].ref_outside_mem being set to true which later causes
reg_eliminate[0].can_eliminate to be set to ).
Unfortunately passing paramters to child functions is a common
construct... Any ideas how best to fix this? Does frame pointer
elimination work in other ports?
--
Peter Barada Peter.Barada@motorola.com
Wizard 781-852-2768 (direct)
WaveMark Solutions(wholly owned by Motorola) 781-270-0193 (fax)