[PATCH] Fix ICE from path isolation (PR tree-optimization/84960)

Jakub Jelinek jakub@redhat.com
Wed Mar 21 21:41:00 GMT 2018


Hi!

On the following testcase, path isolation decides to duplicate a bb and
redirect edge from ENTRY bb to its successor to this duplicate bb and
tree cleanup then removes all other basic blocks as unreachable.

When blocks are removed, forced labels are moved to their bb->prev_bb block,
but inserting any stmts into the ENTRY bb is of course invalid.

This patch makes sure we insert it into the ENTRY successor instead in that
case.  Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

2018-03-21  Jakub Jelinek  <jakub@redhat.com>

	PR tree-optimization/84960
	* tree-cfg.c (remove_bb): Don't move forced labels into bb->prev_bb
	if it is ENTRY block, move them into single succ of ENTRY in that case.

	* gcc.c-torture/compile/pr84960.c: New test.

--- gcc/tree-cfg.c.jj	2018-02-09 06:44:38.445804410 +0100
+++ gcc/tree-cfg.c	2018-03-21 12:43:57.835337795 +0100
@@ -2301,6 +2301,12 @@ remove_bb (basic_block bb)
 		}
 
 	      new_bb = bb->prev_bb;
+	      /* Don't move any labels into ENTRY block.  */
+	      if (new_bb == ENTRY_BLOCK_PTR_FOR_FN (cfun))
+		{
+		  new_bb = single_succ (new_bb);
+		  gcc_assert (new_bb != bb);
+		}
 	      new_gsi = gsi_start_bb (new_bb);
 	      gsi_remove (&i, false);
 	      gsi_insert_before (&new_gsi, stmt, GSI_NEW_STMT);
--- gcc/testsuite/gcc.c-torture/compile/pr84960.c.jj	2018-03-21 12:49:15.299278319 +0100
+++ gcc/testsuite/gcc.c-torture/compile/pr84960.c	2018-03-21 12:49:04.245280389 +0100
@@ -0,0 +1,17 @@
+/* PR tree-optimization/84960 */
+/* { dg-do compile { target indirect_jumps } } */
+
+void
+foo (unsigned int a, float b, void *c)
+{
+lab:
+  if ((b - (a %= 0) < 1U) * -1U)
+    ;
+  else
+    {
+      unsigned int f = a;
+      __builtin_unreachable ();
+      c = &&lab;
+    }
+  goto *c;
+}

	Jakub



More information about the Gcc-patches mailing list