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 ICE in gen_lsm_tmp_name (PR tree-optimization/70169)


Hi!

As the testcase shows, we can get a FUNCTION_DECL or LABEL_DECL (on
questionable code).  The patch also removes the default gcc_unreachable (),
as this is just a debugging aid function, nothing bad happens if we ignore
some other tree code.

Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

2016-03-11  Jakub Jelinek  <jakub@redhat.com>

	PR tree-optimization/70169
	* tree-ssa-loop.c (gen_lsm_tmp_name): Handle FUNCTION_DECL and
	LABEL_DECL like VAR_DECL.  Emit nothing instead of gcc_unreachable
	for unknown codes.

	* gcc.dg/pr70169.c: New test.

--- gcc/tree-ssa-loop.c.jj	2016-02-23 20:43:49.000000000 +0100
+++ gcc/tree-ssa-loop.c	2016-03-11 10:00:18.792578125 +0100
@@ -769,6 +769,8 @@ gen_lsm_tmp_name (tree ref)
     case SSA_NAME:
     case VAR_DECL:
     case PARM_DECL:
+    case FUNCTION_DECL:
+    case LABEL_DECL:
       name = get_name (ref);
       if (!name)
 	name = "D";
@@ -784,11 +786,9 @@ gen_lsm_tmp_name (tree ref)
       break;
 
     case INTEGER_CST:
+    default:
       /* Nothing.  */
       break;
-
-    default:
-      gcc_unreachable ();
     }
 }
 
--- gcc/testsuite/gcc.dg/pr70169.c.jj	2016-03-11 09:51:59.139304653 +0100
+++ gcc/testsuite/gcc.dg/pr70169.c	2016-03-11 10:02:12.956050092 +0100
@@ -0,0 +1,40 @@
+/* PR tree-optimization/70169 */
+/* { dg-do compile } */
+/* { dg-options "-O2 -fno-strict-aliasing -fno-tree-dce" } */
+
+int printf (const char *, ...); 
+
+void
+foo ()
+{
+  unsigned char *p = (unsigned char *) &printf;
+  for (;;)
+    (*p)++;
+}
+
+void
+bar (int x)
+{
+  unsigned char *p = (unsigned char *) &printf;
+  int i;
+  for (i = 0; i < x; i++)
+    (*p)++;
+}
+
+void
+baz (int x, int y)
+{
+  unsigned char *p = (unsigned char *) &&lab;
+  int i;
+  if (y)
+    {
+      for (i = 0; i < x; i++)
+	(*p)++;
+    }
+  else
+    {
+     lab:
+      asm volatile ("");
+      foo ();
+    }
+}

	Jakub


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