public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* Minor improvement to points-to analysis
@ 2004-07-31 18:56 Diego Novillo
  0 siblings, 0 replies; only message in thread
From: Diego Novillo @ 2004-07-31 18:56 UTC (permalink / raw)
  To: gcc-patches


Noticed while fixing the alias problem in Ada.  We shouldn't just look
at invariant addresses.

This lets us find a few more points-to sets (~700 more in a bootstrap
and ~1300 in DLV).  This means precisely zilch, but it's Friday and I
have nothing better to do.

I'm hoping that we will soon be able to get rid of this use-def chain
walker.  Brian Booth is working on an improvement that may give us a bit
better points-to sets almost for free.  We'll see if it pans out.

Bootstrapped and tested x86, alpha, ia64, x86-64 and ppc.


Diego.


	* tree-ssa-alias.c (compute_points_to_and_addr_escape): If a
	pointer escapes through a function call, assume that the
	callee will dereference it.
	(add_pointed_to_var): Assume that VALUE is always an
	ADDR_EXPR.
	(collect_points_to_info_r): Only call add_pointed_to_var if
	the value is an ADDR_EXPR.


Index: tree-ssa-alias.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-ssa-alias.c,v
retrieving revision 2.21
diff -d -c -p -u -r2.21 tree-ssa-alias.c
--- tree-ssa-alias.c	30 Jul 2004 14:59:46 -0000	2.21
+++ tree-ssa-alias.c	30 Jul 2004 17:11:12 -0000
@@ -691,7 +691,10 @@ compute_points_to_and_addr_escape (struc
 		     that pointer OP will be dereferenced in a store
 		     operation inside the called function.  */
 		  if (get_call_expr_in (stmt))
-		    bitmap_set_bit (ai->dereferenced_ptrs_store, v_ann->uid);
+		    {
+		      bitmap_set_bit (ai->dereferenced_ptrs_store, v_ann->uid);
+		      pi->is_dereferenced = 1;
+		    }
 		}
 	    }
 
@@ -1863,35 +1866,32 @@ static void
 add_pointed_to_var (struct alias_info *ai, tree ptr, tree value)
 {
   struct ptr_info_def *pi = get_ptr_info (ptr);
+  tree pt_var;
+  size_t uid;
 
-  if (TREE_CODE (value) == ADDR_EXPR)
-    {
-      tree pt_var;
-      size_t uid;
+#if defined ENABLE_CHECKING
+  if (TREE_CODE (value) != ADDR_EXPR)
+    abort ();
+#endif
 
-      pt_var = TREE_OPERAND (value, 0);
-      if (TREE_CODE_CLASS (TREE_CODE (pt_var)) == 'r')
-	pt_var = get_base_address (pt_var);
+  pt_var = TREE_OPERAND (value, 0);
+  if (TREE_CODE_CLASS (TREE_CODE (pt_var)) == 'r')
+    pt_var = get_base_address (pt_var);
 
-      if (pt_var && SSA_VAR_P (pt_var))
-	{
-	  uid = var_ann (pt_var)->uid;
-	  bitmap_set_bit (ai->addresses_needed, uid);
+  if (pt_var && SSA_VAR_P (pt_var))
+    {
+      uid = var_ann (pt_var)->uid;
+      bitmap_set_bit (ai->addresses_needed, uid);
 
-	  /* If PTR has already been found to point anywhere, don't
-	     add the variable to PTR's points-to set.  */
-	  if (!pi->pt_anything)
-	    {
-	      if (pi->pt_vars == NULL)
-		pi->pt_vars = BITMAP_GGC_ALLOC ();
-	      bitmap_set_bit (pi->pt_vars, uid);
-	    }
+      /* If PTR has already been found to point anywhere, don't
+	 add the variable to PTR's points-to set.  */
+      if (!pi->pt_anything)
+	{
+	  if (pi->pt_vars == NULL)
+	    pi->pt_vars = BITMAP_GGC_ALLOC ();
+	  bitmap_set_bit (pi->pt_vars, uid);
 	}
-      else
-	add_pointed_to_expr (ptr, value);
     }
-  else
-    add_pointed_to_expr (ptr, value);
 }
 
 
@@ -1922,8 +1922,8 @@ collect_points_to_info_r (tree var, tree
       tree rhs = TREE_OPERAND (stmt, 1);
       STRIP_NOPS (rhs);
 
-      /* Found P_i = CONST.  */
-      if (is_gimple_min_invariant (rhs))
+      /* Found P_i = ADDR_EXPR  */
+      if (TREE_CODE (rhs) == ADDR_EXPR)
 	add_pointed_to_var (ai, var, rhs);
 
       /* Found P_i = Q_j.  */
@@ -1944,9 +1944,9 @@ collect_points_to_info_r (tree var, tree
 	  else if (TREE_CODE (op1) == SSA_NAME
 		   && POINTER_TYPE_P (TREE_TYPE (op1)))
 	    merge_pointed_to_info (ai, var, op1);
-	  else if (is_gimple_min_invariant (op0))
+	  else if (TREE_CODE (op0) == ADDR_EXPR)
 	    add_pointed_to_var (ai, var, op0);
-	  else if (is_gimple_min_invariant (op1))
+	  else if (TREE_CODE (op1) == ADDR_EXPR)
 	    add_pointed_to_var (ai, var, op1);
 	  else
 	    add_pointed_to_expr (var, rhs);
@@ -1978,7 +1978,7 @@ collect_points_to_info_r (tree var, tree
 	 variable that we are analyzing is the LHS of the PHI node.  */
       tree lhs = PHI_RESULT (stmt);
 
-      if (is_gimple_min_invariant (var))
+      if (TREE_CODE (var) == ADDR_EXPR)
 	add_pointed_to_var (ai, lhs, var);
       else if (TREE_CODE (var) == SSA_NAME)
 	{
@@ -1987,6 +1987,8 @@ collect_points_to_info_r (tree var, tree
 	  else
 	    set_pt_anything (lhs);
 	}
+      else if (is_gimple_min_invariant (var))
+	add_pointed_to_expr (lhs, var);
       else
 	abort ();
     }


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2004-07-30 21:04 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-07-31 18:56 Minor improvement to points-to analysis Diego Novillo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).