aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>2016-10-20 14:14:47 +0000
committerrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>2016-10-20 14:14:47 +0000
commitc3f852350fadf23ea459d4ce8df0212392af582a (patch)
tree76741cf91c5b716dba2283f07c3d8dcba3801b64
parent3645e92434f113b9bc9ef66fd69ead1facac324b (diff)
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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@241378 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog9
-rw-r--r--gcc/tree-ssa-alias.c22
-rw-r--r--gcc/tree-ssa-structalias.c16
3 files changed, 40 insertions, 7 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 4265d087107..2c770c240ec 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -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.
diff --git a/gcc/tree-ssa-alias.c b/gcc/tree-ssa-alias.c
index 01bef17cbfb..26c9f9e894b 100644
--- a/gcc/tree-ssa-alias.c
+++ b/gcc/tree-ssa-alias.c
@@ -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. */
diff --git a/gcc/tree-ssa-structalias.c b/gcc/tree-ssa-structalias.c
index 78f45334785..fb364f1319d 100644
--- a/gcc/tree-ssa-structalias.c
+++ b/gcc/tree-ssa-structalias.c
@@ -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 ();