This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Fix tree-opt/29059, ICE with the recent builtins improvements


The problem here is that the recent builtins improvements cause us to
try to call set_rhs with an expression of a MODIFY_EXPR.  Right now we
don't check to make sure that the arguments are non gimple which can be
the case most of the time.  This patch is the simpliest patch to fix the
problem by just rejecting MODIFY_EXPR in set_rhs so we don't have to
check the operands to be gimple.  In a future version of set_rhs, we
could just go and regimplify the expression before setting the right
hand side but that is for 4.3 because it changes how set_rhs works
currently.

OK? Bootstrapped and tested on i686-linux-gnu with no regressions.

:ADDPATCH tree-ssa(tree-ssa-propagate):

I added 4 testcases, each for a slightly different case where we call
set_rhs, at least one is called from inside DOM and one from inside CCP.

Thanks,
Andrew Pinski

ChangeLog:
	* tree-ssa-propagate.c (set_rhs): Reject MODIFY_EXPR right
	away for the expr argument.

testsuite/ChangeLog:

	* gcc.c-torture/compile/strcpy-1.c: New test.
	* gcc.c-torture/compile/strcpy-2.c: New test.
	* gcc.c-torture/compile/memcpy-1.c: New test.
	* gcc.c-torture/compile/memcpy-2.c: New test.
Index: testsuite/gcc.c-torture/compile/strcpy-1.c
===================================================================
--- testsuite/gcc.c-torture/compile/strcpy-1.c	(revision 0)
+++ testsuite/gcc.c-torture/compile/strcpy-1.c	(revision 0)
@@ -0,0 +1,15 @@
+
+
+typedef struct
+{
+  char str[20];
+}STACK;
+STACK stack[15];
+int level;
+rezero ()
+{
+  level = 0;
+  __builtin_strcpy (stack[level].str, "");
+}
+
+
Index: testsuite/gcc.c-torture/compile/strcpy-2.c
===================================================================
--- testsuite/gcc.c-torture/compile/strcpy-2.c	(revision 0)
+++ testsuite/gcc.c-torture/compile/strcpy-2.c	(revision 0)
@@ -0,0 +1,7 @@
+char wrkstr_un[270];
+extern void
+LoadUserAlph (char *s)
+{
+  s = &wrkstr_un[0];
+  __builtin_strcpy (s, "");
+};
Index: testsuite/gcc.c-torture/compile/memcpy-1.c
===================================================================
--- testsuite/gcc.c-torture/compile/memcpy-1.c	(revision 0)
+++ testsuite/gcc.c-torture/compile/memcpy-1.c	(revision 0)
@@ -0,0 +1,9 @@
+static const char OggFLAC__MAPPING_VERSION_MAJOR = 1;
+void f(void)
+{
+  char synthetic_first_packet_body[10];
+  char *b = &synthetic_first_packet_body[4];
+  __builtin_memcpy (b, &OggFLAC__MAPPING_VERSION_MAJOR, (1u));
+}
+
+
Index: testsuite/gcc.c-torture/compile/memcpy-2.c
===================================================================
--- testsuite/gcc.c-torture/compile/memcpy-2.c	(revision 0)
+++ testsuite/gcc.c-torture/compile/memcpy-2.c	(revision 0)
@@ -0,0 +1,10 @@
+static const char OggFLAC__MAPPING_VERSION_MAJOR = 1;
+void f(void)
+{
+  char synthetic_first_packet_body[10];
+  char *b = synthetic_first_packet_body;
+  b+=4u;
+  __builtin_memcpy (b, &OggFLAC__MAPPING_VERSION_MAJOR, (1u));
+}
+
+
Index: tree-ssa-propagate.c
===================================================================
--- tree-ssa-propagate.c	(revision 116947)
+++ tree-ssa-propagate.c	(working copy)
@@ -588,7 +588,8 @@ set_rhs (tree *stmt_p, tree expr)
 	  && !is_gimple_val (TREE_OPERAND (TREE_OPERAND (expr, 0), 1)))
 	return false;
     }
-  else if (code == COMPOUND_EXPR)
+  else if (code == COMPOUND_EXPR
+	   || code == MODIFY_EXPR)
     return false;
 
   switch (TREE_CODE (stmt))

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]