From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3282 invoked by alias); 29 Jun 2011 14:39:22 -0000 Received: (qmail 3107 invoked by uid 22791); 29 Jun 2011 14:39:19 -0000 X-SWARE-Spam-Status: No, hits=-2.3 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW X-Spam-Check-By: sourceware.org Received: from mail-qw0-f47.google.com (HELO mail-qw0-f47.google.com) (209.85.216.47) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 29 Jun 2011 14:39:01 +0000 Received: by qwh5 with SMTP id 5so724774qwh.20 for ; Wed, 29 Jun 2011 07:39:01 -0700 (PDT) MIME-Version: 1.0 Received: by 10.229.18.77 with SMTP id v13mr649214qca.56.1309358340876; Wed, 29 Jun 2011 07:39:00 -0700 (PDT) Received: by 10.229.214.83 with HTTP; Wed, 29 Jun 2011 07:39:00 -0700 (PDT) In-Reply-To: References: <20110611160548.GA20036@intel.com> Date: Wed, 29 Jun 2011 15:25:00 -0000 Message-ID: Subject: Re: PATCH [5/n]: Prepare x32: PR middle-end/48016: Inconsistency in non-local goto save area From: "H.J. Lu" To: Richard Guenther Cc: Michael Matz , gcc-patches@gcc.gnu.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org X-SW-Source: 2011-06/txt/msg02247.txt.bz2 Ping. On Sat, Jun 25, 2011 at 9:06 AM, H.J. Lu wrote: > On Thu, Jun 16, 2011 at 10:18 AM, H.J. Lu wrote: >> On Thu, Jun 16, 2011 at 12:56 AM, Richard Guenther >> wrote: >>> On Wed, Jun 15, 2011 at 9:55 PM, H.J. Lu wrote: >>>> On Wed, Jun 15, 2011 at 8:16 AM, Michael Matz wrote: >>>>> Hi, >>>>> >>>>> On Wed, 15 Jun 2011, H.J. Lu wrote: >>>>> >>>>>> >> + =A0/* FIXME: update_nonlocal_goto_save_area may pass SA in the = wrong mode. =A0*/ >>>>>> >> + =A0if (GET_MODE (sa) !=3D mode) >>>>>> >> + =A0 =A0{ >>>>>> >> + =A0 =A0 =A0gcc_assert (ptr_mode !=3D Pmode >>>>>> >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 && GET_MODE (sa) =3D=3D ptr_mode >>>>>> >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 && mode =3D=3D Pmode); >>>>>> >> + =A0 =A0 =A0sa =3D adjust_address (sa, mode, 0); >>>>>> >> + =A0 =A0} >>>>>> > >>>>>> > That may be appropriate for a branch, but trunk shouldn't contain = FIXMEs >>>>>> > that explain how something should be fixed, instead that something= should >>>>>> > be carried out. =A0I.e. just fix update_nonlocal_goto_save_area. >>>>>> > >>>>>> >>>>>> I don't know update_nonlocal_goto_save_area enough to fix it >>>>>> without breaking other targets. =A0This patch is the lest invasive. >>>>>> Any suggestions how to properly fix it is appreciated. >>>>> >>>>> Well, the most obvious variant would be to move the above code right >>>>> before the call of emit_stack_save in update_nonlocal_goto_save_area >>>>> (using r_save and STACK_SAVEAREA_MODE (SAVE_NONLOCAL)). =A0All other = callers >>>>> of emit_stack_save already make sure to pass an object of correct mod= e, so >>>>> this one should too. >>>>> >>>>> But I think it's better to just produce a correct array_ref from the >>>>> start. =A0get_nl_goto_field creates an array_type for the >>>>> nonlocal_goto_save_area of correct type (ptr_type_node or >>>>> lang_hooks.types.type_for_mode (Pmode, 1)), and we should use that. >>>>> >>>>> So something like this in update_nonlocal_goto_save_area: >>>>> =A0t_save =3D build4 (ARRAY_REF, >>>>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 TREE_TYPE (TREE_TYPE (cfun->nonlo= cal_goto_save_area)), >>>>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 cfun->nonlocal_goto_save_area, >>>>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 integer_one_node, NULL_TREE, NULL= _TREE); >>>>> >>>>> instead of the current building of t_save. =A0Then r_save also should= get >>>>> the correct mode automatically. >>>>> >>>> >>>> Here is the updated patch. =A0OK for trunk? >>> >>> The explow.c change is ok. =A0For the function.c change I wonder why >>> convert_memory_address doesn't do the right thing - from it's documenta= tion >>> it definitely should, so it should be fixed instead of being replaced by >>> adjust_address with a zero offset. >>> >> >> convert_memory_address may return a pseudo register converted >> to Pmode. =A0But here what we want is the same memory address >> adjusted for Pmode. =A0I don't think the usage of convert_memory_address >> > > Here is the code in question: > > =A0 =A0 =A0r_save =3D convert_memory_address (Pmode, r_save); > > =A0 =A0 =A0emit_move_insn (r_save, targetm.builtin_setjmp_frame_value ()); > > R_SAVE must be lvalue. =A0But return from convert_memory_address > isn't. I am re-posting my patch here. =A0OK for trunk? > > Thanks. > > -- > H.J. > --- > 2011-06-15 =A0H.J. Lu =A0 > > =A0 =A0 =A0 =A0PR middle-end/48016 > =A0 =A0 =A0 =A0* explow.c (update_nonlocal_goto_save_area): Use proper mo= de > =A0 =A0 =A0 =A0for stack save area. > > =A0 =A0 =A0 =A0* function.c (expand_function_start): Properly store frame > =A0 =A0 =A0 =A0pointer for non-local goto. > > 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) > =A0 =A0 =A0first one is used for the frame pointer save; the rest are siz= ed by > =A0 =A0 =A0STACK_SAVEAREA_MODE. =A0Create a reference to array index 1, t= he first > =A0 =A0 =A0of the stack save area slots. =A0*/ > - =A0t_save =3D build4 (ARRAY_REF, ptr_type_node, cfun->nonlocal_goto_sav= e_area, > + =A0t_save =3D build4 (ARRAY_REF, > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0TREE_TYPE (TREE_TYPE (cfun->nonlocal= _goto_save_area)), > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0cfun->nonlocal_goto_save_area, > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 integer_one_node, NULL_TREE, NULL_TRE= E); > =A0 r_save =3D expand_expr (t_save, NULL_RTX, VOIDmode, EXPAND_WRITE); > > 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) > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 cfun->nonlocal_goto_save_area, > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 integer_zero_node, NULL_TREE,= NULL_TREE); > =A0 =A0 =A0 r_save =3D expand_expr (t_save, NULL_RTX, VOIDmode, EXPAND_WR= ITE); > - =A0 =A0 =A0r_save =3D convert_memory_address (Pmode, r_save); > + =A0 =A0 =A0r_save =3D adjust_address (r_save, Pmode, 0); > > =A0 =A0 =A0 emit_move_insn (r_save, targetm.builtin_setjmp_frame_value ()= ); > =A0 =A0 =A0 update_nonlocal_goto_save_area (); > --=20 H.J.