From: Jakub Jelinek <jakub@redhat.com>
To: Richard Biener <rguenther@suse.de>
Cc: gcc-patches@gcc.gnu.org
Subject: [PATCH] Fix ICE with gimple clobber (PR tree-optimization/71405)
Date: Sat, 04 Jun 2016 13:36:00 -0000 [thread overview]
Message-ID: <20160604133613.GS7387@tucnak.redhat.com> (raw)
Hi!
On this testcase execute_update_addresses_taken creates
VIEW_CONVERT_EXPR of a {CLOBBER}, which is of course invalid.
Instead, this patch just creates {CLOBBER} of the right type and let's
the following ssa update transform that to replacing uses with default def
or whatever else is appropriate.
Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
2016-06-04 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/71405
* tree-ssa.c (execute_update_addresses_taken): For clobber with
incompatible type, build a new clobber with the right type instead
of building a VIEW_CONVERT_EXPR around it.
* g++.dg/torture/pr71405.C: New test.
--- gcc/tree-ssa.c.jj 2016-05-24 10:56:01.000000000 +0200
+++ gcc/tree-ssa.c 2016-06-04 11:59:36.561302230 +0200
@@ -1622,9 +1622,16 @@ execute_update_addresses_taken (void)
if (gimple_assign_lhs (stmt) != lhs
&& !useless_type_conversion_p (TREE_TYPE (lhs),
TREE_TYPE (rhs)))
- rhs = fold_build1 (VIEW_CONVERT_EXPR,
- TREE_TYPE (lhs), rhs);
-
+ {
+ if (gimple_clobber_p (stmt))
+ {
+ rhs = build_constructor (TREE_TYPE (lhs), NULL);
+ TREE_THIS_VOLATILE (rhs) = 1;
+ }
+ else
+ rhs = fold_build1 (VIEW_CONVERT_EXPR,
+ TREE_TYPE (lhs), rhs);
+ }
if (gimple_assign_lhs (stmt) != lhs)
gimple_assign_set_lhs (stmt, lhs);
--- gcc/testsuite/g++.dg/torture/pr71405.C.jj 2016-06-04 12:10:33.694768153 +0200
+++ gcc/testsuite/g++.dg/torture/pr71405.C 2016-06-04 12:09:28.000000000 +0200
@@ -0,0 +1,22 @@
+// PR tree-optimization/71405
+// { dg-do compile }
+
+struct C
+{
+ C () {}
+ int i;
+};
+
+void *
+operator new (__SIZE_TYPE__ x, void *y)
+{
+ return y;
+}
+
+int
+main ()
+{
+ int a;
+ new (&a) C;
+ return a;
+}
Jakub
next reply other threads:[~2016-06-04 13:36 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-04 13:36 Jakub Jelinek [this message]
2016-06-04 14:44 ` 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=20160604133613.GS7387@tucnak.redhat.com \
--to=jakub@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=rguenther@suse.de \
/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).