This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Why doesn't -fomit-frame-pointer work(very well)?
At 6:27 PM -0500 4/4/02, Peter Barada wrote:
> >On Wed, Apr 03, 2002 at 06:01:40PM -0500, Peter Barada wrote:
>>> So it looks like it tried to eliminate the frame pointer and then
>>> failed.
>>
>>Hum. I suspect that reload doesn't like %sp being modifed
>>and used within the same insn. In fact, IIRC this is illegal
>>on ARM, so there may well be code in there to prevent this.
>
>I didn't find any explicit code to disallow modifying %sp in an
>instruction that refers to it. After adding in ARG_POINTER_REGNUM to
>mimic what others have done (i386, h8300, etc), I have in 3.0.4(for
>the non-FPA case):
I'm pretty sure that there is code in register elimination that won't eliminate if
there's a change-and-use in the same instruction.
This is because the semantics of that are machine-dependent (you might have a code pattern that
knows it's safe to generate
move -(sp),4(sp)
because you know that the src address is evaluated before the stack is adjusted).
I remember running into this before on a machine that only had 3 registers capable of indirection
(and only two of them allowed any displacement offset!) Making register elimination work was
particularly critical!
....
Okay, rather than being cryptic, I went and looked at the source code.....
In reload1.c elimination_effects() will stumble on things like push instructions that try to eliminate
into SP-relative addresses.
I fixed this in the case SET: leg of the switch stmt by recursively calling elimination_effects() on
the SET_SRC with something like....
mem_mode = GET_MODE (SET_DEST (x));
elimination_effects (SET_SRC (x),
(push_operand (SET_DEST (x), mem_mode) ? mem_mode : 0));
instead of the
elimination_effects (SET_SRC (x), 0);
that's normally there.
--
------------------------------------------------------------------------
Quality Software Management
http://home.earthlink.net/~qsmgmt
apl@alum.mit.edu
(978)287-0435 Voice
(978)808-6836 Cell
(978)287-0436 Fax
Software Process Improvement and Management Consulting
Language Design and Compiler Implementation