aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2022-07-29 08:24:52 +0200
committerRichard Biener <rguenther@suse.de>2022-07-29 10:47:47 +0200
commit4894ba078692a780a461d2f358b5dfaa25719859 (patch)
tree1df9d0769b37ad08851cc08c4e6a842c134da483 /gcc
parent2dcceedb3c121f2498ae58d8414e7b8454b7bf55 (diff)
downloadgcc-4894ba078692a780a461d2f358b5dfaa25719859.zip
gcc-4894ba078692a780a461d2f358b5dfaa25719859.tar.gz
gcc-4894ba078692a780a461d2f358b5dfaa25719859.tar.bz2
tree-optimization/106422 - verify block copying in forward threading
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.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr106422.c14
-rw-r--r--gcc/tree-ssa-threadupdate.cc4
2 files changed, 17 insertions, 1 deletions
diff --git a/gcc/testsuite/gcc.dg/torture/pr106422.c b/gcc/testsuite/gcc.dg/torture/pr106422.c
new file mode 100644
index 0000000..a2cef1a
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr106422.c
@@ -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);
+}
diff --git a/gcc/tree-ssa-threadupdate.cc b/gcc/tree-ssa-threadupdate.cc
index f901c77..0f2b319 100644
--- a/gcc/tree-ssa-threadupdate.cc
+++ b/gcc/tree-ssa-threadupdate.cc
@@ -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;
}