tree-ssa-alias.c (ptrs_compare_unequal): Remove code duplication.

2016-10-20  Richard Biener  <rguenther@suse.de>

	* tree-ssa-alias.c (ptrs_compare_unequal): Remove code duplication.
	Handle decls possibly not bound.
	* tree-ssa-structalias.c (get_constraint_for_ssa_var): Add
	nothing_id for decls that might not be bound if we are interested
	for the address.
	(get_constraint_for_component_ref): Deal with that.

From-SVN: r241378
This commit is contained in:
Richard Biener 2016-10-20 14:14:47 +00:00 committed by Richard Biener
parent eff89e01b8
commit 40b8428e2e
3 changed files with 40 additions and 7 deletions

View File

@ -1,3 +1,12 @@
2016-10-20 Richard Biener <rguenther@suse.de>
* tree-ssa-alias.c (ptrs_compare_unequal): Remove code duplication.
Handle decls possibly not bound.
* tree-ssa-structalias.c (get_constraint_for_ssa_var): Add
nothing_id for decls that might not be bound if we are interested
for the address.
(get_constraint_for_component_ref): Deal with that.
2016-10-20 Michael Matz <matz@suse.de>
Loop splitting.

View File

@ -358,6 +358,13 @@ ptrs_compare_unequal (tree ptr1, tree ptr2)
ptr2 = TREE_OPERAND (tem, 0);
}
/* Canonicalize ptr vs. object. */
if (TREE_CODE (ptr1) == SSA_NAME && obj2)
{
std::swap (ptr1, ptr2);
std::swap (obj1, obj2);
}
if (obj1 && obj2)
/* Other code handles this correctly, no need to duplicate it here. */;
else if (obj1 && TREE_CODE (ptr2) == SSA_NAME)
@ -368,15 +375,16 @@ ptrs_compare_unequal (tree ptr1, tree ptr2)
may be in fact obj1. */
if (!pi || pi->pt.vars_contains_restrict)
return false;
if (VAR_P (obj1)
&& (TREE_STATIC (obj1) || DECL_EXTERNAL (obj1)))
{
varpool_node *node = varpool_node::get (obj1);
/* If obj1 may bind to NULL give up (see below). */
if (! node || ! node->nonzero_address ())
return false;
}
return !pt_solution_includes (&pi->pt, obj1);
}
else if (TREE_CODE (ptr1) == SSA_NAME && obj2)
{
struct ptr_info_def *pi = SSA_NAME_PTR_INFO (ptr1);
if (!pi || pi->pt.vars_contains_restrict)
return false;
return !pt_solution_includes (&pi->pt, obj2);
}
/* ??? We'd like to handle ptr1 != NULL and ptr1 != ptr2
but those require pt.null to be conservatively correct. */

View File

@ -2944,6 +2944,16 @@ get_constraint_for_ssa_var (tree t, vec<ce_s> *results, bool address_p)
DECL_PT_UID (t) = DECL_UID (node->decl);
t = node->decl;
}
/* If this is decl may bind to NULL note that. */
if (address_p
&& (! node || ! node->nonzero_address ()))
{
cexpr.var = nothing_id;
cexpr.type = SCALAR;
cexpr.offset = 0;
results->safe_push (cexpr);
}
}
vi = get_vi_for_tree (t);
@ -3213,6 +3223,12 @@ get_constraint_for_component_ref (tree t, vec<ce_s> *results,
/* Pretend to take the address of the base, we'll take care of
adding the required subset of sub-fields below. */
get_constraint_for_1 (t, results, true, lhs_p);
/* Strip off nothing_id. */
if (results->length () == 2)
{
gcc_assert ((*results)[0].var == nothing_id);
results->unordered_remove (0);
}
gcc_assert (results->length () == 1);
struct constraint_expr &result = results->last ();