]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
tree-flow-inline.h (gimple_var_anns): New function.
authorJan Hubicka <jh@suse.cz>
Wed, 20 Dec 2006 22:40:48 +0000 (23:40 +0100)
committerJan Hubicka <hubicka@gcc.gnu.org>
Wed, 20 Dec 2006 22:40:48 +0000 (22:40 +0000)
* tree-flow-inline.h (gimple_var_anns): New function.
(var_ann): Use hashtable for static functions.
* tree-dfa.c (create_var_ann): Likewise.
* tree-ssa.c (var_ann_eq, var_ann_hash): New functions.
(init_tree_ssa): Initialize var anns.
(delete_tree_ssa): Delete var anns; also clear out gimple_df.
* tree-flow.h (struct static_var_ann_d): New structure.
(gimple_df): Add var_anns.

From-SVN: r120089

gcc/ChangeLog
gcc/tree-dfa.c
gcc/tree-flow-inline.h
gcc/tree-flow.h
gcc/tree-ssa.c

index 42e4aa5edae402b0fefb4cd0c07a6a5e802eb90e..c4bcad1fa2c52350535105b4771a205aa65de4d6 100644 (file)
@@ -1,3 +1,14 @@
+2006-12-20  Jan Hubicka  <jh@suse.cz>
+
+       * tree-flow-inline.h (gimple_var_anns): New function.
+       (var_ann): Use hashtable for static functions.
+       * tree-dfa.c (create_var_ann): Likewise.
+       * tree-ssa.c (var_ann_eq, var_ann_hash): New functions.
+       (init_tree_ssa): Initialize var anns.
+       (delete_tree_ssa): Delete var anns; also clear out gimple_df.
+       * tree-flow.h (struct static_var_ann_d): New structure.
+       (gimple_df): Add var_anns.
+
 2006-12-20  Carlos O'Donell  <carlos@codesourcery.com>
 
        PR bootstrap/30242
index 0aabc80b7a7b9ea5a0524e85ca5f1421919cd861..5b9c72418b559400de8502c6355690f9ce73a4bc 100644 (file)
@@ -124,16 +124,33 @@ var_ann_t
 create_var_ann (tree t)
 {
   var_ann_t ann;
+  struct static_var_ann_d *sann = NULL;
 
   gcc_assert (t);
   gcc_assert (DECL_P (t));
   gcc_assert (!t->base.ann || t->base.ann->common.type == VAR_ANN);
 
-  ann = GGC_CNEW (struct var_ann_d);
+  if (TREE_STATIC (t))
+    {
+      sann = GGC_CNEW (struct static_var_ann_d);
+      ann = &sann->ann;
+    }
+  else
+    ann = GGC_CNEW (struct var_ann_d);
 
   ann->common.type = VAR_ANN;
 
-  t->base.ann = (tree_ann_t) ann;
+  if (TREE_STATIC (t))
+    {
+       void **slot;
+       sann->uid = DECL_UID (t);
+       slot = htab_find_slot_with_hash (gimple_var_anns (cfun),
+                                       t, DECL_UID (t), INSERT);
+       gcc_assert (!*slot);
+       *slot = sann;
+    }
+  else
+    t->base.ann = (tree_ann_t) ann;
 
   return ann;
 }
index e2b4f9791405cc2085c431999c5a25560aa6a149..d87adc3911248975f5011ec54f90c590fba2ea60 100644 (file)
@@ -91,6 +91,15 @@ gimple_nonlocal_all (struct function *fun)
   gcc_assert (fun && fun->gimple_df);
   return fun->gimple_df->nonlocal_all;
 }
+
+/* Hashtable of variables annotations.  Used for static variables only;
+   local variables have direct pointer in the tree node.  */
+static inline htab_t
+gimple_var_anns (struct function *fun)
+{
+  return fun->gimple_df->var_anns;
+}
+
 /* Initialize the hashtable iterator HTI to point to hashtable TABLE */
 
 static inline void *
@@ -194,6 +203,16 @@ var_ann (tree t)
   gcc_assert (t);
   gcc_assert (DECL_P (t));
   gcc_assert (TREE_CODE (t) != FUNCTION_DECL);
+  if (TREE_STATIC (t))
+    {
+      struct static_var_ann_d *sann
+        = ((struct static_var_ann_d *)
+          htab_find_with_hash (gimple_var_anns (cfun), t, DECL_UID (t)));
+      if (!sann)
+       return NULL;
+      gcc_assert (sann->ann.common.type = VAR_ANN);
+      return &sann->ann;
+    }
   gcc_assert (!t->base.ann
              || t->base.ann->common.type == VAR_ANN);
 
index 5f63ba93b01571cd8cbfe452dea7491e3c19ab81..8989c2f0a243b0678f588e629754b58e50298f8f 100644 (file)
@@ -38,6 +38,7 @@ typedef struct edge_def *edge;
 struct basic_block_def;
 typedef struct basic_block_def *basic_block;
 #endif
+struct static_var_ann_d;
 
 /* Gimple dataflow datastructure. All publicly available fields shall have
    gimple_ accessor defined in tree-flow-inline.h, all publicly modifiable
@@ -92,6 +93,10 @@ struct gimple_df GTY(()) {
   unsigned int in_ssa_p : 1;
 
   struct ssa_operands ssa_operands;
+
+  /* Hashtable of variables annotations.  Used for static variables only;
+     local variables have direct pointer in the tree node.  */
+  htab_t GTY((param_is (struct static_var_ann_d))) var_anns;
 };
 
 /* Accessors for internal use only.  Generic code should use abstraction
@@ -283,6 +288,14 @@ struct var_ann_d GTY(())
   unsigned int escape_mask;
 };
 
+/* Contianer for variable annotation used by hashtable for annotations for
+   static variables.  */
+struct static_var_ann_d GTY(())
+{
+  struct var_ann_d ann;
+  unsigned int uid;
+};
+
 struct function_ann_d GTY(())
 {
   struct tree_ann_common_d common;
index 8f34ce2b7fe12ec21ec71d0e4a5b0f55ee27eda1..2e4bcdbfe4402e6b95d5fc5b648e83cda341d587 100644 (file)
@@ -745,6 +745,24 @@ int_tree_map_hash (const void *item)
   return ((const struct int_tree_map *)item)->uid;
 }
 
+/* Return true if the uid in both int tree maps are equal.  */
+
+static int
+var_ann_eq (const void *va, const void *vb)
+{
+  const struct static_var_ann_d *a = (const struct static_var_ann_d *) va;
+  tree b = (tree) vb;
+  return (a->uid == DECL_UID (b));
+}
+
+/* Hash a UID in a int_tree_map.  */
+
+static unsigned int
+var_ann_hash (const void *item)
+{
+  return ((const struct static_var_ann_d *)item)->uid;
+}
+
 
 /* Initialize global DFA and SSA structures.  */
 
@@ -756,6 +774,8 @@ init_tree_ssa (void)
                                                      int_tree_map_eq, NULL);
   cfun->gimple_df->default_defs = htab_create_ggc (20, int_tree_map_hash, 
                                                   int_tree_map_eq, NULL);
+  cfun->gimple_df->var_anns = htab_create_ggc (20, var_ann_hash, 
+                                              var_ann_eq, NULL);
   cfun->gimple_df->call_clobbered_vars = BITMAP_GGC_ALLOC ();
   cfun->gimple_df->addressable_vars = BITMAP_GGC_ALLOC ();
   init_alias_heapvars ();
@@ -805,7 +825,8 @@ delete_tree_ssa (void)
   /* Remove annotations from every referenced variable.  */
   FOR_EACH_REFERENCED_VAR (var, rvi)
     {
-      ggc_free (var->base.ann);
+      if (var->base.ann)
+        ggc_free (var->base.ann);
       var->base.ann = NULL;
     }
   htab_delete (gimple_referenced_vars (cfun));
@@ -817,6 +838,9 @@ delete_tree_ssa (void)
   cfun->gimple_df->global_var = NULL_TREE;
   
   htab_delete (cfun->gimple_df->default_defs);
+  cfun->gimple_df->default_defs = NULL;
+  htab_delete (cfun->gimple_df->var_anns);
+  cfun->gimple_df->var_anns = NULL;
   cfun->gimple_df->call_clobbered_vars = NULL;
   cfun->gimple_df->addressable_vars = NULL;
   cfun->gimple_df->modified_noreturn_calls = NULL;
@@ -824,6 +848,7 @@ delete_tree_ssa (void)
 
   delete_alias_heapvars ();
   gcc_assert (!need_ssa_update_p ());
+  cfun->gimple_df = NULL;
 }