From: Marek Polacek <polacek@redhat.com>
To: Richard Biener <richard.guenther@gmail.com>
Cc: GCC Patches <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH] Fix ICE with bogus posix_memalign call (PR middle-end/67222)
Date: Tue, 18 Aug 2015 12:03:00 -0000 [thread overview]
Message-ID: <20150818111041.GK2093@redhat.com> (raw)
In-Reply-To: <CAFiYyc3JGMNRv3zdmMA4GnQrkvjXphKfHGnpjceo-EyaW6frcw@mail.gmail.com>
On Tue, Aug 18, 2015 at 12:47:45PM +0200, Richard Biener wrote:
> Please instead change the tree-ssa-alias.c code to do
>
> if (callee != NULL
> && gimple_call_builtin_p (call, BUILT_IN_NORMAL))
> switch (DECL_FUNCTION_CODE (callee))
> ...
Ok. I see that works as well because gimple_call_builtin_p uses
gimple_builtin_call_types_compatible_p.
> which should also fix quite a few issues in the other builtin handlings.
> Likewise can you change stmt_kills_ref_p and ref_maybe_used_by_call_p_1
> in a similar way?
Sure. Regtest/bootstrap running, ok for trunk/5 if it passes?
2015-08-18 Marek Polacek <polacek@redhat.com>
PR middle-end/67222
* gimple-low.c (lower_stmt): Don't lower BUILT_IN_POSIX_MEMALIGN
if the call isn't valid.
* tree-ssa-alias.c (ref_maybe_used_by_call_p_1): Check builtins using
gimple_call_builtin_p.
(call_may_clobber_ref_p_1): Likewise.
(stmt_kills_ref_p): Likewise.
* gcc.dg/torture/pr67222.c: New test.
diff --git gcc/gimple-low.c gcc/gimple-low.c
index d4697e2..4eae3a0 100644
--- gcc/gimple-low.c
+++ gcc/gimple-low.c
@@ -346,7 +346,8 @@ lower_stmt (gimple_stmt_iterator *gsi, struct lower_data *data)
return;
}
else if (DECL_FUNCTION_CODE (decl) == BUILT_IN_POSIX_MEMALIGN
- && flag_tree_bit_ccp)
+ && flag_tree_bit_ccp
+ && gimple_builtin_call_types_compatible_p (stmt, decl))
{
lower_builtin_posix_memalign (gsi);
return;
diff --git gcc/testsuite/gcc.dg/torture/pr67222.c gcc/testsuite/gcc.dg/torture/pr67222.c
index e69de29..739f869 100644
--- gcc/testsuite/gcc.dg/torture/pr67222.c
+++ gcc/testsuite/gcc.dg/torture/pr67222.c
@@ -0,0 +1,19 @@
+/* PR middle-end/67222 */
+/* { dg-do compile } */
+
+void
+foo (void **p)
+{
+ posix_memalign (); /* { dg-warning "implicit declaration" } */
+ posix_memalign (p);
+ posix_memalign (0);
+ posix_memalign (p, 1);
+ posix_memalign (p, "foo");
+ posix_memalign ("gnu", "gcc");
+ posix_memalign (1, p);
+ posix_memalign (1, 2);
+ posix_memalign (1, 2, 3);
+ posix_memalign (p, p, p);
+ posix_memalign (p, "qui", 3);
+ posix_memalign (p, 1, 2);
+}
diff --git gcc/tree-ssa-alias.c gcc/tree-ssa-alias.c
index e103220..0445052 100644
--- gcc/tree-ssa-alias.c
+++ gcc/tree-ssa-alias.c
@@ -1535,7 +1535,7 @@ ref_maybe_used_by_call_p_1 (gcall *call, ao_ref *ref)
escape points. See tree-ssa-structalias.c:find_func_aliases
for the list of builtins we might need to handle here. */
if (callee != NULL_TREE
- && DECL_BUILT_IN_CLASS (callee) == BUILT_IN_NORMAL)
+ && gimple_call_builtin_p (call, BUILT_IN_NORMAL))
switch (DECL_FUNCTION_CODE (callee))
{
/* All the following functions read memory pointed to by
@@ -1941,7 +1941,7 @@ call_may_clobber_ref_p_1 (gcall *call, ao_ref *ref)
escape points. See tree-ssa-structalias.c:find_func_aliases
for the list of builtins we might need to handle here. */
if (callee != NULL_TREE
- && DECL_BUILT_IN_CLASS (callee) == BUILT_IN_NORMAL)
+ && gimple_call_builtin_p (call, BUILT_IN_NORMAL))
switch (DECL_FUNCTION_CODE (callee))
{
/* All the following functions clobber memory pointed to by
@@ -2341,7 +2341,7 @@ stmt_kills_ref_p (gimple stmt, ao_ref *ref)
{
tree callee = gimple_call_fndecl (stmt);
if (callee != NULL_TREE
- && DECL_BUILT_IN_CLASS (callee) == BUILT_IN_NORMAL)
+ && gimple_call_builtin_p (stmt, BUILT_IN_NORMAL))
switch (DECL_FUNCTION_CODE (callee))
{
case BUILT_IN_FREE:
Marek
next prev parent reply other threads:[~2015-08-18 11:10 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-17 18:38 Marek Polacek
2015-08-18 8:50 ` Richard Biener
2015-08-18 10:43 ` Marek Polacek
2015-08-18 11:08 ` Richard Biener
2015-08-18 12:03 ` Marek Polacek [this message]
2015-08-18 13:13 ` 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=20150818111041.GK2093@redhat.com \
--to=polacek@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
--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).