From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23018 invoked by alias); 25 Jun 2011 16:07:08 -0000 Received: (qmail 23010 invoked by uid 22791); 25 Jun 2011 16:07:06 -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; Sat, 25 Jun 2011 16:06:50 +0000 Received: by qwh5 with SMTP id 5so1987235qwh.20 for ; Sat, 25 Jun 2011 09:06:49 -0700 (PDT) MIME-Version: 1.0 Received: by 10.229.79.196 with SMTP id q4mr2917049qck.132.1309018009036; Sat, 25 Jun 2011 09:06:49 -0700 (PDT) Received: by 10.229.238.19 with HTTP; Sat, 25 Jun 2011 09:06:48 -0700 (PDT) In-Reply-To: References: <20110611160548.GA20036@intel.com> Date: Sat, 25 Jun 2011 16:20: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/msg01914.txt.bz2 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 w= rong 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 F= IXMEs >>>>> > 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 c= allers >>>> of emit_stack_save already make sure to pass an object of correct mode= , 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->nonloc= al_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 documentat= ion >> 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: r_save =3D convert_memory_address (Pmode, r_save); emit_move_insn (r_save, targetm.builtin_setjmp_frame_value ()); R_SAVE must be lvalue. But return from convert_memory_address isn't. I am re-posting my patch here. OK for trunk? Thanks. --=20 H.J. --- 2011-06-15 H.J. Lu PR middle-end/48016 * explow.c (update_nonlocal_goto_save_area): Use proper mode for stack save area. * function.c (expand_function_start): Properly store frame pointer 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) 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 =3D build4 (ARRAY_REF, ptr_type_node, cfun->nonlocal_goto_save_ar= ea, + t_save =3D 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 =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) cfun->nonlocal_goto_save_area, integer_zero_node, NULL_TREE, NULL_TREE); r_save =3D expand_expr (t_save, NULL_RTX, VOIDmode, EXPAND_WRITE); - r_save =3D convert_memory_address (Pmode, r_save); + r_save =3D adjust_address (r_save, Pmode, 0); emit_move_insn (r_save, targetm.builtin_setjmp_frame_value ()); update_nonlocal_goto_save_area ();