tree-ssa-alias.c (compute_may_aliases): Remove call to delete_old_heap_vars.
authorDaniel Berlin <dberlin@dberlin.org>
Thu, 10 Nov 2005 17:23:49 +0000 (17:23 +0000)
committerDaniel Berlin <dberlin@gcc.gnu.org>
Thu, 10 Nov 2005 17:23:49 +0000 (17:23 +0000)
2005-11-10  Daniel Berlin  <dberlin@dberlin.org>

* tree-ssa-alias.c (compute_may_aliases): Remove call to
delete_old_heap_vars.
* tree-dfa.c (referenced_var_remove): Remove function.
* tree-ssa.c (init_tree_ssa): Call init_alias_heapvars.
(delete_tree_ssa): Remove call to delete_old_heapvars.
Add call to delete_alias_heapvars.
* tree-flow.h (referenced_var_remove): Remove prototype
(init_alias_heapvars): New prototype.
(delete_alias_heapvars): Ditto.
* Makefile.in (tree-ssa-structalias.o): Add
gt-tree-ssa-structalias.o
(GTFILES): Add tree-ssa-structalias.h and
tree-ssa-structalias.c.
(s-gtype): Add gt-tree-ssa-structalias.h.
* tree-ssa-structalias.c (heapvars): Remove.
(oldheapvars): Remove.
(heapvar_for_stmt): New variable.
(heapvar_lookup): New function.
(heapvar_insert): Ditto.
(get_constraint_for): See if we have an old heapvar
to reuse.
(init_alias_heapvars): New function.
(delete_alias_heapvars): Ditto.
Add include of gt-tree-ssa-structalias.h.

From-SVN: r106743

gcc/ChangeLog
gcc/Makefile.in
gcc/tree-dfa.c
gcc/tree-flow.h
gcc/tree-ssa-alias.c
gcc/tree-ssa-structalias.c
gcc/tree-ssa.c

index 9465d8060a2bd042db4613b6a89e7e67381a55e6..3a0cbc6a21e7d3d03fa8726eac6cb783b1db8817 100644 (file)
@@ -1,3 +1,30 @@
+2005-11-10  Daniel Berlin  <dberlin@dberlin.org>
+
+       * tree-ssa-alias.c (compute_may_aliases): Remove call to 
+       delete_old_heap_vars.
+       * tree-dfa.c (referenced_var_remove): Remove function.
+       * tree-ssa.c (init_tree_ssa): Call init_alias_heapvars.
+       (delete_tree_ssa): Remove call to delete_old_heapvars.
+       Add call to delete_alias_heapvars.
+       * tree-flow.h (referenced_var_remove): Remove prototype
+       (init_alias_heapvars): New prototype.
+       (delete_alias_heapvars): Ditto.
+       * Makefile.in (tree-ssa-structalias.o): Add
+       gt-tree-ssa-structalias.o
+       (GTFILES): Add tree-ssa-structalias.h and
+       tree-ssa-structalias.c.
+       (s-gtype): Add gt-tree-ssa-structalias.h.
+       * tree-ssa-structalias.c (heapvars): Remove.
+       (oldheapvars): Remove.
+       (heapvar_for_stmt): New variable.
+       (heapvar_lookup): New function.
+       (heapvar_insert): Ditto.
+       (get_constraint_for): See if we have an old heapvar
+       to reuse.
+       (init_alias_heapvars): New function.
+       (delete_alias_heapvars): Ditto.
+       Add include of gt-tree-ssa-structalias.h.
+
 2005-11-10  Eric Botcazou  <ebotcazou@libertysurf.fr>
 
        PR middle-end/22127
index 4fbbd6c6336209e9dded594903462e4cb52ee860..934d439c36c577c415a6ea728b730633ba08d839 100644 (file)
@@ -1743,7 +1743,8 @@ stor-layout.o : stor-layout.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \
    toplev.h
 tree-ssa-structalias.o: tree-ssa-structalias.c tree-ssa-structalias.h \
    $(SYSTEM_H) $(CONFIG_H) $(GGC_H) $(TREE_H) $(TREE_FLOW_H) \
-   $(TM_H) coretypes.h cgraph.h tree-pass.h $(TIMEVAR_H)
+   $(TM_H) coretypes.h cgraph.h tree-pass.h $(TIMEVAR_H) \
+   gt-tree-ssa-structalias.h
 tree-ssa.o : tree-ssa.c $(TREE_FLOW_H) $(CONFIG_H) $(SYSTEM_H) \
    $(RTL_H) $(TREE_H) $(TM_P_H) $(EXPR_H) output.h $(DIAGNOSTIC_H) \
    toplev.h function.h $(TIMEVAR_H) $(TM_H) coretypes.h \
@@ -2756,7 +2757,8 @@ GTFILES = $(srcdir)/input.h $(srcdir)/coretypes.h \
   $(srcdir)/tree-chrec.h $(srcdir)/tree-vect-generic.c \
   $(srcdir)/tree-ssa-operands.h $(srcdir)/tree-ssa-operands.c \
   $(srcdir)/tree-profile.c $(srcdir)/tree-nested.c \
-  $(srcdir)/ipa-reference.c \
+  $(srcdir)/ipa-reference.c $(srcdir)/tree-ssa-structalias.h \
+  $(srcdir)/tree-ssa-structalias.c \
   $(srcdir)/targhooks.c $(out_file) \
   @all_gtfiles@
 
@@ -2778,6 +2780,7 @@ gt-tree-profile.h gt-tree-ssa-address.h \
 gt-tree-ssanames.h gt-tree-iterator.h gt-gimplify.h \
 gt-tree-phinodes.h gt-tree-nested.h \
 gt-tree-ssa-operands.h gt-tree-ssa-propagate.h \
+gt-tree-ssa-structalias.h \
 gt-stringpool.h gt-targhooks.h : s-gtype ; @true
 
 define echo_quoted_to_gtyp
index 2ede8e6365bbbffdc9c1becea90cd77b17bad2df..9fc48d5cbe8c8fdb77941a46917763acb7aaf55f 100644 (file)
@@ -609,18 +609,6 @@ referenced_var_insert (unsigned int uid, tree to)
   *(struct int_tree_map **)  loc = h;
 }
 
-/* Remove the pair DECL_UID (TO), TO from the referenced vars
-   hashtable.  */
-
-void
-referenced_var_remove (tree to)
-{ 
-  struct int_tree_map in;
-  in.uid = DECL_UID (to);
-  in.to = to;
-  htab_remove_elt_with_hash (referenced_vars, &in, in.uid);
-}
-
 /* Add VAR to the list of dereferenced variables.
 
    WALK_STATE contains a hash table used to avoid adding the same
index b61b3575dd2fb4819c136646a90da5d7ca8ae058..8b01f8b4cc967f1e6e74f16ae39747122af95d94 100644 (file)
@@ -423,7 +423,6 @@ extern GTY((param_is (struct int_tree_map))) htab_t referenced_vars;
 
 extern tree referenced_var_lookup (unsigned int);
 extern tree referenced_var_lookup_if_exists (unsigned int);
-extern void referenced_var_remove (tree);
 #define num_referenced_vars htab_elements (referenced_vars)
 #define referenced_var(i) referenced_var_lookup (i)
 
@@ -892,7 +891,9 @@ int push_fields_onto_fieldstack (tree, VEC(fieldoff_s,heap) **,
                                 HOST_WIDE_INT, bool *);
 void sort_fieldstack (VEC(fieldoff_s,heap) *);
 
-void delete_old_heap_vars (void);
+void init_alias_heapvars (void);
+void delete_alias_heapvars (void);
+
 #include "tree-flow-inline.h"
 
 #endif /* _TREE_FLOW_H  */
index 539789491b3b8cd5bd22585e9f81c3507baff626..84c522554b21c5147efdce1f0f34ab9e72f7851c 100644 (file)
@@ -252,8 +252,6 @@ compute_may_aliases (void)
   
   memset (&alias_stats, 0, sizeof (alias_stats));
 
-  delete_old_heap_vars ();
-
   /* Initialize aliasing information.  */
   ai = init_alias_info ();
 
index 67e872af9d3347dee14bd23029486e95a2fe0d51..db230af72408636e981766b88ce97a20691e007e 100644 (file)
@@ -159,9 +159,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
   TODO: We could handle unions, but to be honest, it's probably not
   worth the pain or slowdown.  */
 
-static VEC(tree, heap) *heapvars = NULL;
-static VEC(tree, heap) *oldheapvars = NULL;
-
+static GTY ((if_marked ("tree_map_marked_p"), param_is (struct tree_map))) 
+  htab_t heapvar_for_stmt;
 static bool use_field_sensitive = true;
 static unsigned int create_variable_info_for (tree, const char *);
 static struct constraint_expr get_constraint_for (tree, bool *);
@@ -311,6 +310,38 @@ static varinfo_t var_anyoffset;
 static tree anyoffset_tree;
 static unsigned int anyoffset_id;
 
+
+/* Lookup a heap var for STMT, and return it if we find one.  */
+
+static tree 
+heapvar_lookup (tree stmt)
+{
+  struct tree_map *h, in;
+  in.from = from;
+
+  h = htab_find_with_hash (heapvar_for_stmt, &in, htab_hash_pointer (from));
+  if (h)
+    return h->to;
+  return NULL_TREE;
+}
+
+/* Insert a mapping FROM->TO in the heap var for statement
+   hashtable.  */
+
+static void
+heapvar_insert (tree from, tree to)
+{
+  struct tree_map *h;
+  void **loc;
+
+  h = ggc_alloc (sizeof (struct tree_map));
+  h->hash = htab_hash_pointer (from);
+  h->from = from;
+  h->to = to;
+  loc = htab_find_slot_with_hash (heapvar_for_stmt, h, h->hash, INSERT);
+  *(struct tree_map **) loc = h;
+}  
+
 /* Return a new variable info structure consisting for a variable
    named NAME, and using constraint graph node NODE.  */
 
@@ -2213,12 +2244,16 @@ get_constraint_for (tree t, bool *need_anyoffset)
            if (call_expr_flags (t) & (ECF_MALLOC | ECF_MAY_BE_ALLOCA))
              {
                varinfo_t vi;
-               tree heapvar;
+               tree heapvar = heapvar_lookup (t);
                
-               heapvar = create_tmp_var_raw (ptr_type_node, "HEAP");
-               VEC_safe_push (tree, heap, heapvars, heapvar);
-               DECL_EXTERNAL (heapvar) = 1;
-               add_referenced_tmp_var (heapvar);
+               if (heapvar == NULL)
+                 {                 
+                   heapvar = create_tmp_var_raw (ptr_type_node, "HEAP");
+                   DECL_EXTERNAL (heapvar) = 1;
+                   add_referenced_tmp_var (heapvar);
+                   heapvar_insert (t, heapvar);
+                 }
+
                temp.var = create_variable_info_for (heapvar,
                                                     alias_get_name (heapvar));
                
@@ -3768,45 +3803,18 @@ delete_points_to_sets (void)
   have_alias_info = false;
 }
 
-/* Delete old heap vars, since nothing else will remove them for
-   us.  */
-void
-delete_old_heap_vars (void)
+/* Initialize the heapvar for statement mapping.  */
+void 
+init_alias_heapvars (void)
 {
-  if (!in_ssa_p)
-    {
-      VEC_free (tree, heap, heapvars);
-      VEC_free (tree, heap, oldheapvars);
-      heapvars = NULL;
-      oldheapvars = NULL;
-    }
-  /* Why is this complicated?
-     We can't remove the heapvars from the referenced var array until
-     they go away from the ssa form, and we can't remove them from the
-     ssa form until we've renamed it.  We can't renamed it if it's not
-     in the referenced vars array. 
-     Thus, we have to first mark it for renaming, and then the *next*
-     time after that we call this function, we can remove it from
-     referenced vars.  */
+  heapvar_for_stmt = htab_create_ggc (11, tree_map_hash, tree_map_eq, NULL);
+}
 
-  if (!VEC_empty (tree, heapvars))
-    {
-      int i;
-      tree heapvar;
-      for (i = 0; VEC_iterate (tree, heapvars, i, heapvar); i++)
-       {
-         if (in_ssa_p)
-           mark_sym_for_renaming (heapvar);
-         DECL_EXTERNAL (heapvar) = false;
-         bitmap_clear_bit (call_clobbered_vars, DECL_UID (heapvar));
-       }
-      if (!VEC_empty (tree, oldheapvars))
-       {
-         for (i = 0; VEC_iterate (tree, oldheapvars, i, heapvar); i++)
-           referenced_var_remove (heapvar);
-       }
-      VEC_free (tree, heap, oldheapvars);
-      oldheapvars = heapvars;
-      heapvars = NULL;
-    }
+void
+delete_alias_heapvars (void)
+{
+  htab_delete (heapvar_for_stmt);  
 }
+
+  
+#include "gt-tree-ssa-structalias.h"
index 15af7f37210e206b57ac8c8fd9a0a3b13a916403..081d21a7b97c7a7ea91ab9869bf9bfb36a7efbd3 100644 (file)
@@ -803,6 +803,7 @@ init_tree_ssa (void)
                                     int_tree_map_eq, NULL);
   call_clobbered_vars = BITMAP_ALLOC (NULL);
   addressable_vars = BITMAP_ALLOC (NULL);
+  init_alias_heapvars ();
   init_ssanames ();
   init_phinodes ();
   global_var = NULL_TREE;
@@ -848,7 +849,6 @@ delete_tree_ssa (void)
       set_phi_nodes (bb, NULL);
     }
 
-  delete_old_heap_vars ();
   /* Remove annotations from every referenced variable.  */
   FOR_EACH_REFERENCED_VAR (var, rvi)
     {
@@ -868,6 +868,7 @@ delete_tree_ssa (void)
   addressable_vars = NULL;
   modified_noreturn_calls = NULL;
   aliases_computed_p = false;
+  delete_alias_heapvars ();
   gcc_assert (!need_ssa_update_p ());
 }