public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Bug in simplify_subreg?
@ 2002-08-02  4:02 Lars Brinkhoff
  2002-08-02 16:56 ` Richard Henderson
  0 siblings, 1 reply; 7+ messages in thread
From: Lars Brinkhoff @ 2002-08-02  4:02 UTC (permalink / raw)
  To: gcc

In simplify-rtx.c:simplify_subreg, there is some code to simplify a
SUBREG of a hard register (starting around line 2557).  This code is
careful not to make the simplification if the register is the stack,
frame, or argument pointer.  However, if the (inner)mode is larger
than SImode, no check is made to ensure that the simplification isn't
made such that the result is one of the above pointers.

I have a situation where the second word of a DI register is allocated
to the frame pointer register (the function doesn't need a frame
pointer).  In this case, the ORIGINAL_REGNO of the frame_pointer_rtx
will be clobbered with the old pseudo REGNO (around line 2597), which
later will be referenced, causing a crash.

If I insert the same checks against final_regno as are made to
REGNO (op), everything seems to be fine.  Is this the right thing
to do?  If so, I'll test and submit a patch.

-- 
Lars Brinkhoff          http://lars.nocrew.org/     Linux, GCC, PDP-10,
Brinkhoff Consulting    http://www.brinkhoff.se/    HTTP programming

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Bug in simplify_subreg?
  2002-08-02  4:02 Bug in simplify_subreg? Lars Brinkhoff
@ 2002-08-02 16:56 ` Richard Henderson
  2002-08-05  4:22   ` Lars Brinkhoff
  0 siblings, 1 reply; 7+ messages in thread
From: Richard Henderson @ 2002-08-02 16:56 UTC (permalink / raw)
  To: Lars Brinkhoff; +Cc: gcc

On Fri, Aug 02, 2002 at 01:02:26PM +0200, Lars Brinkhoff wrote:
> If I insert the same checks against final_regno as are made to
> REGNO (op), everything seems to be fine.  Is this the right thing
> to do?

No.  If the frame pointer isn't being used, then
gen_reg_RTX isn't supposed to return frame_pointer_rtx.


r~

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Bug in simplify_subreg?
  2002-08-02 16:56 ` Richard Henderson
@ 2002-08-05  4:22   ` Lars Brinkhoff
  2002-08-05  5:29     ` Richard Earnshaw
  0 siblings, 1 reply; 7+ messages in thread
From: Lars Brinkhoff @ 2002-08-05  4:22 UTC (permalink / raw)
  To: Richard Henderson; +Cc: gcc

Richard Henderson <rth@redhat.com> writes:
> On Fri, Aug 02, 2002 at 01:02:26PM +0200, Lars Brinkhoff wrote:
> > If I insert the same checks against final_regno as are made to
> > REGNO (op), everything seems to be fine.  Is this the right thing
> > to do?
> No.  If the frame pointer isn't being used, then gen_reg_RTX isn't
> supposed to return frame_pointer_rtx.

But it does.  Since outermode==SImode==Pmode and reload_in_progress==0,
gen_reg_RTX returns frame_pointer_rtx to simplify_subreg.  And so
ORIGINAL_REGNO of frame_pointer_rtx is clobbered.

Would the right solution be to check frame_pointer_needed in gen_reg_RTX?

-- 
Lars Brinkhoff          http://lars.nocrew.org/     Linux, GCC, PDP-10,
Brinkhoff Consulting    http://www.brinkhoff.se/    HTTP programming

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Bug in simplify_subreg?
  2002-08-05  4:22   ` Lars Brinkhoff
@ 2002-08-05  5:29     ` Richard Earnshaw
  2002-08-05  5:43       ` Lars Brinkhoff
  0 siblings, 1 reply; 7+ messages in thread
From: Richard Earnshaw @ 2002-08-05  5:29 UTC (permalink / raw)
  To: Lars Brinkhoff; +Cc: Richard Henderson, gcc, Richard.Earnshaw

> Richard Henderson <rth@redhat.com> writes:
> > On Fri, Aug 02, 2002 at 01:02:26PM +0200, Lars Brinkhoff wrote:
> > > If I insert the same checks against final_regno as are made to
> > > REGNO (op), everything seems to be fine.  Is this the right thing
> > > to do?
> > No.  If the frame pointer isn't being used, then gen_reg_RTX isn't
> > supposed to return frame_pointer_rtx.
> 
> But it does.  Since outermode==SImode==Pmode and reload_in_progress==0,
> gen_reg_RTX returns frame_pointer_rtx to simplify_subreg.  And so
> ORIGINAL_REGNO of frame_pointer_rtx is clobbered.
> 
> Would the right solution be to check frame_pointer_needed in gen_reg_RTX?

We cannot know for certain whether a frame pointer is needed before reload 
starts.  Even during reload the decision might change -- on some machines 
the decision may depend on which registers are being used by the function 
-- and that can change as we push more reloads.

It's probable that on many machines we can accurately guess whether a 
frame pointer is needed or not before reload starts to run, but there's no 
way to be sure.

R.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Bug in simplify_subreg?
  2002-08-05  5:29     ` Richard Earnshaw
@ 2002-08-05  5:43       ` Lars Brinkhoff
  2002-08-06 19:09         ` Richard Henderson
  0 siblings, 1 reply; 7+ messages in thread
From: Lars Brinkhoff @ 2002-08-05  5:43 UTC (permalink / raw)
  To: Richard.Earnshaw; +Cc: Richard Henderson, gcc

Richard Earnshaw <rearnsha@arm.com> writes:
> > Since outermode==SImode==Pmode and reload_in_progress==0,
> > gen_reg_RTX returns frame_pointer_rtx to simplify_subreg.  And so
> > ORIGINAL_REGNO of frame_pointer_rtx is clobbered.
> It's probable that on many machines we can accurately guess whether a 
> frame pointer is needed or not before reload starts to run, but there's no 
> way to be sure.

Ok, then how about doing
    ORIGINAL_REGNO (frame_pointer_rtx) = FRAME_POINTER_REGNUM;
after compilation of every function?

Any other suggestions?

-- 
Lars Brinkhoff          http://lars.nocrew.org/     Linux, GCC, PDP-10,
Brinkhoff Consulting    http://www.brinkhoff.se/    HTTP programming

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Bug in simplify_subreg?
  2002-08-05  5:43       ` Lars Brinkhoff
@ 2002-08-06 19:09         ` Richard Henderson
  2002-08-07  5:15           ` Richard Earnshaw
  0 siblings, 1 reply; 7+ messages in thread
From: Richard Henderson @ 2002-08-06 19:09 UTC (permalink / raw)
  To: Lars Brinkhoff; +Cc: Richard.Earnshaw, gcc

On Mon, Aug 05, 2002 at 02:43:06PM +0200, Lars Brinkhoff wrote:
> Any other suggestions?

gen_reg_RTX should check reload_compled && frame_pointer_needed.


r~

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Bug in simplify_subreg?
  2002-08-06 19:09         ` Richard Henderson
@ 2002-08-07  5:15           ` Richard Earnshaw
  0 siblings, 0 replies; 7+ messages in thread
From: Richard Earnshaw @ 2002-08-07  5:15 UTC (permalink / raw)
  To: Richard Henderson; +Cc: Lars Brinkhoff, Richard.Earnshaw, gcc

> On Mon, Aug 05, 2002 at 02:43:06PM +0200, Lars Brinkhoff wrote:
> > Any other suggestions?
> 
> gen_reg_RTX should check reload_compled && frame_pointer_needed.
> 
> 
> r~

After reload we should certainly not be returning frame_pointer_rtx on the 
ARM, or any other platform that defines HARD_FRAME_POINTER_REGNUM.

R.

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2002-08-07  5:15 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-08-02  4:02 Bug in simplify_subreg? Lars Brinkhoff
2002-08-02 16:56 ` Richard Henderson
2002-08-05  4:22   ` Lars Brinkhoff
2002-08-05  5:29     ` Richard Earnshaw
2002-08-05  5:43       ` Lars Brinkhoff
2002-08-06 19:09         ` Richard Henderson
2002-08-07  5:15           ` Richard Earnshaw

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).