From: David Malcolm <dmalcolm@redhat.com>
To: Jakub Jelinek <jakub@redhat.com>, Martin Sebor <msebor@gmail.com>
Cc: gcc-patches <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH] avoid assuming gimple_call_alloc_size argument is a call (PR 99489)
Date: Fri, 12 Mar 2021 09:04:33 -0500 [thread overview]
Message-ID: <d1345b1e659264ed0de1464c89d0818b18bb942f.camel@redhat.com> (raw)
In-Reply-To: <20210312135220.GW745611@tucnak>
On Fri, 2021-03-12 at 14:52 +0100, Jakub Jelinek via Gcc-patches wrote:
> On Tue, Mar 09, 2021 at 03:07:38PM -0700, Martin Sebor via Gcc-
> patches wrote:
> > The gimple_call_alloc_size() function is documented to "return null
> > when STMT is not a call to a valid allocation function" but the
> > code
> > assumes STMT is a call statement, causing the function to ICE when
> > it isn't.
> >
> > The attached patch changes the function to fulfill its contract and
> > return null also when STMT isn't a call. The fix seems obvious to
> > me but I'll wait some time before committing it in case it's not
> > to someone else.
>
> I think the name of the function suggests that it should be called on
> calls,
> not random stmts. Currently the function has 3 callers, two of them
> already verify is_gimple_call before calling it and only one doesn't,
> and the stmt will never be NULL.
> So I'd say it would be better to remove the if (!stmt) return
> NULL_TREE;
> from the start of the function and add is_gimple_call (stmt) &&
> in tree-ssa-strlen.c.
Maybe even make it convert it to taking a "const gcall *", so those
if (is_gimple_call (stmt))
{
...
if (gimple_call_alloc_size (stmt, ...))
{
}
}
become:
if (const gcall *call = dyn_cast <const gcall *> (stmt))
{
...
if (gimple_call_alloc_size (call, ...))
{
}
}
so that the compiler can enforce this requirement via the type system?
Hope this is constructive
Dave
next prev parent reply other threads:[~2021-03-12 14:04 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-09 22:07 Martin Sebor
2021-03-12 13:52 ` Jakub Jelinek
2021-03-12 14:04 ` David Malcolm [this message]
2021-03-12 14:11 ` Jakub Jelinek
2021-03-13 21:31 ` Martin Sebor
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=d1345b1e659264ed0de1464c89d0818b18bb942f.camel@redhat.com \
--to=dmalcolm@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=jakub@redhat.com \
--cc=msebor@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).