From a0b48080020f344b3d594f31546c714564a061c7 Mon Sep 17 00:00:00 2001 From: Michael Matz Date: Fri, 16 Nov 2018 13:39:18 +0000 Subject: [PATCH] Don't use %z printf length specifier * system.h (PRsa): New macro. (SIZE_AMOUNT): Cast number to uint64_t. * alloc-pool.h (pool_usage::dump): Don't use %zu but PRsa. (pool_usage::dump_footer): Likewise and also use PRIu64. * bitmap.h (bitmap_usage::dump): Likewise. * ggc-common.c (ggc_usage::dump): Likewise. * ggc-page.c (ggc_print_statistics): Likewise. * input.c (dump_line_table_statistics): Likewise. * mem-stats.h (mem_usage::dump): Likewise. (mem_usage::dump_footer): Likewise. * rtl.c (dump_rtx_statistics): Likewise. * tree-cfg.c (dump_cfg_stats): Likewise. * tree-dfa.c (dump_dfa_stats): Likewise. * tree-phinodes.c (phinodes_print_statistics): Likewise. * tree-ssanames (ssanames_print_statistics): Likewise. * vec.c (vec_usage::dump): Likewise. (vec_usage::dump_footer): Likewise. From-SVN: r266208 --- gcc/ChangeLog | 30 +++++++++++++++++++++----- gcc/alloc-pool.h | 8 +++---- gcc/bitmap.h | 6 +++--- gcc/ggc-common.c | 4 ++-- gcc/ggc-page.c | 51 +++++++++++++++++++++++---------------------- gcc/input.c | 30 +++++++++++++------------- gcc/mem-stats.h | 6 +++--- gcc/rtl.c | 6 +++--- gcc/system.h | 6 +++++- gcc/tree-cfg.c | 6 +++--- gcc/tree-dfa.c | 4 ++-- gcc/tree-phinodes.c | 5 +++-- gcc/tree-ssanames.c | 4 ++-- gcc/vec.c | 10 ++++----- 14 files changed, 101 insertions(+), 75 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 3f7e443e57d..07cdcc75bd8 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,23 @@ +2018-11-16 Michael Matz + + * system.h (PRsa): New macro. + (SIZE_AMOUNT): Cast number to uint64_t. + * alloc-pool.h (pool_usage::dump): Don't use %zu but PRsa. + (pool_usage::dump_footer): Likewise and also use PRIu64. + * bitmap.h (bitmap_usage::dump): Likewise. + * ggc-common.c (ggc_usage::dump): Likewise. + * ggc-page.c (ggc_print_statistics): Likewise. + * input.c (dump_line_table_statistics): Likewise. + * mem-stats.h (mem_usage::dump): Likewise. + (mem_usage::dump_footer): Likewise. + * rtl.c (dump_rtx_statistics): Likewise. + * tree-cfg.c (dump_cfg_stats): Likewise. + * tree-dfa.c (dump_dfa_stats): Likewise. + * tree-phinodes.c (phinodes_print_statistics): Likewise. + * tree-ssanames (ssanames_print_statistics): Likewise. + * vec.c (vec_usage::dump): Likewise. + (vec_usage::dump_footer): Likewise. + 2018-11-16 Richard Biener PR tree-optimization/88011 @@ -40,7 +60,7 @@ (alloc_size, nonnull, sentinel): Same. 2018-11-15 Andrew Stubbs - Kwok Cheung Yeung + Kwok Cheung Yeung * tree-vect-stmts.c (vectorizable_store): Don't ICE when int_mode_for_size fails. @@ -91,10 +111,10 @@ 2018-11-15 Richard Biener - PR middle-end/88029 - * gimple.c (gimple_call_flags): Union flags from decl, type - and call fntype. - * trans-mem.c (is_tm_pure_call): Simplify. + PR middle-end/88029 + * gimple.c (gimple_call_flags): Union flags from decl, type + and call fntype. + * trans-mem.c (is_tm_pure_call): Simplify. 2018-11-15 Richard Biener diff --git a/gcc/alloc-pool.h b/gcc/alloc-pool.h index d17a05ca4fb..81cb69e227a 100644 --- a/gcc/alloc-pool.h +++ b/gcc/alloc-pool.h @@ -63,8 +63,8 @@ struct pool_usage: public mem_usage { char *location_string = loc->to_string (); - fprintf (stderr, "%-32s%-48s %5zu%c%9zu%c:%5.1f%%%9zu" - "%c%9zu%c:%5.1f%%%12zu\n", + fprintf (stderr, "%-32s%-48s " PRsa(5) PRsa(9) ":%5.1f%%" + PRsa(9) PRsa(9) ":%5.1f%%%12" PRIu64 "\n", m_pool_name, location_string, SIZE_AMOUNT (m_instances), SIZE_AMOUNT (m_allocated), @@ -72,7 +72,7 @@ struct pool_usage: public mem_usage SIZE_AMOUNT (m_peak), SIZE_AMOUNT (m_times), get_percent (m_times, total.m_times), - m_element_size); + (uint64_t)m_element_size); free (location_string); } @@ -91,7 +91,7 @@ struct pool_usage: public mem_usage dump_footer () { print_dash_line (); - fprintf (stderr, "%s%82zu%c%10zu%c\n", "Total", + fprintf (stderr, "%s" PRsa(82) PRsa(10) "\n", "Total", SIZE_AMOUNT (m_instances), SIZE_AMOUNT (m_allocated)); print_dash_line (); } diff --git a/gcc/bitmap.h b/gcc/bitmap.h index 973ea846baf..9a180daa745 100644 --- a/gcc/bitmap.h +++ b/gcc/bitmap.h @@ -239,9 +239,9 @@ struct bitmap_usage: public mem_usage { char *location_string = loc->to_string (); - fprintf (stderr, "%-48s %9zu%c:%5.1f%%" - "%9zu%c%9zu%c:%5.1f%%" - "%11" PRIu64 "%c%11" PRIu64 "%c%10s\n", + fprintf (stderr, "%-48s " PRsa (9) ":%5.1f%%" + PRsa (9) PRsa (9) ":%5.1f%%" + PRsa (11) PRsa (11) "%10s\n", location_string, SIZE_AMOUNT (m_allocated), get_percent (m_allocated, total.m_allocated), SIZE_AMOUNT (m_peak), SIZE_AMOUNT (m_times), diff --git a/gcc/ggc-common.c b/gcc/ggc-common.c index 9fdba23ce4c..c989fb01e66 100644 --- a/gcc/ggc-common.c +++ b/gcc/ggc-common.c @@ -884,8 +884,8 @@ struct ggc_usage: public mem_usage { size_t balance = get_balance (); fprintf (stderr, - "%-48s %9zu%c:%5.1f%%%9zu%c:%5.1f%%" - "%9zu%c:%5.1f%%%9zu%c:%5.1f%%%9zu%c\n", + "%-48s " PRsa (9) ":%5.1f%%" PRsa (9) ":%5.1f%%" + PRsa (9) ":%5.1f%%" PRsa (9) ":%5.1f%%" PRsa (9) "\n", prefix, SIZE_AMOUNT (m_collected), get_percent (m_collected, total.m_collected), SIZE_AMOUNT (m_freed), get_percent (m_freed, total.m_freed), diff --git a/gcc/ggc-page.c b/gcc/ggc-page.c index 00c2864711f..f04b22ca8cc 100644 --- a/gcc/ggc-page.c +++ b/gcc/ggc-page.c @@ -2288,14 +2288,15 @@ ggc_print_statistics (void) overhead += (sizeof (page_entry) - sizeof (long) + BITMAP_SIZE (OBJECTS_IN_PAGE (p) + 1)); } - fprintf (stderr, "%-8zu %10zu%c %10zu%c %10zu%c\n", - OBJECT_SIZE (i), + fprintf (stderr, "%-8" PRIu64 " " PRsa (10) " " PRsa (10) " " + PRsa (10) "\n", + (uint64_t)OBJECT_SIZE (i), SIZE_AMOUNT (allocated), SIZE_AMOUNT (in_use), SIZE_AMOUNT (overhead)); total_overhead += overhead; } - fprintf (stderr, "%-8s %10zu%c %10zu%c %10zu%c\n", + fprintf (stderr, "%-8s " PRsa (10) " " PRsa (10) " " PRsa (10) "\n", "Total", SIZE_AMOUNT (G.bytes_mapped), SIZE_AMOUNT (G.allocated), @@ -2306,42 +2307,42 @@ ggc_print_statistics (void) fprintf (stderr, "\nTotal allocations and overheads during " "the compilation process\n"); - fprintf (stderr, "Total Overhead: %9" - HOST_LONG_LONG_FORMAT "d%c\n", + fprintf (stderr, "Total Overhead: " + PRsa (9) "\n", SIZE_AMOUNT (G.stats.total_overhead)); - fprintf (stderr, "Total Allocated: %9" - HOST_LONG_LONG_FORMAT "d%c\n", + fprintf (stderr, "Total Allocated: " + PRsa (9) "\n", SIZE_AMOUNT (G.stats.total_allocated)); - fprintf (stderr, "Total Overhead under 32B: %9" - HOST_LONG_LONG_FORMAT "d%c\n", + fprintf (stderr, "Total Overhead under 32B: " + PRsa (9) "\n", SIZE_AMOUNT (G.stats.total_overhead_under32)); - fprintf (stderr, "Total Allocated under 32B: %9" - HOST_LONG_LONG_FORMAT "d%c\n", + fprintf (stderr, "Total Allocated under 32B: " + PRsa (9) "\n", SIZE_AMOUNT (G.stats.total_allocated_under32)); - fprintf (stderr, "Total Overhead under 64B: %9" - HOST_LONG_LONG_FORMAT "d%c\n", + fprintf (stderr, "Total Overhead under 64B: " + PRsa (9) "\n", SIZE_AMOUNT (G.stats.total_overhead_under64)); - fprintf (stderr, "Total Allocated under 64B: %9" - HOST_LONG_LONG_FORMAT "d%c\n", + fprintf (stderr, "Total Allocated under 64B: " + PRsa (9) "\n", SIZE_AMOUNT (G.stats.total_allocated_under64)); - fprintf (stderr, "Total Overhead under 128B: %9" - HOST_LONG_LONG_FORMAT "d%c\n", + fprintf (stderr, "Total Overhead under 128B: " + PRsa (9) "\n", SIZE_AMOUNT (G.stats.total_overhead_under128)); - fprintf (stderr, "Total Allocated under 128B: %9" - HOST_LONG_LONG_FORMAT "d%c\n", + fprintf (stderr, "Total Allocated under 128B: " + PRsa (9) "\n", SIZE_AMOUNT (G.stats.total_allocated_under128)); for (i = 0; i < NUM_ORDERS; i++) if (G.stats.total_allocated_per_order[i]) { - fprintf (stderr, "Total Overhead page size %9zu: %9" - HOST_LONG_LONG_FORMAT "d%c\n", - OBJECT_SIZE (i), + fprintf (stderr, "Total Overhead page size %9" PRIu64 ": " + PRsa (9) "\n", + (uint64_t)OBJECT_SIZE (i), SIZE_AMOUNT (G.stats.total_overhead_per_order[i])); - fprintf (stderr, "Total Allocated page size %9zu: %9" - HOST_LONG_LONG_FORMAT "d%c\n", - OBJECT_SIZE (i), + fprintf (stderr, "Total Allocated page size %9" PRIu64 ": " + PRsa (9) "\n", + (uint64_t)OBJECT_SIZE (i), SIZE_AMOUNT (G.stats.total_allocated_per_order[i])); } } diff --git a/gcc/input.c b/gcc/input.c index 347122e98a8..237c0d58f07 100644 --- a/gcc/input.c +++ b/gcc/input.c @@ -940,35 +940,35 @@ dump_line_table_statistics (void) fprintf (stderr, "\nLine Table allocations during the " "compilation process\n"); - fprintf (stderr, "Number of ordinary maps used: %5ld%c\n", + fprintf (stderr, "Number of ordinary maps used: " PRsa (5) "\n", SIZE_AMOUNT (s.num_ordinary_maps_used)); - fprintf (stderr, "Ordinary map used size: %5ld%c\n", + fprintf (stderr, "Ordinary map used size: " PRsa (5) "\n", SIZE_AMOUNT (s.ordinary_maps_used_size)); - fprintf (stderr, "Number of ordinary maps allocated: %5ld%c\n", + fprintf (stderr, "Number of ordinary maps allocated: " PRsa (5) "\n", SIZE_AMOUNT (s.num_ordinary_maps_allocated)); - fprintf (stderr, "Ordinary maps allocated size: %5ld%c\n", + fprintf (stderr, "Ordinary maps allocated size: " PRsa (5) "\n", SIZE_AMOUNT (s.ordinary_maps_allocated_size)); - fprintf (stderr, "Number of macro maps used: %5ld%c\n", + fprintf (stderr, "Number of macro maps used: " PRsa (5) "\n", SIZE_AMOUNT (s.num_macro_maps_used)); - fprintf (stderr, "Macro maps used size: %5ld%c\n", + fprintf (stderr, "Macro maps used size: " PRsa (5) "\n", SIZE_AMOUNT (s.macro_maps_used_size)); - fprintf (stderr, "Macro maps locations size: %5ld%c\n", + fprintf (stderr, "Macro maps locations size: " PRsa (5) "\n", SIZE_AMOUNT (s.macro_maps_locations_size)); - fprintf (stderr, "Macro maps size: %5ld%c\n", + fprintf (stderr, "Macro maps size: " PRsa (5) "\n", SIZE_AMOUNT (macro_maps_size)); - fprintf (stderr, "Duplicated maps locations size: %5ld%c\n", + fprintf (stderr, "Duplicated maps locations size: " PRsa (5) "\n", SIZE_AMOUNT (s.duplicated_macro_maps_locations_size)); - fprintf (stderr, "Total allocated maps size: %5ld%c\n", + fprintf (stderr, "Total allocated maps size: " PRsa (5) "\n", SIZE_AMOUNT (total_allocated_map_size)); - fprintf (stderr, "Total used maps size: %5ld%c\n", + fprintf (stderr, "Total used maps size: " PRsa (5) "\n", SIZE_AMOUNT (total_used_map_size)); - fprintf (stderr, "Ad-hoc table size: %5ld%c\n", + fprintf (stderr, "Ad-hoc table size: " PRsa (5) "\n", SIZE_AMOUNT (s.adhoc_table_size)); - fprintf (stderr, "Ad-hoc table entries used: %5ld%c\n", + fprintf (stderr, "Ad-hoc table entries used: " PRsa (5) "\n", SIZE_AMOUNT (s.adhoc_table_entries_used)); - fprintf (stderr, "optimized_ranges: %5xu%c\n", + fprintf (stderr, "optimized_ranges: " PRsa (5) "\n", SIZE_AMOUNT (line_table->num_optimized_ranges)); - fprintf (stderr, "unoptimized_ranges: %5xu%c\n", + fprintf (stderr, "unoptimized_ranges: " PRsa (5) "\n", SIZE_AMOUNT (line_table->num_unoptimized_ranges)); fprintf (stderr, "\n"); diff --git a/gcc/mem-stats.h b/gcc/mem-stats.h index 6ab92211cf4..219959faa99 100644 --- a/gcc/mem-stats.h +++ b/gcc/mem-stats.h @@ -205,8 +205,8 @@ struct mem_usage { char *location_string = loc->to_string (); - fprintf (stderr, "%-48s %9zu%c:%5.1f%%" - "%9zu%c%9zu%c:%5.1f%%%10s\n", + fprintf (stderr, "%-48s " PRsa (9) ":%5.1f%%" + PRsa (9) PRsa (9) ":%5.1f%%%10s\n", location_string, SIZE_AMOUNT (m_allocated), get_percent (m_allocated, total.m_allocated), SIZE_AMOUNT (m_peak), SIZE_AMOUNT (m_times), @@ -220,7 +220,7 @@ struct mem_usage dump_footer () const { print_dash_line (); - fprintf (stderr, "%s%53zu%c%26zu%c\n", "Total", + fprintf (stderr, "%s" PRsa (53) PRsa (26) "\n", "Total", SIZE_AMOUNT (m_allocated), SIZE_AMOUNT (m_times)); print_dash_line (); } diff --git a/gcc/rtl.c b/gcc/rtl.c index bf897bf75b4..2ab349981d9 100644 --- a/gcc/rtl.c +++ b/gcc/rtl.c @@ -821,7 +821,7 @@ dump_rtx_statistics (void) unsigned j = indices[i]; if (rtx_alloc_counts[j]) { - fprintf (stderr, "%-24s %6zu%c %9zu%c\n", + fprintf (stderr, "%-24s " PRsa (6) " " PRsa (9) "\n", GET_RTX_NAME (j), SIZE_AMOUNT (rtx_alloc_counts[j]), SIZE_AMOUNT (rtx_alloc_sizes[j])); @@ -832,14 +832,14 @@ dump_rtx_statistics (void) if (rtvec_alloc_counts) { - fprintf (stderr, "%-24s %6zu%c %9zu%c\n", "rtvec", + fprintf (stderr, "%-24s " PRsa (6) " " PRsa (9) "\n", "rtvec", SIZE_AMOUNT (rtvec_alloc_counts), SIZE_AMOUNT (rtvec_alloc_sizes)); total_counts += rtvec_alloc_counts; total_sizes += rtvec_alloc_sizes; } fprintf (stderr, "-----------------------------------------------\n"); - fprintf (stderr, "%-24s %6d%c %9d%c\n", + fprintf (stderr, "%-24s " PRsa (6) " " PRsa (9) "\n", "Total", SIZE_AMOUNT (total_counts), SIZE_AMOUNT (total_sizes)); fprintf (stderr, "-----------------------------------------------\n"); diff --git a/gcc/system.h b/gcc/system.h index ba328213a69..d23300f5e5d 100644 --- a/gcc/system.h +++ b/gcc/system.h @@ -1231,6 +1231,10 @@ void gcc_stablesort (void *, size_t, size_t, /* 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 SIZE_AMOUNT(size) SIZE_SCALE (size), SIZE_LABEL (size) +#define SIZE_AMOUNT(size) (uint64_t)SIZE_SCALE (size), SIZE_LABEL (size) + +/* Format string particle for printing a SIZE_AMOUNT with N being the width + of the number. */ +#define PRsa(n) "%" #n PRIu64 "%c" #endif /* ! GCC_SYSTEM_H */ diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c index 582cf18ad0d..be0ba870c0e 100644 --- a/gcc/tree-cfg.c +++ b/gcc/tree-cfg.c @@ -2569,9 +2569,9 @@ dump_cfg_stats (FILE *file) long num_edges; basic_block bb; const char * const fmt_str = "%-30s%-13s%12s\n"; - const char * const fmt_str_1 = "%-30s%13d%11lu%c\n"; - const char * const fmt_str_2 = "%-30s%13ld%11lu%c\n"; - const char * const fmt_str_3 = "%-43s%11lu%c\n"; + const char * const fmt_str_1 = "%-30s%13d" PRsa (11) "\n"; + const char * const fmt_str_2 = "%-30s%13ld" PRsa (11) "\n"; + const char * const fmt_str_3 = "%-43s" PRsa (11) "\n"; const char *funcname = current_function_name (); fprintf (file, "\nCFG Statistics for %s\n\n", funcname); diff --git a/gcc/tree-dfa.c b/gcc/tree-dfa.c index ad49c878f64..798a315dbb7 100644 --- a/gcc/tree-dfa.c +++ b/gcc/tree-dfa.c @@ -184,8 +184,8 @@ dump_dfa_stats (FILE *file) unsigned long size, total = 0; const char * const fmt_str = "%-30s%-13s%12s\n"; - const char * const fmt_str_1 = "%-30s%13lu%11lu%c\n"; - const char * const fmt_str_3 = "%-43s%11lu%c\n"; + const char * const fmt_str_1 = "%-30s%13lu" PRsa (11) "\n"; + const char * const fmt_str_3 = "%-43s" PRsa (11) "\n"; const char *funcname = lang_hooks.decl_printable_name (current_function_decl, 2); diff --git a/gcc/tree-phinodes.c b/gcc/tree-phinodes.c index 16dcf67e2f0..8f42727526a 100644 --- a/gcc/tree-phinodes.c +++ b/gcc/tree-phinodes.c @@ -80,9 +80,10 @@ unsigned int phi_nodes_created; void phinodes_print_statistics (void) { - fprintf (stderr, "PHI nodes allocated: %u%c\n", + fprintf (stderr, "PHI nodes allocated: " PRsa (11) "\n", SIZE_AMOUNT (phi_nodes_created)); - fprintf (stderr, "PHI nodes reused: %u%c\n", SIZE_AMOUNT (phi_nodes_reused)); + fprintf (stderr, "PHI nodes reused: " PRsa (11) "\n", + SIZE_AMOUNT (phi_nodes_reused)); } /* Allocate a PHI node with at least LEN arguments. If the free list diff --git a/gcc/tree-ssanames.c b/gcc/tree-ssanames.c index 702b7db3ccc..24f647af8b9 100644 --- a/gcc/tree-ssanames.c +++ b/gcc/tree-ssanames.c @@ -112,9 +112,9 @@ fini_ssanames (struct function *fn) void ssanames_print_statistics (void) { - fprintf (stderr, "SSA_NAME nodes allocated: %u%c\n", + fprintf (stderr, "SSA_NAME nodes allocated: " PRsa (11) "\n", SIZE_AMOUNT (ssa_name_nodes_created)); - fprintf (stderr, "SSA_NAME nodes reused: %u%c\n", + fprintf (stderr, "SSA_NAME nodes reused: " PRsa (11) "\n", SIZE_AMOUNT (ssa_name_nodes_reused)); } diff --git a/gcc/vec.c b/gcc/vec.c index bd49d0358c5..c08ef0445af 100644 --- a/gcc/vec.c +++ b/gcc/vec.c @@ -83,13 +83,13 @@ struct vec_usage: public mem_usage s[48] = '\0'; fprintf (stderr, - "%-48s %10zu%10zu%c:%4.1f%%%9zu%c%10zu" - ":%4.1f%%%10zu%c%10zu%c\n", + "%-48s %10" PRIu64 PRsa (10) ":%4.1f%%" PRsa (9) "%10" PRIu64 + ":%4.1f%%" PRsa (10) PRsa (10) "\n", s, - m_element_size, + (uint64_t)m_element_size, SIZE_AMOUNT (m_allocated), m_allocated * 100.0 / total.m_allocated, - SIZE_AMOUNT (m_peak), m_times, + SIZE_AMOUNT (m_peak), (uint64_t)m_times, m_times * 100.0 / total.m_times, SIZE_AMOUNT (m_items), SIZE_AMOUNT (m_items_peak)); } @@ -99,7 +99,7 @@ struct vec_usage: public mem_usage dump_footer () { print_dash_line (); - fprintf (stderr, "%s%64zu%c%25zu%c%16zu%c\n", + fprintf (stderr, "%s" PRsa (64) PRsa (25) PRsa (16) "\n", "Total", SIZE_AMOUNT (m_allocated), SIZE_AMOUNT (m_times), SIZE_AMOUNT (m_items)); print_dash_line (); -- 2.30.2