tree-optimization/115701 - fix maybe_duplicate_ssa_info_at_copy
The following restricts copying of points-to info from defs that might be in regions invoking UB and are never executed. PR tree-optimization/115701 * tree-ssanames.cc (maybe_duplicate_ssa_info_at_copy): Only copy info from within the same BB. * gcc.dg/torture/pr115701.c: New testcase. (cherry picked from commit b77f17c5feec9614568bf2dee7f7d811465ee4a5)
This commit is contained in:
parent
6f74a5f5dc
commit
e01012c459
2 changed files with 30 additions and 14 deletions
22
gcc/testsuite/gcc.dg/torture/pr115701.c
Normal file
22
gcc/testsuite/gcc.dg/torture/pr115701.c
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
/* { dg-do run } */
|
||||||
|
/* IPA PTA disables local PTA recompute after IPA. */
|
||||||
|
/* { dg-additional-options "-fipa-pta" } */
|
||||||
|
|
||||||
|
int a, c, d;
|
||||||
|
static int b;
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
int *e = &a, **f = &e;
|
||||||
|
while (1) {
|
||||||
|
int **g, ***h = &f;
|
||||||
|
if (c)
|
||||||
|
*g = e;
|
||||||
|
else if (!b)
|
||||||
|
break;
|
||||||
|
*e = **g;
|
||||||
|
e = &d;
|
||||||
|
}
|
||||||
|
if (e != &a)
|
||||||
|
__builtin_abort();
|
||||||
|
return 0;
|
||||||
|
}
|
|
@ -763,25 +763,19 @@ duplicate_ssa_name_range_info (tree name, tree src)
|
||||||
void
|
void
|
||||||
maybe_duplicate_ssa_info_at_copy (tree dest, tree src)
|
maybe_duplicate_ssa_info_at_copy (tree dest, tree src)
|
||||||
{
|
{
|
||||||
|
/* While points-to info is flow-insensitive we have to avoid copying
|
||||||
|
info from not executed regions invoking UB to dominating defs. */
|
||||||
|
if (gimple_bb (SSA_NAME_DEF_STMT (src))
|
||||||
|
!= gimple_bb (SSA_NAME_DEF_STMT (dest)))
|
||||||
|
return;
|
||||||
|
|
||||||
if (POINTER_TYPE_P (TREE_TYPE (dest))
|
if (POINTER_TYPE_P (TREE_TYPE (dest))
|
||||||
&& SSA_NAME_PTR_INFO (dest)
|
&& SSA_NAME_PTR_INFO (dest)
|
||||||
&& ! SSA_NAME_PTR_INFO (src))
|
&& ! SSA_NAME_PTR_INFO (src))
|
||||||
{
|
duplicate_ssa_name_ptr_info (src, SSA_NAME_PTR_INFO (dest));
|
||||||
duplicate_ssa_name_ptr_info (src, SSA_NAME_PTR_INFO (dest));
|
|
||||||
/* Points-to information is cfg insensitive,
|
|
||||||
but VRP might record context sensitive alignment
|
|
||||||
info, non-nullness, etc. So reset context sensitive
|
|
||||||
info if the two SSA_NAMEs aren't defined in the same
|
|
||||||
basic block. */
|
|
||||||
if (gimple_bb (SSA_NAME_DEF_STMT (src))
|
|
||||||
!= gimple_bb (SSA_NAME_DEF_STMT (dest)))
|
|
||||||
reset_flow_sensitive_info (src);
|
|
||||||
}
|
|
||||||
else if (INTEGRAL_TYPE_P (TREE_TYPE (dest))
|
else if (INTEGRAL_TYPE_P (TREE_TYPE (dest))
|
||||||
&& SSA_NAME_RANGE_INFO (dest)
|
&& SSA_NAME_RANGE_INFO (dest)
|
||||||
&& ! SSA_NAME_RANGE_INFO (src)
|
&& ! SSA_NAME_RANGE_INFO (src))
|
||||||
&& (gimple_bb (SSA_NAME_DEF_STMT (src))
|
|
||||||
== gimple_bb (SSA_NAME_DEF_STMT (dest))))
|
|
||||||
duplicate_ssa_name_range_info (src, dest);
|
duplicate_ssa_name_range_info (src, dest);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue