diff options
author | Richard Biener <rguenther@suse.de> | 2016-10-20 14:14:47 +0000 |
---|---|---|
committer | Richard Biener <rguenth@gcc.gnu.org> | 2016-10-20 14:14:47 +0000 |
commit | 40b8428e2e586d89cce4fbafb8ef333a062a53f8 (patch) | |
tree | 76741cf91c5b716dba2283f07c3d8dcba3801b64 /gcc/tree-ssa-alias.c | |
parent | eff89e01b880e6f058ae136935d70c743bc852b6 (diff) | |
download | gcc-40b8428e2e586d89cce4fbafb8ef333a062a53f8.zip gcc-40b8428e2e586d89cce4fbafb8ef333a062a53f8.tar.gz gcc-40b8428e2e586d89cce4fbafb8ef333a062a53f8.tar.bz2 |
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
Diffstat (limited to 'gcc/tree-ssa-alias.c')
-rw-r--r-- | gcc/tree-ssa-alias.c | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/gcc/tree-ssa-alias.c b/gcc/tree-ssa-alias.c index 01bef17..26c9f9e 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. */ |