diff mbox

[3/6] Add recursion to make_param_constraints

Message ID 562F748D.5020507@mentor.com
State New
Headers show

Commit Message

Tom de Vries Oct. 27, 2015, 12:56 p.m. UTC
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

Comments

Tom de Vries Nov. 1, 2015, 6:03 p.m. UTC | #1
On 27/10/15 13:56, Tom de Vries wrote:
> 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.

I've managed to eliminate this patch from the patch series, at the cost 
of having to merge patches 4-6 into a single patch, rather than having a 
more stepwise approach.

So, the new patch series is:

      1	Rename make_restrict_var_constraints to make_param_constraints
      2	Handle recursive restrict in function parameter

I'll repost in reply to this message.

Thanks,
- Tom
diff mbox

Patch

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