This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH, 3/6] Add recursion to make_param_constraints


On 27/10/15 13:24, Tom de Vries wrote:
Thinking it over a bit more, I realized the constraint handling started
to be messy. I've reworked the patch series to simplify that first.

      1    Simplify constraint handling
      2    Rename make_restrict_var_constraints to make_param_constraints
      3    Add recursion to make_param_constraints
      4    Add handle_param parameter to create_variable_info_for_1
      5    Handle recursive restrict pointer in create_variable_info_for_1
      6    Handle restrict struct fields recursively

Currently doing bootstrap and regtest on x86_64.

I'll repost the patch series in reply to this message.


This patch:
- registers the connection between a restrict pointer var and a
  restrict var in a new hash_map restrict_pointed_var.
- move the restrict pointer constraint handling from
  intra_create_variable_infos to make_param_constraints

The result of this and the two preceding patches is that the constraint handling for params in intra_create_variable_infos is reduced to a single call to make_param_constraints.

Thanks,
- Tom
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(-)

diff --git a/gcc/tree-ssa-structalias.c b/gcc/tree-ssa-structalias.c
index e88fbf0..93bc325 100644
--- a/gcc/tree-ssa-structalias.c
+++ b/gcc/tree-ssa-structalias.c
@@ -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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]