* [PATCH] Make frame saves identical for setjmp and non_local_goto in function.c
@ 2008-05-23 1:42 Andy H
2008-05-23 9:03 ` Richard Guenther
0 siblings, 1 reply; 3+ messages in thread
From: Andy H @ 2008-05-23 1:42 UTC (permalink / raw)
To: gcc-patches; +Cc: rguenther
[-- Attachment #1: Type: text/plain, Size: 1862 bytes --]
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)
2008-05-22 Andy Hutchinson <hutchinsonandy@aim.com>
* gcc/function.c: Include target hook for nonlocal_goto frame value.
[-- Attachment #2: funcFrame.patch --]
[-- Type: text/plain, Size: 481 bytes --]
Index: function.c
===================================================================
--- function.c (revision 135702)
+++ function.c (working copy)
@@ -4231,7 +4231,7 @@
r_save = expand_expr (t_save, NULL_RTX, VOIDmode, EXPAND_WRITE);
r_save = convert_memory_address (Pmode, r_save);
- emit_move_insn (r_save, virtual_stack_vars_rtx);
+ emit_move_insn (r_save, targetm.builtin_setjmp_frame_value ());
update_nonlocal_goto_save_area ();
}
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Make frame saves identical for setjmp and non_local_goto in function.c
2008-05-23 1:42 [PATCH] Make frame saves identical for setjmp and non_local_goto in function.c Andy H
@ 2008-05-23 9:03 ` Richard Guenther
0 siblings, 0 replies; 3+ messages in thread
From: Richard Guenther @ 2008-05-23 9:03 UTC (permalink / raw)
To: Andy H; +Cc: gcc-patches
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.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Make frame saves identical for setjmp and non_local_goto in function.c
@ 2008-05-24 21:06 Andy H
0 siblings, 0 replies; 3+ messages in thread
From: Andy H @ 2008-05-24 21:06 UTC (permalink / raw)
To: gcc-patches, Richard Guenther
Sorry for missing that out.
it was tested with/without patch for all gcc tests on Native
configuration is i686-pc-linux-gnu
No differences in result.
Thank for prompt reply!
Andy
> 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.
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2008-05-24 16:52 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-05-23 1:42 [PATCH] Make frame saves identical for setjmp and non_local_goto in function.c Andy H
2008-05-23 9:03 ` Richard Guenther
2008-05-24 21:06 Andy H
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).