public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Hans-Peter Nilsson <hp@bitrange.com>
To: Ulrich Weigand <uweigand@de.ibm.com>
Cc: Jeff Law <law@redhat.com>, gcc-patches@gcc.gnu.org
Subject: Re: Fix PR48542: reload register contents reuse crossing setjmp
Date: Tue, 19 Jul 2011 01:07:00 -0000	[thread overview]
Message-ID: <alpine.BSF.2.00.1107141538560.27138@dair.pair.com> (raw)
In-Reply-To: <201107141616.p6EGGKaP006516@d06av02.portsmouth.uk.ibm.com>

On Thu, 14 Jul 2011, Ulrich Weigand wrote:
> Jeff Law wrote:
> > On 06/15/11 21:46, Hans-Peter Nilsson wrote:
> > > 	PR rtl-optimization/48542
> > > 	* reload.c (find_equiv_reg): Stop looking when finding a
> > > 	setjmp-type call.
> > > 	* reload1.c (reload_as_needed): Invalidate all reload
> > > 	registers when crossing a setjmp-type call.
> > OK.
> > Jeff
>
> I see that this went already in, but I'm wondering why this
> change should be necessary.  As far as register use is
> concerned, setjmp ought to behave just like a regular function:
> if a register is call-clobbered, reload will not attempt to
> use it across a function call (*any* function call) anyway;
> but if the register is call-saved, setjmp really ought to
> restore the old value, *both* times it returns, and so reuse
> ought to be allowed ...

First of all, if this changes (back) in reload, then it should
change in IRA too.

Right; you do have a point.  I *think* my excuse would be that I
stopped thinking further when I saw that IRA doesn't allocate
registers across setjmp.

Changing this will make a difference for architectures (ABIs)
that don't save call-saved registers in the prologue but rather
for each call.  Crazy and suboptimal?  Not if you use register
windows or a register stack where you just (automatically as
part of the call insn or sequence) update a register number or
pointer for the call "save".  So MMIX is one, I guess sparc and
ia64 could be others, it seems so at a glance.  It all depends
on their setjmp/longjmp implementations of course, I don't have
the whole picture.

If you change this, such ports will then have to handle calls to
setjmp differently to other functions; not call-save across
those setjmp calls or else the call-saved register will be
picked up instead of the one saved at setjmp (restored at
longjmp).

The difference would be better code across calls to setjmp (and
related secondary effects in the setjmp-calling function) for
everyone else, but what is in place with the committed patch now
*is* consistent and correct and not needing special handling
regarding register-saving, AFAICT.

brgds, H-P

  parent reply	other threads:[~2011-07-18 23:44 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-16  5:08 Hans-Peter Nilsson
2011-06-16 22:57 ` Jeff Law
2011-07-14 16:23   ` Ulrich Weigand
2011-07-18 23:32     ` Jeff Law
2011-07-19  1:07     ` Hans-Peter Nilsson [this message]
2011-07-19 13:30       ` Ulrich Weigand

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.BSF.2.00.1107141538560.27138@dair.pair.com \
    --to=hp@bitrange.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=law@redhat.com \
    --cc=uweigand@de.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).