Add recursion to make_param_constraints
2015-10-27 Tom de Vries <tom@codesourcery.com>
* tree-ssa-structalias.c (restrict_pointed_var): New static var.
(insert_restrict_pointed_var, lookup_restrict_pointed_var): New
function.
(make_param_constraints): Handle case that
lookup_restrict_pointed_var (vi) != NULL.
(intra_create_variable_infos): Call insert_restrict_pointed_var.
Simplify constraint handling. Delete restrict_pointed_var.
---
gcc/tree-ssa-structalias.c | 48 ++++++++++++++++++++++++++++++++++++++++++----
1 file changed, 44 insertions(+), 4 deletions(-)
@@ -5607,6 +5607,39 @@ check_for_overlaps (vec<fieldoff_s> fieldstack)
return false;
}
+/* Map from restrict pointer variable info to restrict var variable info. */
+
+static hash_map<varinfo_t, varinfo_t> *restrict_pointed_var = NULL;
+
+/* Insert VI2 as the restrict var for VI in the restrict_pointed_var map. */
+
+static void
+insert_restrict_pointed_var (varinfo_t vi, varinfo_t vi2)
+{
+ if (restrict_pointed_var == NULL)
+ restrict_pointed_var = new hash_map<varinfo_t, varinfo_t>;
+
+ bool mapped = restrict_pointed_var->put (vi, vi2);
+ gcc_assert (!mapped);
+}
+
+/* Find the restrict var for restrict pointer VI in the restrict_pointed_var
+ map. If VI does not exist in the map, return NULL, otherwise, return the
+ varinfo we found. */
+
+static varinfo_t
+lookup_restrict_pointed_var (varinfo_t vi)
+{
+ if (restrict_pointed_var == NULL)
+ return NULL;
+ varinfo_t *slot = restrict_pointed_var->get (vi);
+ if (slot == NULL)
+ return NULL;
+
+ return *slot;
+}
+
+
/* Create a varinfo structure for NAME and DECL, and add it to VARMAP.
This will also create any varinfo structures necessary for fields
of DECL. */
@@ -5856,7 +5889,13 @@ make_param_constraints (varinfo_t vi, bool toplevel)
{
if (vi->only_restrict_pointers)
{
- if (toplevel)
+ varinfo_t rvi = lookup_restrict_pointed_var (vi);
+ if (rvi != NULL)
+ {
+ make_constraint_from (vi, rvi->id);
+ make_param_constraints (rvi, false);
+ }
+ else if (toplevel)
make_constraint_from_global_restrict (vi, "PARM_RESTRICT");
else
make_constraint_from_global_restrict (vi, "GLOBAL_RESTRICT");
@@ -5910,14 +5949,15 @@ intra_create_variable_infos (struct function *fn)
vi = create_variable_info_for_1 (heapvar, "PARM_NOALIAS");
vi->is_restrict_var = 1;
insert_vi_for_tree (heapvar, vi);
- make_constraint_from (p, vi->id);
- make_param_constraints (vi, false);
- continue;
+ insert_restrict_pointed_var (p, vi);
}
make_param_constraints (p, true);
}
+ delete restrict_pointed_var;
+ restrict_pointed_var = NULL;
+
/* Add a constraint for a result decl that is passed by reference. */
if (DECL_RESULT (fn->decl)
&& DECL_BY_REFERENCE (DECL_RESULT (fn->decl)))
--
1.9.1