* [PATCH] Fix ICE during strstr gimple folding (PR middle-end/81207)
@ 2017-06-27 5:47 Jakub Jelinek
2017-06-27 7:11 ` Richard Biener
0 siblings, 1 reply; 2+ messages in thread
From: Jakub Jelinek @ 2017-06-27 5:47 UTC (permalink / raw)
To: Richard Biener; +Cc: gcc-patches
Hi!
replace_call_with_call_and_fold has code to copy over vdef/vuse from the
old call to the new one, so that we don't have to update virtual ssa,
but it is conditioned on gimple_vdef being non-NULL and SSA_NAME.
If we have a pure function, gimple_vdef is NULL, yet we still want to copy
over the vuse.
Bootstrapped/regtested on x86_64-linux (i686-linux fails to bootstrap
with/without this patch), ok for trunk?
2017-06-27 Jakub Jelinek <jakub@redhat.com>
PR middle-end/81207
* gimple-fold.c (replace_call_with_call_and_fold): Handle
gimple_vuse copying separately from gimple_vdef copying.
* gcc.c-torture/compile/pr81207.c: New test.
--- gcc/gimple-fold.c.jj 2017-06-19 08:28:11.000000000 +0200
+++ gcc/gimple-fold.c 2017-06-26 17:09:34.735420583 +0200
@@ -607,9 +607,11 @@ replace_call_with_call_and_fold (gimple_
&& TREE_CODE (gimple_vdef (stmt)) == SSA_NAME)
{
gimple_set_vdef (repl, gimple_vdef (stmt));
- gimple_set_vuse (repl, gimple_vuse (stmt));
SSA_NAME_DEF_STMT (gimple_vdef (repl)) = repl;
}
+ if (gimple_vuse (stmt)
+ && TREE_CODE (gimple_vuse (stmt)) == SSA_NAME)
+ gimple_set_vuse (repl, gimple_vuse (stmt));
gsi_replace (gsi, repl, false);
fold_stmt (gsi);
}
--- gcc/testsuite/gcc.c-torture/compile/pr81207.c.jj 2017-06-26 17:21:38.765918367 +0200
+++ gcc/testsuite/gcc.c-torture/compile/pr81207.c 2017-06-26 17:27:15.222966965 +0200
@@ -0,0 +1,13 @@
+/* PR middle-end/81207 */
+
+static const char *b[2] = { "'", "" };
+
+int
+foo (const char *d)
+{
+ int e;
+ for (e = 0; b[e]; e++)
+ if (__builtin_strstr (d, b[e]))
+ return 1;
+ return 0;
+}
Jakub
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] Fix ICE during strstr gimple folding (PR middle-end/81207)
2017-06-27 5:47 [PATCH] Fix ICE during strstr gimple folding (PR middle-end/81207) Jakub Jelinek
@ 2017-06-27 7:11 ` Richard Biener
0 siblings, 0 replies; 2+ messages in thread
From: Richard Biener @ 2017-06-27 7:11 UTC (permalink / raw)
To: Jakub Jelinek; +Cc: gcc-patches
On Tue, 27 Jun 2017, Jakub Jelinek wrote:
> Hi!
>
> replace_call_with_call_and_fold has code to copy over vdef/vuse from the
> old call to the new one, so that we don't have to update virtual ssa,
> but it is conditioned on gimple_vdef being non-NULL and SSA_NAME.
> If we have a pure function, gimple_vdef is NULL, yet we still want to copy
> over the vuse.
>
> Bootstrapped/regtested on x86_64-linux (i686-linux fails to bootstrap
> with/without this patch), ok for trunk?
Ok with ...
> 2017-06-27 Jakub Jelinek <jakub@redhat.com>
>
> PR middle-end/81207
> * gimple-fold.c (replace_call_with_call_and_fold): Handle
> gimple_vuse copying separately from gimple_vdef copying.
>
> * gcc.c-torture/compile/pr81207.c: New test.
>
> --- gcc/gimple-fold.c.jj 2017-06-19 08:28:11.000000000 +0200
> +++ gcc/gimple-fold.c 2017-06-26 17:09:34.735420583 +0200
> @@ -607,9 +607,11 @@ replace_call_with_call_and_fold (gimple_
> && TREE_CODE (gimple_vdef (stmt)) == SSA_NAME)
> {
> gimple_set_vdef (repl, gimple_vdef (stmt));
> - gimple_set_vuse (repl, gimple_vuse (stmt));
> SSA_NAME_DEF_STMT (gimple_vdef (repl)) = repl;
> }
> + if (gimple_vuse (stmt)
> + && TREE_CODE (gimple_vuse (stmt)) == SSA_NAME)
... the SSA_NAME check removed. It's done above because we access
SSA_NAME_DEF_STMT, here it isn't necessary.
> + gimple_set_vuse (repl, gimple_vuse (stmt));
> gsi_replace (gsi, repl, false);
> fold_stmt (gsi);
> }
> --- gcc/testsuite/gcc.c-torture/compile/pr81207.c.jj 2017-06-26 17:21:38.765918367 +0200
> +++ gcc/testsuite/gcc.c-torture/compile/pr81207.c 2017-06-26 17:27:15.222966965 +0200
> @@ -0,0 +1,13 @@
> +/* PR middle-end/81207 */
> +
> +static const char *b[2] = { "'", "" };
> +
> +int
> +foo (const char *d)
> +{
> + int e;
> + for (e = 0; b[e]; e++)
> + if (__builtin_strstr (d, b[e]))
> + return 1;
> + return 0;
> +}
>
> Jakub
>
>
--
Richard Biener <rguenther@suse.de>
SUSE LINUX GmbH, GF: Felix Imendoerffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nuernberg)
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-06-27 7:11 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-27 5:47 [PATCH] Fix ICE during strstr gimple folding (PR middle-end/81207) Jakub Jelinek
2017-06-27 7:11 ` Richard Biener
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).