From: Richard Biener <richard.guenther@gmail.com>
To: Aldy Hernandez <aldyh@redhat.com>
Cc: Andrew MacLeod <amacleod@redhat.com>,
Jakub Jelinek <jakub@redhat.com>,
Aldy Hernandez via Gcc-patches <gcc-patches@gcc.gnu.org>
Subject: Re: [RFC] Return NULL from gimple_call_return_type if no return available.
Date: Thu, 15 Jul 2021 15:06:00 +0200 [thread overview]
Message-ID: <CAFiYyc0yuNun_96qqh0XQ_jWHvc_4=O1wgRnuJWNoojdSNb2Mg@mail.gmail.com> (raw)
In-Reply-To: <CAGm3qMVbvxae0PhBhUm8ZYD9iLHPpW1vrG+1fmmu2Da3z_Y0cQ@mail.gmail.com>
On Thu, Jul 15, 2021 at 1:06 PM Aldy Hernandez <aldyh@redhat.com> wrote:
>
> Well, if we don't adjust gimple_call_return_type() to handle built-ins
> with no LHS, then we must adjust the callers.
>
> The attached patch fixes gimple_expr_type() per it's documentation:
>
> /* Return the type of the main expression computed by STMT. Return
> void_type_node if the statement computes nothing. */
>
> Currently gimple_expr_type is ICEing because it calls gimple_call_return_type.
>
> I still think gimple_call_return_type should return void_type_node
> instead of ICEing, but this will also fix my problem.
>
> Anyone have a problem with this?
It's still somewhat inconsistent, no? Because for a call without a LHS
it's now either void_type_node or the type of the return value.
It's probably known I dislike gimple_expr_type itself (it was introduced
to make the transition to tuples easier). I wonder why you can't simply
fix range_of_call to do
tree lhs = gimple_call_lhs (call);
if (lhs)
type = TREE_TYPE (lhs);
Richard.
>
> Aldy
>
> On Thu, Jun 24, 2021 at 3:57 PM Andrew MacLeod via Gcc-patches
> <gcc-patches@gcc.gnu.org> wrote:
> >
> > On 6/24/21 9:45 AM, Jakub Jelinek wrote:
> > > On Thu, Jun 24, 2021 at 09:31:13AM -0400, Andrew MacLeod via Gcc-patches wrote:
> > >> We'll still compute values for statements that don't have a LHS.. there's
> > >> nothing inherently wrong with that. The primary example is
> > >>
> > >> if (x_2 < y_3)
> > >>
> > >> we will compute [0,0] [1,1] or [0,1] for that statement, without a LHS. It
> > >> primarily becomes a generic way to ask for the range of each of the operands
> > >> of the statement, and process it regardless of the presence of a LHS. I
> > >> don't know, maybe there is (or will be) an internal function that doesn't
> > >> have a LHS but which can be folded away/rewritten if the operands are
> > >> certain values.
> > > There are many internal functions that aren't ECF_CONST or ECF_PURE. Some
> > > of them, like IFN*STORE* I think never have an lhs, others have them, but
> > > if the lhs is unused, various optimization passes can just remove those lhs
> > > from the internal fn calls (if they'd be ECF_CONST or ECF_PURE, the calls
> > > would be DCEd).
> > >
> > > I think generally, if a call doesn't have lhs, there is no point in
> > > computing a value range for that missing lhs. It won't be useful for the
> > > call arguments to lhs direction (nothing would care about that value) and
> > > it won't be useful on the direction from the lhs to the call arguments
> > > either. Say if one has
> > > p_23 = __builtin_memcpy (p_75, q_23, 16);
> > > then one can imply from ~[0, 0] range on p_75 that p_23 has that range too
> > > (and vice versa), but if one has
> > > __builtin_memcpy (p_125, q_23, 16);
> > > none of that makes sense.
> > >
> > > So instead of punting when gimple_call_return_type returns NULL IMHO the
> > > code should punt when gimple_call_lhs is NULL.
> > >
> > >
> >
> > Well, we are going to punt anyway, because the call type, whether it is
> > NULL or VOIDmode is not supported by irange. It was more just a matter
> > of figuring out whether us checking for internal call or the
> > gimple_function_return_type call should do the check... Ultimately in
> > the end it doesnt matter.. just seemed like something someone else could
> > trip across if we didnt strengthen gimple_call_return_type to not ice.
> >
> > Andrew
> >
next prev parent reply other threads:[~2021-07-15 13:06 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-23 15:03 Aldy Hernandez
2021-06-23 18:37 ` Richard Biener
2021-06-23 19:25 ` Andrew MacLeod
2021-06-24 9:07 ` Richard Biener
2021-06-24 13:31 ` Andrew MacLeod
2021-06-24 13:45 ` Jakub Jelinek
2021-06-24 13:55 ` Andrew MacLeod
2021-07-15 11:05 ` Aldy Hernandez
2021-07-15 13:06 ` Richard Biener [this message]
2021-07-15 13:16 ` Aldy Hernandez
2021-07-15 13:21 ` Richard Biener
2021-07-15 13:23 ` Richard Biener
2021-07-15 13:26 ` Richard Biener
2021-07-15 19:59 ` [COMMITTED] Add gimple_range_type for statements Andrew MacLeod
2021-07-16 7:07 ` Richard Biener
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='CAFiYyc0yuNun_96qqh0XQ_jWHvc_4=O1wgRnuJWNoojdSNb2Mg@mail.gmail.com' \
--to=richard.guenther@gmail.com \
--cc=aldyh@redhat.com \
--cc=amacleod@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=jakub@redhat.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).