diff mbox

Fix ICE with gimple clobber (PR tree-optimization/71405)

Message ID 20160604133613.GS7387@tucnak.redhat.com
State New
Headers show

Commit Message

Jakub Jelinek June 4, 2016, 1:36 p.m. UTC
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.


	Jakub

Comments

Richard Biener June 4, 2016, 2:43 p.m. UTC | #1
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
diff mbox

Patch

--- 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; 
+}