diff options
author | hubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4> | 2006-12-20 22:40:48 +0000 |
---|---|---|
committer | hubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4> | 2006-12-20 22:40:48 +0000 |
commit | f5ab006bf3e5e6f8e8036e036d8bd1b151c82f60 (patch) | |
tree | 43db620bf4a68210816d01661abe142a49165b70 /gcc | |
parent | 44753b5af6138f98260a844f11f88969abc33c05 (diff) | |
download | gcc-f5ab006bf3e5e6f8e8036e036d8bd1b151c82f60.tar.gz |
* 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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@120089 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 11 | ||||
-rw-r--r-- | gcc/tree-dfa.c | 21 | ||||
-rw-r--r-- | gcc/tree-flow-inline.h | 19 | ||||
-rw-r--r-- | gcc/tree-flow.h | 13 | ||||
-rw-r--r-- | gcc/tree-ssa.c | 27 |
5 files changed, 88 insertions, 3 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 42e4aa5edae..c4bcad1fa2c 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -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 diff --git a/gcc/tree-dfa.c b/gcc/tree-dfa.c index 0aabc80b7a7..5b9c72418b5 100644 --- a/gcc/tree-dfa.c +++ b/gcc/tree-dfa.c @@ -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; } diff --git a/gcc/tree-flow-inline.h b/gcc/tree-flow-inline.h index e2b4f979140..d87adc39112 100644 --- a/gcc/tree-flow-inline.h +++ b/gcc/tree-flow-inline.h @@ -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); diff --git a/gcc/tree-flow.h b/gcc/tree-flow.h index 5f63ba93b01..8989c2f0a24 100644 --- a/gcc/tree-flow.h +++ b/gcc/tree-flow.h @@ -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; diff --git a/gcc/tree-ssa.c b/gcc/tree-ssa.c index 8f34ce2b7fe..2e4bcdbfe44 100644 --- a/gcc/tree-ssa.c +++ b/gcc/tree-ssa.c @@ -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; } |