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]

Re: [PATCH] Fix call-clobbering (PRs 36373 and 36387)


Something like the attached should fix the points-to results (I may
have missed some is_special_var cases to remove, etc)
Index: tree-ssa-structalias.c
===================================================================
--- tree-ssa-structalias.c	(revision 136230)
+++ tree-ssa-structalias.c	(working copy)
@@ -1398,6 +1398,7 @@ do_sd_constraint (constraint_graph_t gra
   unsigned int j;
   bitmap_iterator bi;
 
+#if 0
  if (bitmap_bit_p (delta, anything_id))
    {
      flag = !bitmap_bit_p (sol, anything_id);
@@ -1405,6 +1406,7 @@ do_sd_constraint (constraint_graph_t gra
        bitmap_set_bit (sol, anything_id);
      goto done;
    }
+#endif
   /* For each variable j in delta (Sol(y)), add
      an edge in the graph from j to x, and union Sol(j) into Sol(x).  */
   EXECUTE_IF_SET_IN_BITMAP (delta, 0, j, bi)
@@ -1423,14 +1425,19 @@ do_sd_constraint (constraint_graph_t gra
 
 	  /* Adding edges from the special vars is pointless.
 	     They don't have sets that can change.  */
+#if 0
 	  if (get_varinfo (t) ->is_special_var)
 	    flag |= bitmap_ior_into (sol, get_varinfo (t)->solution);
-	  else if (add_graph_edge (graph, lhs, t))
+	  else
+#endif
+	  if (add_graph_edge (graph, lhs, t))
 	    flag |= bitmap_ior_into (sol, get_varinfo (t)->solution);
 	}
     }
 
+#if 0
 done:
+#endif
   /* If the LHS solution changed, mark the var as changed.  */
   if (flag)
     {
@@ -1453,6 +1460,7 @@ do_ds_constraint (constraint_t c, bitmap
   unsigned int j;
   bitmap_iterator bi;
 
+#if 0
  if (bitmap_bit_p (sol, anything_id))
    {
      EXECUTE_IF_SET_IN_BITMAP (delta, 0, j, bi)
@@ -1480,13 +1488,17 @@ do_ds_constraint (constraint_t c, bitmap
        }
      return;
    }
-
+#endif
   /* For each member j of delta (Sol(x)), add an edge from y to j and
      union Sol(y) into Sol(j) */
   EXECUTE_IF_SET_IN_BITMAP (delta, 0, j, bi)
     {
       unsigned HOST_WIDE_INT loff = c->lhs.offset;
-      if (type_safe (j, &loff) && !(get_varinfo (j)->is_special_var))
+      if (type_safe (j, &loff)
+#if 0
+&& !(get_varinfo (j)->is_special_var)
+#endif
+)
 	{
 	  varinfo_t v;
 	  unsigned int t;
@@ -1535,7 +1547,8 @@ do_complex_constraint (constraint_graph_
   else if (c->rhs.type == DEREF)
     {
       /* x = *y */
-      if (!(get_varinfo (c->lhs.var)->is_special_var))
+      if (c->lhs.var == anything_id 
+	  || !(get_varinfo (c->lhs.var)->is_special_var))
 	do_sd_constraint (graph, c, delta);
     }
   else
@@ -2134,10 +2147,15 @@ move_complex_constraints (constraint_gra
 	    }
 	  else if (rhs.type == DEREF)
 	    {
+#if 0
 	      if (!(get_varinfo (lhs.var)->is_special_var))
+#endif
 		insert_into_complex (graph, rhs.var, c);
 	    }
-	  else if (rhs.type != ADDRESSOF && lhs.var > anything_id
+	  else if (rhs.type != ADDRESSOF
+#if 0
+		   && lhs.var > anything_id
+#endif
 		   && (lhs.offset != 0 || rhs.offset != 0))
 	    {
 	      insert_into_complex (graph, rhs.var, c);
@@ -2534,10 +2552,6 @@ process_constraint_1 (constraint_t t, bo
       t->lhs.offset = 0;
     }
 
-  /* ANYTHING == ANYTHING is pointless.  */
-  if (lhs.var == anything_id && rhs.var == anything_id)
-    return;
-
   /* If we have &ANYTHING = something, convert to SOMETHING = &ANYTHING) */
   else if (lhs.var == anything_id && lhs.type == ADDRESSOF)
     {
@@ -3606,11 +3620,15 @@ handle_rhs_call  (tree rhs)
 {
   tree arg;
   call_expr_arg_iterator iter;
-  struct constraint_expr rhsc;
+  struct constraint_expr includesanything;
+  struct constraint_expr anythingincludes;
 
-  rhsc.var = anything_id;
-  rhsc.offset = 0;
-  rhsc.type = ADDRESSOF;
+  includesanything.var = anything_id;
+  includesanything.offset = 0;
+  includesanything.type = ADDRESSOF;
+  anythingincludes.var = anything_id;
+  anythingincludes.offset = 0;
+  anythingincludes.type = SCALAR;
 
   FOR_EACH_CALL_EXPR_ARG (arg, iter, rhs)
     {
@@ -3624,9 +3642,13 @@ handle_rhs_call  (tree rhs)
 	  struct constraint_expr *lhsp;
 
 	  get_constraint_for (arg, &lhsc);
+	  for (j = 0; VEC_iterate (ce_s, lhsc, j, lhsp); j++)
+	    process_constraint_1 (new_constraint (anythingincludes, *lhsp),
+				  true);
 	  do_deref (&lhsc);
 	  for (j = 0; VEC_iterate (ce_s, lhsc, j, lhsp); j++)
-	    process_constraint_1 (new_constraint (*lhsp, rhsc), true);
+	    process_constraint_1 (new_constraint (*lhsp, includesanything),
+				  true);
 	  VEC_free (ce_s, heap, lhsc);
 	}
     }
@@ -5026,21 +5048,30 @@ init_base_vars (void)
   var_anything->is_special_var = 1;
   anything_id = 1;
 
-  /* Anything points to anything.  This makes deref constraints just
-     work in the presence of linked list and other p = *p type loops,
-     by saying that *ANYTHING = ANYTHING. */
   VEC_safe_push (varinfo_t, heap, varmap, var_anything);
+
+  /* ANYTHING = *ANYTHING, because anything is may-deref'd at calls, etc.  */
+
+  lhs.type = SCALAR;
+  lhs.var = anything_id;
+  lhs.offset = 0;
+  rhs.type = DEREF;
+  rhs.var = anything_id;
+  rhs.offset = 0;
+  process_constraint_1 (new_constraint (lhs, rhs), true);
+
+
+  /* ANTHING = &ANYTHING because anything points to anything.  */
   lhs.type = SCALAR;
   lhs.var = anything_id;
   lhs.offset = 0;
   rhs.type = ADDRESSOF;
   rhs.var = anything_id;
   rhs.offset = 0;
+  process_constraint_1 (new_constraint (lhs, rhs), true);
 
-  /* This specifically does not use process_constraint because
-     process_constraint ignores all anything = anything constraints, since all
-     but this one are redundant.  */
-  VEC_safe_push (constraint_t, heap, constraints, new_constraint (lhs, rhs));
+  /* *ANYTHING = &ANYTHING is added at the bottom since it will
+     create a new variable.  */
 
   /* Create the READONLY variable, used to represent that a variable
      points to readonly memory.  */
@@ -5092,6 +5123,17 @@ init_base_vars (void)
   rhs.var = anything_id;
   rhs.offset = 0;
   process_constraint (new_constraint (lhs, rhs));
+
+  /* *ANYTHING = &ANYTHING.  This is true because we have to assume
+     everything pointed to by anything can also point to anything. */
+  lhs.type = DEREF;
+  lhs.var = anything_id;
+  lhs.offset = 0;
+  rhs.type = ADDRESSOF;
+  rhs.var = anything_id;
+  rhs.offset = 0;
+  process_constraint_1 (new_constraint (lhs, rhs), true);
+
 }
 
 /* Initialize things necessary to perform PTA */

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