This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: avoid unnecessary register saves for setjmp


On Fri, 2003-11-21 at 19:08, Daniel Jacobowitz wrote:
> Here's the difficulty: changing the size of jmp_buf.

That is a good point.  Still, we shouldn't penalize targets that have
defined setjmp correctly.  So I suggest using NON_SAVING_SETJMP for
this.  This will do what you want if you define it for your target. 
I'll go ahead and fix NON_SAVING_SETJMP to make it usable.

> 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.

You are confusing two different issues here.  setjmp is not required to
restore call-used registers.  Thus any value stored in a register in
this function may not be restored when longjmp is called.  This is why
the C language standard says that local automatic non-volatile variables
may not be restored by longjmp.  However, setjmp is required to restore
the original context, and that means call-saved registers must be
restored.  A setjmp call is not allowed to clobber locals in the parent
function, which is what would happen if call-saved registers were not
restored.
-- 
Jim Wilson, GNU Tools Support, http://www.SpecifixInc.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]