This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: avoid unnecessary register saves for setjmp
On Fri, Nov 21, 2003 at 04:20:29PM -0800, Jim Wilson wrote:
> On Fri, 2003-11-21 at 09:55, Daniel Jacobowitz wrote:
> > I recently spent some time investigating this same code. I was working
> > on an ARM target with the iWMMXt extension set, which includes a number
> > of additional registers. The existing setjmp implementation on that
> > target did not save them, but things worked anyway; I dug, and this was
> > how.
>
> We could perhaps use NON_SAVING_SETJMP for this, but I think fixing
> setjmp is a better solution. Assuming it needs to save any of the
> iWMMXt registers.
>
> > Speaking of Altivec, at least the GNU/Linux glibc setjmp implementation
> > doesn't save Altivec registers either. I posted a patch for this about
> > three years ago and it was never incorporated. So we may see problems
> > reported from that side.
>
> PR 12817 is from people asking gcc to not save the altivec registers
> around setjmp, because it isn't supposed to. So at least some PowerPC
> folks believe that this register saving is wrong.
If your setjmp saves them, sure.
Here's the difficulty: changing the size of jmp_buf. Lately (last
three years or so) there have been a rash of ISA extensions implemented
which would require incompatible changes to jmp_buf for a widely
deployed architecture. This is remarkably painful.
> > I discussed this on IRC with a few people; I don't remember who all of
> > them were, but definitely including H-P. My conclusion from the
> > discussion was that the setjmp standard library function is _not_
> > mandated by C99 to save all registers. I do not know of any psABI
> > documents which specify the saved registers either. So I am a little
> > uncomfortable with your patch.
>
> Yes, setjmp is not required to save registers. Gcc knows this, and
> avoids allocating pseudos to registers if the pseudo lives across a
> setjmp. We don't need to save unused registers to make this work.
Sure - but that assumes that all unused call-saved registers are
restored by the setjmp. So then it is required to save registers to
get reasonable behavior.
--
Daniel Jacobowitz
MontaVista Software Debian GNU/Linux Developer