public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: "H.J. Lu" <hjl.tools@gmail.com>
To: Richard Guenther <richard.guenther@gmail.com>
Cc: Michael Matz <matz@suse.de>, gcc-patches@gcc.gnu.org
Subject: Re: PATCH [5/n]: Prepare x32: PR middle-end/48016: Inconsistency in non-local goto save area
Date: Sat, 25 Jun 2011 16:20:00 -0000	[thread overview]
Message-ID: <BANLkTikorR2hgw1_7eMLMn6bgaPLW4ZW6w@mail.gmail.com> (raw)
In-Reply-To: <BANLkTi=TOW8sLqsG_SWvzRL_3YVHkt0D9g@mail.gmail.com>

On Thu, Jun 16, 2011 at 10:18 AM, H.J. Lu <hjl.tools@gmail.com> wrote:
> On Thu, Jun 16, 2011 at 12:56 AM, Richard Guenther
> <richard.guenther@gmail.com> wrote:
>> On Wed, Jun 15, 2011 at 9:55 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
>>> On Wed, Jun 15, 2011 at 8:16 AM, Michael Matz <matz@suse.de> wrote:
>>>> Hi,
>>>>
>>>> On Wed, 15 Jun 2011, H.J. Lu wrote:
>>>>
>>>>> >> +  /* FIXME: update_nonlocal_goto_save_area may pass SA in the wrong mode.  */
>>>>> >> +  if (GET_MODE (sa) != mode)
>>>>> >> +    {
>>>>> >> +      gcc_assert (ptr_mode != Pmode
>>>>> >> +               && GET_MODE (sa) == ptr_mode
>>>>> >> +               && mode == Pmode);
>>>>> >> +      sa = adjust_address (sa, mode, 0);
>>>>> >> +    }
>>>>> >
>>>>> > 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.  I.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.  This 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)).  All other callers
>>>> 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.  get_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:
>>>>  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);
>>>>
>>>> instead of the current building of t_save.  Then r_save also should get
>>>> the correct mode automatically.
>>>>
>>>
>>> Here is the updated patch.  OK for trunk?
>>
>> The explow.c change is ok.  For the function.c change I wonder why
>> convert_memory_address doesn't do the right thing - from it's documentation
>> 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.  But here what we want is the same memory address
> adjusted for Pmode.  I don't think the usage of convert_memory_address
>

Here is the code in question:

      r_save = 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.

-- 
H.J.
---
2011-06-15  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): 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 = 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 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);

       emit_move_insn (r_save, targetm.builtin_setjmp_frame_value ());
       update_nonlocal_goto_save_area ();

  reply	other threads:[~2011-06-25 16:07 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-11 16:22 H.J. Lu
2011-06-15 14:37 ` Michael Matz
2011-06-15 15:10   ` H.J. Lu
     [not found]     ` <Pine.LNX.4.64.1106151659200.17115@wotan.suse.de>
2011-06-16  6:41       ` H.J. Lu
2011-06-16  8:02         ` Richard Guenther
2011-06-16 17:59           ` H.J. Lu
2011-06-25 16:20             ` H.J. Lu [this message]
2011-06-29 15:25               ` H.J. Lu
2011-06-29 17:03                 ` Michael Matz
2011-06-30 18:10                   ` H.J. Lu
2011-07-01  8:01                     ` Richard Guenther

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=BANLkTikorR2hgw1_7eMLMn6bgaPLW4ZW6w@mail.gmail.com \
    --to=hjl.tools@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=matz@suse.de \
    --cc=richard.guenther@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).