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]

[tree-ssa]: Fix points-to


Fixes bugs introduced by my last change (memory problems), and removes 
flag_ip in favor of using flag_unit_at_a_time.

2003-02-25  Daniel Berlin  <dberlin at dberlin dot org>

	* flags.h: Remove flag_ip.
	* toplev.c: Ditto.
	* tree-alias-ander.c: s/flag_ip/flag_unit_at_a_time/g.
	(andersen_cleanup): Set region to null when done.
	(andersen_function_call): Check DECL_PTA_TYPEVAR, not
	DECL_SAVED_TREE.
	* tree-alias-common.c: s/SSA_DECL_P/DECL_P/g.
	(get_alias_var_decl): Remove dead code, fix bug in what is a
	local alias var.
	(find_func_aliases): Use get_alias_var, not create_fun_alias_var.
	(create_fun_alias_var): Fix to use DECL_PTA_TYPEVAR.
	Use get_alias_var rather than create_alias_var.
	(create_fun_alias_var_ptf): Ditto.
	(create_alias_vars): Ditto.
	* tree-dfa.c (compute_may_aliases): Fix check for
	create_alias_vars.
	Move deletion of alias vars back to here, from tree-ssa.c
	* tree-ssa.c (delete_tree_ssa): Remove delete_alias_vars call.

Index: flags.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/flags.h,v
retrieving revision 1.86.2.18
diff -u -3 -p -r1.86.2.18 flags.h
--- flags.h	23 Feb 2003 22:03:03 -0000	1.86.2.18
+++ flags.h	25 Feb 2003 19:42:31 -0000
@@ -669,9 +669,6 @@ extern int flag_tree_ccp;
 /* Enable SSA-DCE on trees.  */
 extern int flag_tree_dce;
 
-/* Enable interprocedural analysis.  */
-extern int flag_ip;
-
 /* Nonzero means put zero initialized data in the bss section.  */
 extern int flag_zero_initialized_in_bss;
 
Index: toplev.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/toplev.c,v
retrieving revision 1.654.2.44
diff -u -3 -p -r1.654.2.44 toplev.c
--- toplev.c	23 Feb 2003 22:03:06 -0000	1.654.2.44
+++ toplev.c	25 Feb 2003 19:42:33 -0000
@@ -911,9 +911,6 @@ int flag_tree_cp = 0;
 /* Enable SSA-DCE on trees.  */
 int flag_tree_dce = 0;
 
-/* Enable interprocedural analysis.  */
-int flag_ip = 0;
-
 /* Nonzero if we perform superblock formation.  */
 int flag_tracer = 0;
 
@@ -1241,9 +1238,7 @@ static const lang_independent_options f_
   { "tree-cp", &flag_tree_cp, 1,
    N_("Enable SSA-CP optimization on trees") },
   { "tree-dce", &flag_tree_dce, 1,
-   N_("Enable SSA dead code elimination optimization on trees") },
-  { "ip", &flag_ip, 1, 
-   N_("Enable interprocedural analysis") },
+   N_("Enable SSA dead code elimination optimization on trees") }
 };
 
 /* Table of language-specific options.  */
@@ -5029,11 +5024,6 @@ parse_options_and_default_flags (argc, a
       flag_unswitch_loops = 1;
     }
   
-  if  (optimize >= 4)
-    {
-      flag_ip = 1;
-    }
-
   if (optimize < 2 || optimize_size)
     {
       align_loops = 1;
Index: tree-alias-ander.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-alias-ander.c,v
retrieving revision 1.1.2.10
diff -u -3 -p -r1.1.2.10 tree-alias-ander.c
--- tree-alias-ander.c	24 Feb 2003 19:32:27 -0000	1.1.2.10
+++ tree-alias-ander.c	25 Feb 2003 19:42:33 -0000
@@ -400,7 +400,7 @@ static void
 andersen_init (ops)
      struct tree_alias_ops *ops ATTRIBUTE_UNUSED;
 {
-  if (!initted || !flag_ip)
+  if (!initted || !flag_unit_at_a_time)
     {
       pta_init ();
       andersen_rgn = newregion ();
@@ -410,7 +410,7 @@ andersen_init (ops)
   dump_file = dump_begin (TDI_pta, &dump_flags);
   ptamap = splay_tree_new (splay_tree_compare_pointers, NULL, NULL);
   /* Don't claim we can do ip partial unless the user requests it. */
-  if (!flag_ip)
+  if (!flag_unit_at_a_time)
     andersen_ops.ip_partial = 0;
   
 }
@@ -445,11 +445,12 @@ andersen_cleanup (ops)
       dump_end (TDI_pta, dump_file);
     }
   
-  if (!flag_ip)
+  if (!flag_unit_at_a_time)
     {
       pta_reset ();
       splay_tree_delete (ptamap);
       deleteregion (andersen_rgn);
+      andersen_rgn = NULL;
     }
   
 
@@ -732,8 +733,8 @@ andersen_function_call (ops, lhs, func, 
      just have incoming parameters assigned to global_var if
      necessary. */
   if (TREE_CODE (decl) == FUNCTION_DECL 
-      && DECL_SAVED_TREE (decl) != NULL_TREE 
-      && flag_ip 
+      && DECL_PTA_TYPEVAR (decl)
+      && flag_unit_at_a_time
       && (!TREE_PUBLIC (decl) && TREE_STATIC (decl)))
     {
       return 0;
Index: tree-alias-common.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-alias-common.c,v
retrieving revision 1.1.2.19
diff -u -3 -p -r1.1.2.19 tree-alias-common.c
--- tree-alias-common.c	24 Feb 2003 19:32:27 -0000	1.1.2.19
+++ tree-alias-common.c	25 Feb 2003 19:42:33 -0000
@@ -149,23 +149,13 @@ static alias_typevar
 get_alias_var_decl (decl)
      tree decl;
 {
-  struct alias_annot_entry *entry;
-  struct alias_annot_entry lookup;
-  
   alias_typevar newvar;
   
-  if (SSA_DECL_P (decl))
+  if (DECL_P (decl))
     {
       if (DECL_PTA_TYPEVAR (decl))
 	return DECL_PTA_TYPEVAR (decl);
     }
-  else
-    {
-      lookup.key = decl;
-      entry = htab_find (alias_annot, &lookup);
-      if (entry != NULL && entry->value != 0)
-	return entry->value;
-    } 
   /* For debugging, remove this whole if block, and re-enable the 
      find_func_decls call. */
   if (TREE_CODE (decl) == FUNCTION_DECL)
@@ -178,11 +168,16 @@ get_alias_var_decl (decl)
 	newvar = create_alias_var (decl);
     }
   
-  if (!TREE_PUBLIC (decl))
+  if (!current_alias_ops->ip)
     {
-      VARRAY_PUSH_INT (local_alias_varnums, 
-		       VARRAY_ACTIVE_SIZE (alias_vars) - 1);
-      VARRAY_PUSH_GENERIC_PTR (local_alias_vars, decl);
+      if (!current_alias_ops->ip_partial 
+	  || (TREE_CODE (decl) != FUNCTION_DECL 
+	      && TREE_CODE (decl)!= PARM_DECL))
+	{
+	  VARRAY_PUSH_INT (local_alias_varnums, 
+			   VARRAY_ACTIVE_SIZE (alias_vars) - 1);
+	  VARRAY_PUSH_GENERIC_PTR (local_alias_vars, decl);
+	}
     }
   return newvar;
 }
@@ -511,9 +506,6 @@ find_func_aliases (tp, walk_subtrees, da
 			VARRAY_PUSH_GENERIC_PTR (args, aav);
 
 		    }
-		  if (TREE_CODE (callop0) == ADDR_EXPR)
-		    create_fun_alias_var (TREE_OPERAND (callop0, 0), 0);
-		  
 		  /* NORETURN and CONST functions have no effect on aliasing. */
 		  if (!(call_expr_flags (op1) & (ECF_NORETURN | ECF_CONST)))
 		    if (current_alias_ops->function_call (current_alias_ops, lhsAV, 
@@ -663,8 +655,6 @@ find_func_aliases (tp, walk_subtrees, da
 	  if (aav)
 	    VARRAY_PUSH_GENERIC_PTR (args, aav);
 	}
-      if (TREE_CODE (TREE_OPERAND (stp, 0)) == ADDR_EXPR)
-	create_fun_alias_var (TREE_OPERAND (TREE_OPERAND (stp, 0), 0), 0);
       /* NORETURN and CONST functions have no effect on aliasing.  */
       if (!(call_expr_flags (stp) & (ECF_NORETURN | ECF_CONST)))
 	if (current_alias_ops->function_call (current_alias_ops, NULL, 
@@ -718,14 +708,11 @@ create_fun_alias_var (decl, force)
   alias_typevar avar, retvar;
   tree rdecl;
   varray_type params = NULL;
-  struct alias_annot_entry entry, *newentry, *result, **slot;
   
-  entry.key = decl;
-  result = htab_find (alias_annot, &entry);
   if (!force)
     {
-      if (result != NULL && result->value != NULL)
-	return result->value;
+      if (DECL_PTA_TYPEVAR (decl)) 
+        return DECL_PTA_TYPEVAR (decl);
     }
 
   VARRAY_GENERIC_PTR_INIT (params, 1, "Arguments");
@@ -734,15 +721,7 @@ create_fun_alias_var (decl, force)
       tree arg;
       for (arg = DECL_ARGUMENTS (decl); arg; arg = TREE_CHAIN (arg))
 	{
-	  alias_typevar tvar = create_alias_var (arg);
-	  newentry = ggc_alloc (sizeof (struct alias_annot_entry));
-	  newentry->key = arg;
-	  newentry->value = tvar;
-	  slot = (struct alias_annot_entry **) htab_find_slot (alias_annot, 
-							       newentry, 
-							       INSERT);
-	  *slot = newentry;
-	  
+	  alias_typevar tvar = get_alias_var (arg);
 	  VARRAY_PUSH_GENERIC_PTR (params, tvar);
 	  /* Incoming pointers can point to global_var, unless 
 	     either we are interprocedural, or we can do ip on all
@@ -767,7 +746,7 @@ create_fun_alias_var (decl, force)
 	   arg = TREE_CHAIN (arg))
 	{
 	  tree fakedecl = create_tmp_alias_var (TREE_VALUE (arg), "normarg");
-	  alias_typevar tvar = create_alias_var (fakedecl);
+	  alias_typevar tvar = get_alias_var (fakedecl);
 	  VARRAY_PUSH_GENERIC_PTR (params, tvar);	  
 	  
 	  /* Incoming pointers can point to global_var, unless 
@@ -791,7 +770,7 @@ create_fun_alias_var (decl, force)
   else
     {
       tree fakedecl = create_tmp_alias_var (void_type_node, "fakearg");
-      alias_typevar fakevar = create_alias_var (fakedecl);
+      alias_typevar fakevar = get_alias_var (fakedecl);
       VARRAY_PUSH_GENERIC_PTR (params, fakevar);
     }
 
@@ -802,13 +781,7 @@ create_fun_alias_var (decl, force)
   VARRAY_PUSH_GENERIC_PTR (alias_vars, avar);
 
   current_alias_ops->function_def (current_alias_ops, avar, params, retvar);
-  newentry = ggc_alloc (sizeof (struct alias_annot_entry));
-  newentry->key = decl;
-  newentry->value = avar;
-  slot = (struct alias_annot_entry **) htab_find_slot (alias_annot, 
-						       newentry, 
-						       INSERT);
-  *slot = newentry;
+  DECL_PTA_TYPEVAR (decl) = avar;
 	  
   /* FIXME: Also, if this is a defining declaration then add the annotation
      to all extern definitions of the function. */
@@ -837,13 +810,9 @@ create_fun_alias_var_ptf (decl, type)
   alias_typevar avar, retvar;
   tree rdecl;
   varray_type params = NULL;
-  struct alias_annot_entry entry, *result, *newentry, **slot;
-  
-  entry.key = decl;
-  result = htab_find (alias_annot, &entry);
   
-  if (result != NULL && result->value != NULL)
-    return result->value;
+  if (DECL_PTA_TYPEVAR (decl))
+    return DECL_PTA_TYPEVAR (decl);
 
   VARRAY_GENERIC_PTR_INIT (params, 1, "Arguments");
 
@@ -856,7 +825,7 @@ create_fun_alias_var_ptf (decl, type)
 	   arg = TREE_CHAIN (arg))
 	{
 	  tree fakedecl = create_tmp_alias_var (TREE_VALUE (arg), "ptfarg");
-	  alias_typevar tvar = create_alias_var (fakedecl);
+	  alias_typevar tvar = get_alias_var (fakedecl);
 	  VARRAY_PUSH_GENERIC_PTR (params, tvar);
 	}
     }
@@ -867,7 +836,7 @@ create_fun_alias_var_ptf (decl, type)
   else
     {
       tree fakedecl = create_tmp_alias_var (void_type_node, "fakearg");
-      alias_typevar fakevar = create_alias_var (fakedecl);
+      alias_typevar fakevar = get_alias_var (fakedecl);
       VARRAY_PUSH_GENERIC_PTR (params, fakevar);
     }
 
@@ -879,12 +848,7 @@ create_fun_alias_var_ptf (decl, type)
   VARRAY_PUSH_GENERIC_PTR (alias_vars, avar);
   
   current_alias_ops->function_def (current_alias_ops, avar, params, retvar);
-  newentry = ggc_alloc (sizeof (struct alias_annot_entry));
-  newentry->key = decl;
-  newentry->value = avar;
-  slot = (struct alias_annot_entry **) htab_find_slot (alias_annot,
-						       newentry, INSERT);
-  *slot = newentry;
+  DECL_PTA_TYPEVAR (decl) = avar;
   
   return avar;
 }
@@ -905,7 +869,7 @@ create_alias_var (decl)
   struct alias_annot_entry entry, *result, *newentry, **slot;
   
   alias_typevar avar;
-  if (SSA_DECL_P (decl))
+  if (DECL_P (decl))
     {
       if (DECL_PTA_TYPEVAR (decl))
 	return DECL_PTA_TYPEVAR (decl);
@@ -923,7 +887,8 @@ create_alias_var (decl)
     }
   else
     avar = current_alias_ops->add_var (current_alias_ops, decl);
-  if (SSA_DECL_P (decl))
+  
+  if (DECL_P (decl))
     {
       DECL_PTA_TYPEVAR (decl) = avar;
     }
@@ -985,7 +950,10 @@ create_alias_vars (fndecl)
 
   /* Don't force creation unless we are processing the top level
      function decl. */
-  create_fun_alias_var (fndecl, fndecl == current_function_decl);
+  if (fndecl == current_function_decl)
+    DECL_PTA_TYPEVAR (fndecl) = NULL;
+  get_alias_var (fndecl);
+
   /* For debugging, disable the on-the-fly variable creation, 
      and reenable this. */
   /*  walk_tree_without_duplicates (&DECL_SAVED_TREE (fndecl),
@@ -1006,7 +974,7 @@ delete_alias_vars ()
   for (i = 0; i < VARRAY_ACTIVE_SIZE (local_alias_vars); i++)
     {
       entry.key = VARRAY_GENERIC_PTR (local_alias_vars, i);
-      if (!SSA_DECL_P (entry.key))
+      if (!DECL_P (entry.key))
 	{
 	  htab_remove_elt (alias_annot, &entry);
 	}
@@ -1069,7 +1037,7 @@ ptr_may_alias_var (ptr, var)
   if (ptr == var || (DECL_CONTEXT (ptr) == NULL
 		     && DECL_CONTEXT (var) == NULL))
     return true;
-  if (SSA_DECL_P (ptr))
+  if (DECL_P (ptr))
     {
       ptrtv = DECL_PTA_TYPEVAR (ptr);
       if (DECL_CONTEXT (ptr) == NULL)
@@ -1092,7 +1060,7 @@ ptr_may_alias_var (ptr, var)
 	return false;
       ptrtv = result->value;  
     }
-  if (SSA_DECL_P (var))
+  if (DECL_P (var))
     {
       vartv = DECL_PTA_TYPEVAR (var);
       if (DECL_CONTEXT (var) == NULL)
Index: tree-dfa.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-dfa.c,v
retrieving revision 1.1.4.81
diff -u -3 -p -r1.1.4.81 tree-dfa.c
--- tree-dfa.c	21 Feb 2003 15:51:18 -0000	1.1.4.81
+++ tree-dfa.c	25 Feb 2003 19:42:33 -0000
@@ -1500,7 +1500,7 @@ compute_may_aliases ()
   htab_delete (vars_found);
   htab_delete (aliased_objects_found);
 
-  if (flag_tree_points_to != PTA_NONE && aliased_objects_found)
+  if (flag_tree_points_to != PTA_NONE && num_aliased_objects)
     {
       timevar_push (TV_TREE_PTA);
       create_alias_vars (current_function_decl);
@@ -1508,6 +1508,13 @@ compute_may_aliases ()
     }
 
   compute_alias_sets ();
+  
+  if (flag_tree_points_to != PTA_NONE && num_aliased_objects)
+    {
+      timevar_push (TV_TREE_PTA);
+      delete_alias_vars ();
+      timevar_pop (TV_TREE_PTA);
+    }
 
   num_aliased_objects = 0;
   aliased_objects = 0;
Index: tree-ssa.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-ssa.c,v
retrieving revision 1.1.4.53
diff -u -3 -p -r1.1.4.53 tree-ssa.c
--- tree-ssa.c	12 Feb 2003 19:52:02 -0000	1.1.4.53
+++ tree-ssa.c	25 Feb 2003 19:42:34 -0000
@@ -995,13 +995,6 @@ delete_tree_ssa (fndecl)
   for (i = 0; i < num_referenced_vars; i++)
     referenced_var (i)->common.ann = NULL;
 
-  if (flag_tree_points_to != PTA_NONE && num_referenced_vars)
-    {
-      timevar_push (TV_TREE_PTA);
-      delete_alias_vars ();
-      timevar_pop (TV_TREE_PTA);
-    }
-
   num_referenced_vars = 0;
   referenced_vars = NULL;
   global_var = NULL_TREE;
Index: tree.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree.c,v
retrieving revision 1.263.2.24
diff -u -3 -p -r1.263.2.24 tree.c
--- tree.c	23 Feb 2003 22:03:06 -0000	1.263.2.24
+++ tree.c	25 Feb 2003 19:42:35 -0000
@@ -333,6 +333,7 @@ make_node (code)
 
       /* We have not yet computed the alias set for this declaration.  */
       DECL_POINTER_ALIAS_SET (t) = -1;
+      DECL_PTA_TYPEVAR (t) = 0;
       break;
 
     case 't':
Index: tree.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree.h,v
retrieving revision 1.342.2.49
diff -u -3 -p -r1.342.2.49 tree.h
--- tree.h	24 Feb 2003 19:32:27 -0000	1.342.2.49
+++ tree.h	25 Feb 2003 19:42:36 -0000
@@ -2165,7 +2165,7 @@ struct tree_decl GTY(())
 
   tree vindex;
   HOST_WIDE_INT pointer_alias_set;
-  union alias_typevar_def * GTY ((skip (""))) typevar;
+  union alias_typevar_def *GTY ((skip(""))) typevar;
   /* Points to a structure whose details depend on the language in use.  */
   struct lang_decl *lang_specific;
 };


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