From af1430196a223b94fd0aeaf292d9ce22730f7e23 Mon Sep 17 00:00:00 2001 From: Martin Liska Date: Wed, 14 Mar 2018 12:17:01 +0100 Subject: [PATCH] Fix tree statistics with -fmem-report. 2018-03-14 Martin Liska * tree.c (record_node_allocation_statistics): Use get_stats_node_kind. (get_stats_node_kind): New function extracted from record_node_allocation_statistics. (free_node): Use get_stats_node_kind. From-SVN: r258521 --- gcc/ChangeLog | 8 +++++ gcc/tree.c | 94 +++++++++++++++++++++------------------------------ 2 files changed, 46 insertions(+), 56 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 480db486de8..104e44255e6 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2018-03-14 Martin Liska + + * tree.c (record_node_allocation_statistics): Use + get_stats_node_kind. + (get_stats_node_kind): New function extracted from + record_node_allocation_statistics. + (free_node): Use get_stats_node_kind. + 2018-03-14 Richard Biener * tree-ssa-pre.c (compute_antic_aux): Remove code that asserts diff --git a/gcc/tree.c b/gcc/tree.c index 1e1a1be1f20..ce52f0af0b7 100644 --- a/gcc/tree.c +++ b/gcc/tree.c @@ -933,92 +933,68 @@ tree_size (const_tree node) } } -/* Record interesting allocation statistics for a tree node with CODE - and LENGTH. */ +/* Return tree node kind based on tree CODE. */ -static void -record_node_allocation_statistics (enum tree_code code ATTRIBUTE_UNUSED, - size_t length ATTRIBUTE_UNUSED) +static tree_node_kind +get_stats_node_kind (enum tree_code code) { enum tree_code_class type = TREE_CODE_CLASS (code); - tree_node_kind kind; - - if (!GATHER_STATISTICS) - return; switch (type) { case tcc_declaration: /* A decl node */ - kind = d_kind; - break; - + return d_kind; case tcc_type: /* a type node */ - kind = t_kind; - break; - + return t_kind; case tcc_statement: /* an expression with side effects */ - kind = s_kind; - break; - + return s_kind; case tcc_reference: /* a reference */ - kind = r_kind; - break; - + return r_kind; case tcc_expression: /* an expression */ case tcc_comparison: /* a comparison expression */ case tcc_unary: /* a unary arithmetic expression */ case tcc_binary: /* a binary arithmetic expression */ - kind = e_kind; - break; - + return e_kind; case tcc_constant: /* a constant */ - kind = c_kind; - break; - + return c_kind; case tcc_exceptional: /* something random, like an identifier. */ switch (code) { case IDENTIFIER_NODE: - kind = id_kind; - break; - + return id_kind; case TREE_VEC: - kind = vec_kind; - break; - + return vec_kind; case TREE_BINFO: - kind = binfo_kind; - break; - + return binfo_kind; case SSA_NAME: - kind = ssa_name_kind; - break; - + return ssa_name_kind; case BLOCK: - kind = b_kind; - break; - + return b_kind; case CONSTRUCTOR: - kind = constr_kind; - break; - + return constr_kind; case OMP_CLAUSE: - kind = omp_clause_kind; - break; - + return omp_clause_kind; default: - kind = x_kind; - break; + return x_kind; } break; - case tcc_vl_exp: - kind = e_kind; - break; - + return e_kind; default: gcc_unreachable (); } +} + +/* Record interesting allocation statistics for a tree node with CODE + and LENGTH. */ + +static void +record_node_allocation_statistics (enum tree_code code, size_t length) +{ + if (!GATHER_STATISTICS) + return; + + tree_node_kind kind = get_stats_node_kind (code); tree_code_counts[(int) code]++; tree_node_counts[(int) kind]++; @@ -1157,9 +1133,15 @@ free_node (tree node) enum tree_code code = TREE_CODE (node); if (GATHER_STATISTICS) { + enum tree_node_kind kind = get_stats_node_kind (code); + + gcc_checking_assert (tree_code_counts[(int) TREE_CODE (node)] != 0); + gcc_checking_assert (tree_node_counts[(int) kind] != 0); + gcc_checking_assert (tree_node_sizes[(int) kind] >= tree_size (node)); + tree_code_counts[(int) TREE_CODE (node)]--; - tree_node_counts[(int) t_kind]--; - tree_node_sizes[(int) t_kind] -= tree_size (node); + tree_node_counts[(int) kind]--; + tree_node_sizes[(int) kind] -= tree_size (node); } if (CODE_CONTAINS_STRUCT (code, TS_CONSTRUCTOR)) vec_free (CONSTRUCTOR_ELTS (node)); -- 2.30.2