]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
tree-optimization/106422 - verify block copying in forward threading
authorRichard Biener <rguenther@suse.de>
Fri, 29 Jul 2022 06:24:52 +0000 (08:24 +0200)
committerRichard Biener <rguenther@suse.de>
Fri, 29 Jul 2022 08:47:47 +0000 (10:47 +0200)
The forward threader failed to check whether it can actually duplicate
blocks.  The following adds this in a similar place the backwards threader
performs this check.

PR tree-optimization/106422
* tree-ssa-threadupdate.cc (fwd_jt_path_registry::update_cfg):
Check whether we can copy thread blocks and cancel the thread if not.

* gcc.dg/torture/pr106422.c: New testcase.

gcc/testsuite/gcc.dg/torture/pr106422.c [new file with mode: 0644]
gcc/tree-ssa-threadupdate.cc

diff --git a/gcc/testsuite/gcc.dg/torture/pr106422.c b/gcc/testsuite/gcc.dg/torture/pr106422.c
new file mode 100644 (file)
index 0000000..a2cef1a
--- /dev/null
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+
+void vfork() __attribute__((__leaf__));
+void semanage_reload_policy(char *arg, void cb(void))
+{
+  if (!arg)
+    {
+      cb();
+      return;
+    }
+  vfork();
+  if (arg)
+    __builtin_free(arg);
+}
index f901c7759e3d0e6b24563bb25f5d008f17ce7463..0f2b319d44ae33750851413d449e5eb1f590eaba 100644 (file)
@@ -2678,7 +2678,9 @@ fwd_jt_path_registry::update_cfg (bool may_peel_loop_headers)
        for (j = 0; j < path->length (); j++)
          {
            edge e = (*path)[j]->e;
-           if (m_removed_edges->find_slot (e, NO_INSERT))
+           if (m_removed_edges->find_slot (e, NO_INSERT)
+               || ((*path)[j]->type == EDGE_COPY_SRC_BLOCK
+                   && !can_duplicate_block_p (e->src)))
              break;
          }