Commit af143019 by Martin Liska Committed by Martin Liska

Fix tree statistics with -fmem-report.

2018-03-14  Martin Liska  <mliska@suse.cz>

	* 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
parent 70458d76
2018-03-14 Martin Liska <mliska@suse.cz>
* 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 <rguenther@suse.de> 2018-03-14 Richard Biener <rguenther@suse.de>
* tree-ssa-pre.c (compute_antic_aux): Remove code that asserts * tree-ssa-pre.c (compute_antic_aux): Remove code that asserts
......
...@@ -933,92 +933,68 @@ tree_size (const_tree node) ...@@ -933,92 +933,68 @@ tree_size (const_tree node)
} }
} }
/* Record interesting allocation statistics for a tree node with CODE /* Return tree node kind based on tree CODE. */
and LENGTH. */
static void static tree_node_kind
record_node_allocation_statistics (enum tree_code code ATTRIBUTE_UNUSED, get_stats_node_kind (enum tree_code code)
size_t length ATTRIBUTE_UNUSED)
{ {
enum tree_code_class type = TREE_CODE_CLASS (code); enum tree_code_class type = TREE_CODE_CLASS (code);
tree_node_kind kind;
if (!GATHER_STATISTICS)
return;
switch (type) switch (type)
{ {
case tcc_declaration: /* A decl node */ case tcc_declaration: /* A decl node */
kind = d_kind; return d_kind;
break;
case tcc_type: /* a type node */ case tcc_type: /* a type node */
kind = t_kind; return t_kind;
break;
case tcc_statement: /* an expression with side effects */ case tcc_statement: /* an expression with side effects */
kind = s_kind; return s_kind;
break;
case tcc_reference: /* a reference */ case tcc_reference: /* a reference */
kind = r_kind; return r_kind;
break;
case tcc_expression: /* an expression */ case tcc_expression: /* an expression */
case tcc_comparison: /* a comparison expression */ case tcc_comparison: /* a comparison expression */
case tcc_unary: /* a unary arithmetic expression */ case tcc_unary: /* a unary arithmetic expression */
case tcc_binary: /* a binary arithmetic expression */ case tcc_binary: /* a binary arithmetic expression */
kind = e_kind; return e_kind;
break;
case tcc_constant: /* a constant */ case tcc_constant: /* a constant */
kind = c_kind; return c_kind;
break;
case tcc_exceptional: /* something random, like an identifier. */ case tcc_exceptional: /* something random, like an identifier. */
switch (code) switch (code)
{ {
case IDENTIFIER_NODE: case IDENTIFIER_NODE:
kind = id_kind; return id_kind;
break;
case TREE_VEC: case TREE_VEC:
kind = vec_kind; return vec_kind;
break;
case TREE_BINFO: case TREE_BINFO:
kind = binfo_kind; return binfo_kind;
break;
case SSA_NAME: case SSA_NAME:
kind = ssa_name_kind; return ssa_name_kind;
break;
case BLOCK: case BLOCK:
kind = b_kind; return b_kind;
break;
case CONSTRUCTOR: case CONSTRUCTOR:
kind = constr_kind; return constr_kind;
break;
case OMP_CLAUSE: case OMP_CLAUSE:
kind = omp_clause_kind; return omp_clause_kind;
break;
default: default:
kind = x_kind; return x_kind;
break;
} }
break; break;
case tcc_vl_exp: case tcc_vl_exp:
kind = e_kind; return e_kind;
break;
default: default:
gcc_unreachable (); 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_code_counts[(int) code]++;
tree_node_counts[(int) kind]++; tree_node_counts[(int) kind]++;
...@@ -1157,9 +1133,15 @@ free_node (tree node) ...@@ -1157,9 +1133,15 @@ free_node (tree node)
enum tree_code code = TREE_CODE (node); enum tree_code code = TREE_CODE (node);
if (GATHER_STATISTICS) 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_code_counts[(int) TREE_CODE (node)]--;
tree_node_counts[(int) t_kind]--; tree_node_counts[(int) kind]--;
tree_node_sizes[(int) t_kind] -= tree_size (node); tree_node_sizes[(int) kind] -= tree_size (node);
} }
if (CODE_CONTAINS_STRUCT (code, TS_CONSTRUCTOR)) if (CODE_CONTAINS_STRUCT (code, TS_CONSTRUCTOR))
vec_free (CONSTRUCTOR_ELTS (node)); vec_free (CONSTRUCTOR_ELTS (node));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment