[PATCH] Make frame saves identical for setjmp and non_local_goto in function.c
Richard Guenther
rguenther@suse.de
Fri May 23 09:03:00 GMT 2008
On Thu, 22 May 2008, Andy H wrote:
> This very simple patch corrects an anomaly in the generation of non-local
> goto information.
>
> The patch makes the saved frame value identical for both nested function
> gotos and setjmps.
>
> As no gcc hosted target (yet) uses TARGET_BUILTIN_SETJMP_FRAME_VALUE, the
> change has no effect.
> However, it is a prerequisite to correct AVR setjmp problems with an optimal
> solution.
>
> If this is acceptable change, please approve for 4.4 mainline.
>
> best regards
>
>
> Background
> ------------
>
> To perform either setjmp or goto from a nested function, the frame and stack
> pointers are saved in buffer.
>
> This pointer save code is created in two places.
>
> 1) For setjmp it is created by expand_builtin_setjmp_setup
> 2) For nested function goto it is created by: expand_function_start
>
> For setjmp the frame pointer value is saved using:
>
> emit_move_insn (mem, targetm.builtin_setjmp_frame_value ())
>
> However, expand_function_start uses:
>
> emit_move_insn (r_save, virtual_stack_vars_rtx)
>
> As both use same goto/receiver code they should to be identical. This works
> only because of the default :
> for TARGET_BUILTIN_SETJMP_FRAME_VALUE is virtual_stack_vars_rtx
>
> This target hook allows the true value of the frame_pointer to be saved and
> restored. Whereas
> virtual_stack_vars_rtx will incur addition and subtraction overheads if
> STARTING_FRAME_OFFSET !=0.
> However, because of the mismatch any attempt to utilise this hook, will
> cause either goto or setjmp to fail.
>
> In the AVR target, this is the case and I wish to set
>
> setjmp_frame_value = virtual_stack_vars_rtx - STARTING_FRAME_OFFSET
>
> which eliminate add/sub operations on frame pointer and minimizes the receiver
> code to nothing.
> (and allow me to fix another bug)
And you tested this on ... ?
Otherwise this is ok for mainline.
Thanks,
Richard.
> 2008-05-22 Andy Hutchinson <hutchinsonandy@aim.com>
>
> * gcc/function.c: Include target hook for nonlocal_goto frame value.
More information about the Gcc-patches
mailing list