re PR rtl-optimization/87475 (ICE in patch_jump_insn, at cfgrtl.c:1275)
authorJakub Jelinek <jakub@redhat.com>
Fri, 16 Nov 2018 16:43:49 +0000 (17:43 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Fri, 16 Nov 2018 16:43:49 +0000 (17:43 +0100)
PR rtl-optimization/87475
* cfgrtl.c (patch_jump_insn): Allow redirection failure for
CROSSING_JUMP_P insns.
(cfg_layout_redirect_edge_and_branch): Don't ICE if ret is NULL.

* g++.dg/opt/pr87475.C: New test.

From-SVN: r266219

gcc/ChangeLog
gcc/cfgrtl.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/opt/pr87475.C [new file with mode: 0644]

index 2362e708a8dd6a08c9a86b7b5b9ada37c2b11535..984826d6c47f865bc29a4a65d2ad5ef904cc8719 100644 (file)
@@ -1,3 +1,10 @@
+2018-11-16  Jakub Jelinek  <jakub@redhat.com>
+
+       PR rtl-optimization/87475
+       * cfgrtl.c (patch_jump_insn): Allow redirection failure for
+       CROSSING_JUMP_P insns.
+       (cfg_layout_redirect_edge_and_branch): Don't ICE if ret is NULL.
+
 2018-11-16  Uros Bizjak  <ubizjak@gmail.com>
 
        PR target/88051
index 3d4a114cbbb9d5a674f01a3f526490d089e7b381..411a0245f5456616e4e78b60ea74a980a30b90b6 100644 (file)
@@ -1268,11 +1268,13 @@ patch_jump_insn (rtx_insn *insn, rtx_insn *old_label, basic_block new_bb)
 
          /* If the substitution doesn't succeed, die.  This can happen
             if the back end emitted unrecognizable instructions or if
-            target is exit block on some arches.  */
+            target is exit block on some arches.  Or for crossing
+            jumps.  */
          if (!redirect_jump (as_a <rtx_jump_insn *> (insn),
                              block_label (new_bb), 0))
            {
-             gcc_assert (new_bb == EXIT_BLOCK_PTR_FOR_FN (cfun));
+             gcc_assert (new_bb == EXIT_BLOCK_PTR_FOR_FN (cfun)
+                         || CROSSING_JUMP_P (insn));
              return false;
            }
        }
@@ -4460,6 +4462,9 @@ cfg_layout_redirect_edge_and_branch (edge e, basic_block dest)
   else
     ret = redirect_branch_edge (e, dest);
 
+  if (!ret)
+    return NULL;
+
   fixup_partition_crossing (ret);
   /* We don't want simplejumps in the insn stream during cfglayout.  */
   gcc_assert (!simplejump_p (BB_END (src)) || CROSSING_JUMP_P (BB_END (src)));
index a00506d533dd063a68e749f619248651a77c68c7..e3856f48282e791f2cff67ea86b91964721b99a7 100644 (file)
@@ -1,3 +1,8 @@
+2018-11-16  Jakub Jelinek  <jakub@redhat.com>
+
+       PR rtl-optimization/87475
+       * g++.dg/opt/pr87475.C: New test.
+
 2018-11-16  Matthew Malcomson  <matthew.malcomson@arm.com>
 
        * gcc.c-torture/execute/printf-2.c: Skip on wrapped boards.
diff --git a/gcc/testsuite/g++.dg/opt/pr87475.C b/gcc/testsuite/g++.dg/opt/pr87475.C
new file mode 100644 (file)
index 0000000..5ed25b4
--- /dev/null
@@ -0,0 +1,7 @@
+// PR rtl-optimization/87475
+// { dg-do compile { target freorder } }
+// { dg-options "-O2 -freorder-blocks-and-partition -fmodulo-sched" }
+
+struct A { A (); ~A (); };
+int foo (A, A);
+void bar (bool x) { x ? foo (A (), A ()) : 0; }