diff mbox

PATCH [5/n]: Prepare x32: PR middle-end/48016: Inconsistency in non-local goto save area

Message ID BANLkTikR74CQL_j=sDLn1FZz+N6PNFqgdw@mail.gmail.com
State New
Headers show

Commit Message

H.J. Lu June 30, 2011, 6:05 p.m. UTC
On Wed, Jun 29, 2011 at 9:16 AM, Michael Matz <matz@suse.de> wrote:
> Hi,
>
> On Wed, 29 Jun 2011, H.J. Lu wrote:
>
>> > diff --git a/gcc/function.c b/gcc/function.c
>> > index 81c4d39..131bc09 100644
>> > --- a/gcc/function.c
>> > +++ b/gcc/function.c
>> > @@ -4780,7 +4780,7 @@ expand_function_start (tree subr)
>> >                       cfun->nonlocal_goto_save_area,
>> >                       integer_zero_node, NULL_TREE, NULL_TREE);
>> >       r_save = expand_expr (t_save, NULL_RTX, VOIDmode, EXPAND_WRITE);
>> > -      r_save = convert_memory_address (Pmode, r_save);
>> > +      r_save = adjust_address (r_save, Pmode, 0);
>
> This is actually the same problem as in explow.c.  t_save is built with
> ptr_type_node, where it should have been using
>  TREE_TYPE (TREE_TYPE (cfun->nonlocal_goto_save_area))
>
> Then r_save should have the correct mode already, possibly this could be
> asserted.  You are right that r_save needs to correspond to the
> nonlocal_goto_save_area[0] array-ref, hence pseudos aren't okay, therefore
> convert_memory_address isn't.  Actually I think we might even want to
> assert that indeed the expanded r_save is of Pmode already.
>
>

This patch works for me.  OK for trunk if there are no regressions?

Thanks.

Comments

Richard Biener July 1, 2011, 8:01 a.m. UTC | #1
On Thu, Jun 30, 2011 at 8:05 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
> On Wed, Jun 29, 2011 at 9:16 AM, Michael Matz <matz@suse.de> wrote:
>> Hi,
>>
>> On Wed, 29 Jun 2011, H.J. Lu wrote:
>>
>>> > diff --git a/gcc/function.c b/gcc/function.c
>>> > index 81c4d39..131bc09 100644
>>> > --- a/gcc/function.c
>>> > +++ b/gcc/function.c
>>> > @@ -4780,7 +4780,7 @@ expand_function_start (tree subr)
>>> >                       cfun->nonlocal_goto_save_area,
>>> >                       integer_zero_node, NULL_TREE, NULL_TREE);
>>> >       r_save = expand_expr (t_save, NULL_RTX, VOIDmode, EXPAND_WRITE);
>>> > -      r_save = convert_memory_address (Pmode, r_save);
>>> > +      r_save = adjust_address (r_save, Pmode, 0);
>>
>> This is actually the same problem as in explow.c.  t_save is built with
>> ptr_type_node, where it should have been using
>>  TREE_TYPE (TREE_TYPE (cfun->nonlocal_goto_save_area))
>>
>> Then r_save should have the correct mode already, possibly this could be
>> asserted.  You are right that r_save needs to correspond to the
>> nonlocal_goto_save_area[0] array-ref, hence pseudos aren't okay, therefore
>> convert_memory_address isn't.  Actually I think we might even want to
>> assert that indeed the expanded r_save is of Pmode already.
>>
>>
>
> This patch works for me.  OK for trunk if there are no regressions?

Ok.

Thanks,
Richard.

> Thanks.
>
>
> --
> H.J.
> ---
> 2011-06-30  H.J. Lu  <hongjiu.lu@intel.com>
>
>        PR middle-end/48016
>        * explow.c (update_nonlocal_goto_save_area): Use proper mode
>        for stack save area.
>        * function.c (expand_function_start): Likewise.
>
diff mbox

Patch

diff --git a/gcc/explow.c b/gcc/explow.c
index c7d8183..efe6c7e 100644
--- a/gcc/explow.c
+++ b/gcc/explow.c
@@ -1102,7 +1097,9 @@  update_nonlocal_goto_save_area (void)
      first one is used for the frame pointer save; the rest are sized by
      STACK_SAVEAREA_MODE.  Create a reference to array index 1, the first
      of the stack save area slots.  */
-  t_save = build4 (ARRAY_REF, ptr_type_node, cfun->nonlocal_goto_save_area,
+  t_save = build4 (ARRAY_REF,
+		   TREE_TYPE (TREE_TYPE (cfun->nonlocal_goto_save_area)),
+		   cfun->nonlocal_goto_save_area,
 		   integer_one_node, NULL_TREE, NULL_TREE);
   r_save = expand_expr (t_save, NULL_RTX, VOIDmode, EXPAND_WRITE);
 
diff --git a/gcc/function.c b/gcc/function.c
index 5be018a..0b2f5aa 100644
--- a/gcc/function.c
+++ b/gcc/function.c
@@ -4782,11 +4782,12 @@  expand_function_start (tree subr)
       if (!DECL_RTL_SET_P (var))
 	expand_decl (var);
 
-      t_save = build4 (ARRAY_REF, ptr_type_node,
+      t_save = build4 (ARRAY_REF,
+		       TREE_TYPE (TREE_TYPE (cfun->nonlocal_goto_save_area)),
 		       cfun->nonlocal_goto_save_area,
 		       integer_zero_node, NULL_TREE, NULL_TREE);
       r_save = expand_expr (t_save, NULL_RTX, VOIDmode, EXPAND_WRITE);
-      r_save = convert_memory_address (Pmode, r_save);
+      gcc_assert (GET_MODE (r_save) == Pmode);
 
       emit_move_insn (r_save, targetm.builtin_setjmp_frame_value ());
       update_nonlocal_goto_save_area ();