problem with call clobbered regs
Daniel Bayer
daniel.bayer@stud.uni-rostock.de
Fri Feb 13 12:03:00 GMT 2004
On Thu, Feb 12, 2004 at 03:31:19PM -0800, Jim Wilson wrote:
> Daniel Bayer wrote:
> >I already did that. The save and restore instructions are generated by
> >the caller-save code as insn 187 and 188 (24.greg). The code that
> >calculates the address for the saving is also generated in this pass
> >(some time later as insns 230 and 231). But there is no code to
> >calculate the address for the restore.
>
> This isn't a complete description of the problem. What does the RTL
> look like?
In save_call_clobbered_regs() this RTL is generated:
| (set (mem:QI (plus:QI (reg/f:QI 8 fp)
| (const_int -4 [0xfffffffc])) [0 S1 A16])
| (reg:QI 2 p2))
|
| (set (reg:QI 2 p2)
| (mem:QI (plus:QI (reg/f:QI 8 fp)
| (const_int -4 [0xfffffffc])) [0 S1 A16]))
> I would assume the address was calculated into a pseudo, in which case
> using it across the call is fine. It should be reg allocated to a
> call-saved register. Are there any call-saved registers? If not, that
> could be a problem.
By "call-saved register" you mean registers that are not clobbered?
There are 5 of them. But I disabled 2 and one is used as framepointer.
So there are 2 available.
> Is there are REG_EQUAL note the insn that calculates the address?
There is a REG_EQUIV note in the code generated by
emit_reload_insns(save_insn):
| (insn 230 0 231 (nil) (set (reg:QI 3 p3)
| (const_int -4 [0xfffffffc])) -1 (nil)
| (nil))
| (insn 231 230 0 (nil) (set (reg:QI 3 p3)
| (plus:QI (reg:QI 3 p3)
| (reg/f:QI 8 fp))) 11 {addqi3} (nil)
| (expr_list:REG_EQUIV (plus:QI (reg/f:QI 8 fp)
| (const_int -4 [0xfffffffc]))
| (nil)))
After emit_reload_insns() subst_reloads() is called with the save-insn
as argument. It is changed to
| (insn 187 231 79 5 (nil) (set (mem:QI (reg:QI 3 p3) [0 S1 A16])
| (reg:QI 2 p2)) 4 {*movqi_register_speicher_insn} (nil)
| (nil))
But in this very moment it also changes the restore insn to
| (insn 188 180 64 5 (nil) (set (reg:QI 2 p2)
| (mem:QI (reg:QI 3 p3) [0 S1 A16])) 2 {*movqi_speicher_register_insn} (nil)
| (nil))
I think this shouldn't happen because the comment to subst_reloads()
says that it only changes the argument and insns "just made for
reloading".
> If so, then reload could recalculate the address after the call. If
> the address is in a hard reg instead of a pseudo, then why is it in
> a hard reg? Who put it in a hard reg, and why was it put in a
> call-clobbered reg?
>
> You will probably have to step through the caller-save code and
> answer these questions. The caller-save code is not very
> complicated, so this shouldn't be very hard.
The caller-save code just puts the 2 insns I have listed above into the
reload_insn_chain. I think, that is right.
Daniel
More information about the Gcc
mailing list