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.
This commit is contained in:
Richard Biener 2022-07-29 08:24:52 +02:00
parent 2dcceedb3c
commit 4894ba0786
2 changed files with 17 additions and 1 deletions

View file

@ -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);
}

View 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;
}