public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Fix ICE with gimple clobber (PR tree-optimization/71405)
@ 2016-06-04 13:36 Jakub Jelinek
  2016-06-04 14:44 ` Richard Biener
  0 siblings, 1 reply; 2+ messages in thread
From: Jakub Jelinek @ 2016-06-04 13:36 UTC (permalink / raw)
  To: Richard Biener; +Cc: gcc-patches

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] Fix ICE with gimple clobber (PR tree-optimization/71405)
  2016-06-04 13:36 [PATCH] Fix ICE with gimple clobber (PR tree-optimization/71405) Jakub Jelinek
@ 2016-06-04 14:44 ` Richard Biener
  0 siblings, 0 replies; 2+ messages in thread
From: Richard Biener @ 2016-06-04 14:44 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: gcc-patches

On June 4, 2016 3:36:13 PM GMT+02:00, Jakub Jelinek <jakub@redhat.com> wrote:
>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?

OK.

Thanks,
Richard.

>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


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-06-04 14:44 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-04 13:36 [PATCH] Fix ICE with gimple clobber (PR tree-optimization/71405) Jakub Jelinek
2016-06-04 14:44 ` 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).