From deb3dae698b52152c56ec9e271e015f7547d2468 Mon Sep 17 00:00:00 2001 From: Jan Hubicka Date: Tue, 24 Nov 2015 20:04:04 +0100 Subject: [PATCH] tree.c (free_node): New function. * tree.c (free_node): New function. (type_hash_canon): Use it. * tree.h (free_node): Declare. * lto.c (unify_scc): Use free_node. From-SVN: r230833 --- gcc/ChangeLog | 6 ++++++ gcc/lto/ChangeLog | 4 ++++ gcc/lto/lto.c | 6 +----- gcc/tree.c | 28 ++++++++++++++++++++++------ gcc/tree.h | 4 ++++ 5 files changed, 37 insertions(+), 11 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 56e5e6d226a..d4db20a700e 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2015-11-24 Jan Hubicka + + * tree.c (free_node): New function. + (type_hash_canon): Use it. + * tree.h (free_node): Declare. + 2015-11-24 David Edelsohn Michael Meissner diff --git a/gcc/lto/ChangeLog b/gcc/lto/ChangeLog index 410533710ae..9d6b12640c6 100644 --- a/gcc/lto/ChangeLog +++ b/gcc/lto/ChangeLog @@ -1,3 +1,7 @@ +2015-11-24 Jan Hubicka + + * lto.c (unify_scc): Use free_node. + 2015-11-21 Jan Hubicka * lto.c (iterative_hash_canonical_type): Always recurse for pointers. diff --git a/gcc/lto/lto.c b/gcc/lto/lto.c index 26614912e3b..c4c51588adc 100644 --- a/gcc/lto/lto.c +++ b/gcc/lto/lto.c @@ -1623,13 +1623,9 @@ unify_scc (struct data_in *data_in, unsigned from, data_in->location_cache.revert_location_cache (); for (unsigned i = 0; i < len; ++i) { - enum tree_code code; if (TYPE_P (scc->entries[i])) num_merged_types++; - code = TREE_CODE (scc->entries[i]); - if (CODE_CONTAINS_STRUCT (code, TS_CONSTRUCTOR)) - vec_free (CONSTRUCTOR_ELTS (scc->entries[i])); - ggc_free (scc->entries[i]); + free_node (scc->entries[i]); } break; diff --git a/gcc/tree.c b/gcc/tree.c index 779fe9386a2..2888657fe04 100644 --- a/gcc/tree.c +++ b/gcc/tree.c @@ -1103,6 +1103,27 @@ make_node_stat (enum tree_code code MEM_STAT_DECL) return t; } + +/* Free tree node. */ + +void +free_node (tree node) +{ + enum tree_code code = TREE_CODE (node); + if (GATHER_STATISTICS) + { + tree_code_counts[(int) TREE_CODE (node)]--; + tree_node_counts[(int) t_kind]--; + tree_node_sizes[(int) t_kind] -= tree_code_size (TREE_CODE (node)); + } + if (CODE_CONTAINS_STRUCT (code, TS_CONSTRUCTOR)) + vec_free (CONSTRUCTOR_ELTS (node)); + else if (code == BLOCK) + vec_free (BLOCK_NONLOCALIZED_VARS (node)); + else if (code == TREE_BINFO) + vec_free (BINFO_BASE_ACCESSES (node)); + ggc_free (node); +} /* Return a new node with the same contents as NODE except that its TREE_CHAIN, if it has one, is zero and it has a fresh uid. */ @@ -7100,12 +7121,7 @@ type_hash_canon (unsigned int hashcode, tree type) { tree t1 = ((type_hash *) *loc)->type; gcc_assert (TYPE_MAIN_VARIANT (t1) == t1); - if (GATHER_STATISTICS) - { - tree_code_counts[(int) TREE_CODE (type)]--; - tree_node_counts[(int) t_kind]--; - tree_node_sizes[(int) t_kind] -= sizeof (struct tree_type_non_common); - } + free_node (type); return t1; } else diff --git a/gcc/tree.h b/gcc/tree.h index cb52debc3d1..6c733aa5e4c 100644 --- a/gcc/tree.h +++ b/gcc/tree.h @@ -3763,6 +3763,10 @@ extern int allocate_decl_uid (void); extern tree make_node_stat (enum tree_code MEM_STAT_DECL); #define make_node(t) make_node_stat (t MEM_STAT_INFO) +/* Free tree node. */ + +extern void free_node (tree); + /* Make a copy of a node, with all the same contents. */ extern tree copy_node_stat (tree MEM_STAT_DECL); -- 2.30.2