public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Biener <richard.guenther@gmail.com>
To: guojiufu <guojiufu@linux.ibm.com>
Cc: Bill Schmidt <wschmidt@linux.ibm.com>,
	Ian Lance Taylor <ian@airs.com>,
	 Richard Biener <rguenther@suse.de>,
	GCC Patches <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH] go/100537 - Bootstrap-O3 and bootstrap-debug fail
Date: Mon, 17 May 2021 10:17:02 +0200	[thread overview]
Message-ID: <CAFiYyc0Hd_=GG36g3vhGoBtbwq1KT0K6=Z18v9K2BcRBsDA4YA@mail.gmail.com> (raw)
In-Reply-To: <7bff8b84e66198cbf8710768cfa5fa7f@imap.linux.ibm.com>

On Fri, May 14, 2021 at 11:19 AM guojiufu via Gcc-patches
<gcc-patches@gcc.gnu.org> wrote:
>
> On 2021-05-14 15:39, guojiufu via Gcc-patches wrote:
> > On 2021-05-14 15:15, Richard Biener wrote:
> >> On May 14, 2021 4:52:56 AM GMT+02:00, Jiufu Guo
> >> <guojiufu@linux.ibm.com> wrote:
> >>> As discussed in the PR, Richard mentioned the method to
> >>> figure out which VAR was not set TREE_ADDRESSABLE, and
> >>> then cause this failure.  It is address_expression which
> >>> build addr_expr (build_fold_addr_expr_loc), but not set
> >>> TREE_ADDRESSABLE.
> >>>
> >>> I drafted this patch with reference the comments from Richard
> >>> in this PR, while I'm not quite sure if more thing need to do.
> >>> So, please have review, thanks!
> >>>
> >>> Bootstrap and regtest pass on ppc64le. Is this ok for trunk?
> >>
> >> I suggest to use mark_addresssable unless we're sure expr is always an
> >> entity where TREE_ADDRESSABLE has the desired meaning.
>
> Thanks, Richard!
> You point out the root concern, I'm not sure ;)
>
> With looking at code "mark_addresssable" and code around
> tree-ssa.c:1013,
> VAR_P, PARM_DECL, and RESULT_DECL are checked before accessing
> TREE_ADDRESSABLE.
> So, just wondering if these entities need to be marked as
> TREE_ADDRESSABLE?
>
> diff --git a/gcc/go/go-gcc.cc b/gcc/go/go-gcc.cc
> index 5d9dbb5d068..85d324a92cc 100644
> --- a/gcc/go/go-gcc.cc
> +++ b/gcc/go/go-gcc.cc
> @@ -1680,6 +1680,11 @@ Gcc_backend::address_expression(Bexpression*
> bexpr, Location location)
>     if (expr == error_mark_node)
>       return this->error_expression();
>
> +  if ((VAR_P(expr)
> +       || TREE_CODE(expr) == PARM_DECL
> +       || TREE_CODE(expr) == RESULT_DECL)
> +    TREE_ADDRESSABLE (expr) = 1;
> +

The root concern is that mark_addressable does

  while (handled_component_p (x))
    x = TREE_OPERAND (x, 0);

and I do not know the constraints on 'expr' as passed to
Gcc_backend::address_expression.

I think we need input from Ian here.  Most FEs have their own *_mark_addressable
function where they also emit diagnostics (guess this is handled in
the actual Go frontend).
Since Gcc_backend does lowering to GENERIC using a middle-end is probably OK.

>     tree ret = build_fold_addr_expr_loc(location.gcc_location(), expr);
>     return this->make_expression(ret);
>   }
>
>
> Or call mark_addressable, and update mark_addressable to avoid NULL
> pointer ICE:
> The below patch also pass bootstrap-debug.
>
> diff --git a/gcc/gimple-expr.c b/gcc/gimple-expr.c
> index b8c732b632a..f682841391b 100644
> --- a/gcc/gimple-expr.c
> +++ b/gcc/gimple-expr.c
> @@ -915,6 +915,7 @@ mark_addressable (tree x)
>     if (TREE_CODE (x) == VAR_DECL
>         && !DECL_EXTERNAL (x)
>         && !TREE_STATIC (x)
> +      && cfun != NULL

I'd be OK with this hunk of course.

>         && cfun->gimple_df != NULL
>         && cfun->gimple_df->decls_to_pointers != NULL)
>       {
> diff --git a/gcc/go/go-gcc.cc b/gcc/go/go-gcc.cc
> index 5d9dbb5d068..fe9dfaf8579 100644
> --- a/gcc/go/go-gcc.cc
> +++ b/gcc/go/go-gcc.cc
> @@ -1680,6 +1680,7 @@ Gcc_backend::address_expression(Bexpression*
> bexpr, Location location)
>     if (expr == error_mark_node)
>       return this->error_expression();
>
> +  mark_addressable(expr);
>     tree ret = build_fold_addr_expr_loc(location.gcc_location(), expr);
>     return this->make_expression(ret);
>   }
>
>
> >
> > I notice you mentioned "mark_addresssable" in PR.
> > And I had tried yesterday, it cause new ICEs at gimple-expr.c:918
> > below line:
> >
> >   && cfun->gimple_df != NULL
> >
> >
> >
> >>
> >> Richard.
> >>
> >>> Jiufu Guo.
> >>>
> >>> 2021-05-14  Richard Biener  <rguenther@suse.de>
> >>>         Jiufu Guo <guojiufu@linux.ibm.com>
> >>>
> >>>         PR go/100537
> >>>         * go-gcc.cc
> >>>         (Gcc_backend::address_expression): Set TREE_ADDRESSABLE.
> >>>
> >>> ---
> >>> gcc/go/go-gcc.cc | 1 +
> >>> 1 file changed, 1 insertion(+)
> >>>
> >>> diff --git a/gcc/go/go-gcc.cc b/gcc/go/go-gcc.cc
> >>> index 5d9dbb5d068..8ed20a3b479 100644
> >>> --- a/gcc/go/go-gcc.cc
> >>> +++ b/gcc/go/go-gcc.cc
> >>> @@ -1680,6 +1680,7 @@ Gcc_backend::address_expression(Bexpression*
> >>> bexpr, Location location)
> >>>   if (expr == error_mark_node)
> >>>     return this->error_expression();
> >>>
> >>> +  TREE_ADDRESSABLE (expr) = 1;
> >>>   tree ret = build_fold_addr_expr_loc(location.gcc_location(), expr);
> >>>   return this->make_expression(ret);
> >>> }

  reply	other threads:[~2021-05-17  8:17 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-14  2:52 Jiufu Guo
2021-05-14  7:15 ` Richard Biener
2021-05-14  7:39   ` guojiufu
2021-05-14  8:21     ` guojiufu
2021-05-17  8:17       ` Richard Biener [this message]
2021-05-18  1:18         ` guojiufu
2021-05-18  1:48         ` Ian Lance Taylor
2021-05-18  6:58           ` Richard Biener
2021-05-18 13:14             ` guojiufu
2021-05-20  8:59             ` guojiufu
2021-05-24 21:46               ` Ian Lance Taylor

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='CAFiYyc0Hd_=GG36g3vhGoBtbwq1KT0K6=Z18v9K2BcRBsDA4YA@mail.gmail.com' \
    --to=richard.guenther@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=guojiufu@linux.ibm.com \
    --cc=ian@airs.com \
    --cc=rguenther@suse.de \
    --cc=wschmidt@linux.ibm.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).