From 40ce7fa6dd38f8ac26d576c84f5dbe4362aa902b Mon Sep 17 00:00:00 2001 From: Martin Liska Date: Mon, 5 Nov 2018 14:36:29 +0100 Subject: Come up with SIZE_AMOUNT and use it in memory statistics and sort stats. 2018-11-05 Martin Liska * alloc-pool.h (struct pool_usage): Use SIZE_AMOUNT. * bitmap.h (struct bitmap_usage): Likewise. * ggc-common.c (SCALE): Remove. (LABEL): Likewise. (struct ggc_usage): Use SIZE_AMOUNT. And update compare method. * ggc-page.c (SCALE): Remove. (STAT_LABEL): Remove. (ggc_print_statistics): Use SIZE_AMOUNT. * gimple.h (SCALE): Remove. (LABEL): Likewise. * input.c (ONE_K): Remove. (ONE_M): Likewise. (SCALE): Likewise. (STAT_LABEL): Likewise. (FORMAT_AMOUNT): Likewise. (dump_line_table_statistics): Use SIZE_AMOUNT. * mem-stats.h (struct mem_usage): Likewise. * rtl.c (dump_rtx_statistics): Likewise. (rtx_alloc_counts): Change type to size_t. (rtx_alloc_sizes): Likewise. (rtx_count_cmp): New. (dump_rtx_statistics): Sort first based on counts. * tree.c (tree_nodes_cmp): New. (tree_codes_cmp): New. (dump_tree_statistics): Sort first based on counts. * system.h (ONE_K): New. (ONE_M): Likewise. (SIZE_SCALE): Likewise. (SIZE_LABEL): Likewise. (SIZE_AMOUNT): Likewise. * tree-cfg.c (dump_cfg_stats): Use SIZE_AMOUNT. * tree-dfa.c (dump_dfa_stats): Likewise. * tree-phinodes.c (phinodes_print_statistics): Likewise. * tree-ssanames.c (ssanames_print_statistics): Likewise. * tree.c (dump_tree_statistics): Likewise. * vec.c (struct vec_usage): Likewise. * trans-mem.c (tm_mangle): Enlarge buffer in order to not trigger a -Werror=format-overflow with --enable-gather-detailed-stats. From-SVN: r265800 --- gcc/input.c | 75 ++++++++++++++++--------------------------------------------- 1 file changed, 19 insertions(+), 56 deletions(-) (limited to 'gcc/input.c') diff --git a/gcc/input.c b/gcc/input.c index a94a010..9fb6e72 100644 --- a/gcc/input.c +++ b/gcc/input.c @@ -905,31 +905,6 @@ make_location (location_t caret, source_range src_range) return COMBINE_LOCATION_DATA (line_table, pure_loc, src_range, NULL); } -#define ONE_K 1024 -#define ONE_M (ONE_K * ONE_K) - -/* Display a number as an integer multiple of either: - - 1024, if said integer is >= to 10 K (in base 2) - - 1024 * 1024, if said integer is >= 10 M in (base 2) - */ -#define SCALE(x) ((unsigned long) ((x) < 10 * ONE_K \ - ? (x) \ - : ((x) < 10 * ONE_M \ - ? (x) / ONE_K \ - : (x) / ONE_M))) - -/* For a given integer, display either: - - the character 'k', if the number is higher than 10 K (in base 2) - but strictly lower than 10 M (in base 2) - - the character 'M' if the number is higher than 10 M (in base2) - - the charcter ' ' if the number is strictly lower than 10 K */ -#define STAT_LABEL(x) ((x) < 10 * ONE_K ? ' ' : ((x) < 10 * ONE_M ? 'k' : 'M')) - -/* Display an integer amount as multiple of 1K or 1M (in base 2). - Display the correct unit (either k, M, or ' ') after the amount, as - well. */ -#define FORMAT_AMOUNT(size) SCALE (size), STAT_LABEL (size) - /* Dump statistics to stderr about the memory usage of the line_table set of line maps. This also displays some statistics about macro expansion. */ @@ -964,49 +939,37 @@ dump_line_table_statistics (void) s.num_macro_tokens / s.num_expanded_macros); fprintf (stderr, "\nLine Table allocations during the " - "compilation process\n"); + "compilation process\n"); fprintf (stderr, "Number of ordinary maps used: %5ld%c\n", - SCALE (s.num_ordinary_maps_used), - STAT_LABEL (s.num_ordinary_maps_used)); + SIZE_AMOUNT (s.num_ordinary_maps_used)); fprintf (stderr, "Ordinary map used size: %5ld%c\n", - SCALE (s.ordinary_maps_used_size), - STAT_LABEL (s.ordinary_maps_used_size)); + SIZE_AMOUNT (s.ordinary_maps_used_size)); fprintf (stderr, "Number of ordinary maps allocated: %5ld%c\n", - SCALE (s.num_ordinary_maps_allocated), - STAT_LABEL (s.num_ordinary_maps_allocated)); + SIZE_AMOUNT (s.num_ordinary_maps_allocated)); fprintf (stderr, "Ordinary maps allocated size: %5ld%c\n", - SCALE (s.ordinary_maps_allocated_size), - STAT_LABEL (s.ordinary_maps_allocated_size)); + SIZE_AMOUNT (s.ordinary_maps_allocated_size)); fprintf (stderr, "Number of macro maps used: %5ld%c\n", - SCALE (s.num_macro_maps_used), - STAT_LABEL (s.num_macro_maps_used)); + SIZE_AMOUNT (s.num_macro_maps_used)); fprintf (stderr, "Macro maps used size: %5ld%c\n", - SCALE (s.macro_maps_used_size), - STAT_LABEL (s.macro_maps_used_size)); + SIZE_AMOUNT (s.macro_maps_used_size)); fprintf (stderr, "Macro maps locations size: %5ld%c\n", - SCALE (s.macro_maps_locations_size), - STAT_LABEL (s.macro_maps_locations_size)); + SIZE_AMOUNT (s.macro_maps_locations_size)); fprintf (stderr, "Macro maps size: %5ld%c\n", - SCALE (macro_maps_size), - STAT_LABEL (macro_maps_size)); + SIZE_AMOUNT (macro_maps_size)); fprintf (stderr, "Duplicated maps locations size: %5ld%c\n", - SCALE (s.duplicated_macro_maps_locations_size), - STAT_LABEL (s.duplicated_macro_maps_locations_size)); + SIZE_AMOUNT (s.duplicated_macro_maps_locations_size)); fprintf (stderr, "Total allocated maps size: %5ld%c\n", - SCALE (total_allocated_map_size), - STAT_LABEL (total_allocated_map_size)); + SIZE_AMOUNT (total_allocated_map_size)); fprintf (stderr, "Total used maps size: %5ld%c\n", - SCALE (total_used_map_size), - STAT_LABEL (total_used_map_size)); + SIZE_AMOUNT (total_used_map_size)); fprintf (stderr, "Ad-hoc table size: %5ld%c\n", - SCALE (s.adhoc_table_size), - STAT_LABEL (s.adhoc_table_size)); - fprintf (stderr, "Ad-hoc table entries used: %5ld\n", - s.adhoc_table_entries_used); - fprintf (stderr, "optimized_ranges: %i\n", - line_table->num_optimized_ranges); - fprintf (stderr, "unoptimized_ranges: %i\n", - line_table->num_unoptimized_ranges); + SIZE_AMOUNT (s.adhoc_table_size)); + fprintf (stderr, "Ad-hoc table entries used: %5ld%c\n", + SIZE_AMOUNT (s.adhoc_table_entries_used)); + fprintf (stderr, "optimized_ranges: %5xu%c\n", + SIZE_AMOUNT (line_table->num_optimized_ranges)); + fprintf (stderr, "unoptimized_ranges: %5xu%c\n", + SIZE_AMOUNT (line_table->num_unoptimized_ranges)); fprintf (stderr, "\n"); } -- cgit v1.1