]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Free dominance info at the beginning of pass_jump_after_combine
authorIlya Leoshkevich <iii@linux.ibm.com>
Fri, 15 Nov 2019 12:55:05 +0000 (12:55 +0000)
committerIlya Leoshkevich <iii@gcc.gnu.org>
Fri, 15 Nov 2019 12:55:05 +0000 (12:55 +0000)
try_forward_edges does not update dominance info, and merge_blocks
relies on it being up-to-date.  In PR92430 stale dominance info makes
merge_blocks produce a loop in the dominator tree, which in turn makes
delete_basic_block loop forever.

Fix by freeing dominance info at the beginning of cleanup_cfg.

Also, since the whole point of this pass is to perform jump threading
(other cleanups are not valuable at this point), skip it completely when
flag_thread_jumps is not set.

gcc/ChangeLog:

2019-11-15  Ilya Leoshkevich  <iii@linux.ibm.com>

Backport from mainline
PR rtl-optimization/92430
* cfgcleanup.c (pass_jump_after_combine::gate): New function.
(pass_jump_after_combine::execute): Free
dominance info at the beginning.

gcc/testsuite/ChangeLog:

2019-11-15  Ilya Leoshkevich  <iii@linux.ibm.com>

Backport from mainline
PR rtl-optimization/92430
* gcc.dg/pr92430.c: New test (from Arseny Solokha).

From-SVN: r278291

gcc/ChangeLog
gcc/cfgcleanup.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/pr92430.c [new file with mode: 0644]

index 63209837908c9f05ac3533c14f97d8f12c8ce992..f2694e5dc2d051e5096af13075765ea79dbc70af 100644 (file)
@@ -1,3 +1,11 @@
+2019-11-15  Ilya Leoshkevich  <iii@linux.ibm.com>
+
+       Backport from mainline
+       PR rtl-optimization/92430
+       * cfgcleanup.c (pass_jump_after_combine::gate): New function.
+       (pass_jump_after_combine::execute): Free
+       dominance info at the beginning.
+
 2019-11-13  Claudiu Zissulescu <claziss@gmail.com>
 
        Backport from mainline
index e90cc43e1f0bdb90fef1e122b1f86517a1f05abf..01e13b9dc4f43849913f5582697ec5ea241abbc8 100644 (file)
@@ -3303,6 +3303,7 @@ public:
   {}
 
   /* opt_pass methods: */
+  virtual bool gate (function *) { return flag_thread_jumps; }
   virtual unsigned int execute (function *);
 
 }; // class pass_jump_after_combine
@@ -3310,7 +3311,9 @@ public:
 unsigned int
 pass_jump_after_combine::execute (function *)
 {
-  cleanup_cfg (flag_thread_jumps ? CLEANUP_THREADING : 0);
+  /* Jump threading does not keep dominators up-to-date.  */
+  free_dominance_info (CDI_DOMINATORS);
+  cleanup_cfg (CLEANUP_THREADING);
   return 0;
 }
 
index 1ae0ef123a03d301249d4a462157f60a66914ff1..e4f275430ecc90ebcdd782425843032aee848144 100644 (file)
@@ -1,3 +1,9 @@
+2019-11-15  Ilya Leoshkevich  <iii@linux.ibm.com>
+
+       Backport from mainline
+       PR rtl-optimization/92430
+       * gcc.dg/pr92430.c: New test (from Arseny Solokha).
+
 2019-11-13  Claudiu Zissulescu <claziss@gmail.com>
 
        Backport from mainline
diff --git a/gcc/testsuite/gcc.dg/pr92430.c b/gcc/testsuite/gcc.dg/pr92430.c
new file mode 100644 (file)
index 0000000..9156068
--- /dev/null
@@ -0,0 +1,25 @@
+// PR rtl-optimization/92430
+// { dg-do compile }
+// { dg-options "-Os -fno-if-conversion -fno-tree-dce -fno-tree-loop-optimize -fno-tree-vrp" }
+
+int eb, ko;
+
+void
+e9 (int pe, int lx)
+{
+  int ir;
+
+  for (ir = 0; ir < 1; ++ir)
+    {
+      for (ko = 0; ko < 1; ++ko)
+        {
+          for (eb = 0; eb < 1; ++eb)
+            ko += pe;
+
+          for (ko = 0; ko < 1; ++ko)
+            ;
+        }
+
+      pe = ir = lx;
+    }
+}