From 8826f267175d456121612332b838e41a9542a513 Mon Sep 17 00:00:00 2001 From: Martin Liska Date: Wed, 2 Sep 2020 14:30:16 +0200 Subject: [PATCH 2/3] Use SIZE_AMOUNT macro for GGC memory allocation numbers. gcc/ChangeLog: * ggc-common.c (ggc_prune_overhead_list): Use SIZE_AMOUNT. * ggc-page.c (release_pages): Likewise. (ggc_collect): Likewise. (ggc_trim): Likewise. (ggc_grow): Likewise. * timevar.c (timer::print): Likewise. gcc/testsuite/ChangeLog: * g++.dg/ext/timevar1.C: Prune more possible number values. * g++.dg/ext/timevar2.C: Likewise. --- gcc/ggc-common.c | 6 +++--- gcc/ggc-page.c | 15 +++++++-------- gcc/testsuite/g++.dg/ext/timevar1.C | 3 ++- gcc/testsuite/g++.dg/ext/timevar2.C | 3 ++- gcc/timevar.c | 8 ++++---- 5 files changed, 18 insertions(+), 17 deletions(-) diff --git a/gcc/ggc-common.c b/gcc/ggc-common.c index b8782c5824b..50c52fe525b 100644 --- a/gcc/ggc-common.c +++ b/gcc/ggc-common.c @@ -1008,7 +1008,7 @@ ggc_prune_overhead_list (void) } } -/* Print memory used by heap in kb if this info is not available. */ +/* Print memory used by heap if this info is not available. */ void report_heap_memory_use () @@ -1020,7 +1020,7 @@ report_heap_memory_use () #define MALLINFO_FN mallinfo #endif if (!quiet_flag) - fprintf (stderr," {heap %luk}", - (unsigned long) MALLINFO_FN ().arena / ONE_K); + fprintf (stderr, " {heap " PRsa (0) "}", + SIZE_AMOUNT (MALLINFO_FN ().arena)); #endif } diff --git a/gcc/ggc-page.c b/gcc/ggc-page.c index 53b311c2a52..9405f033a7c 100644 --- a/gcc/ggc-page.c +++ b/gcc/ggc-page.c @@ -1164,9 +1164,9 @@ release_pages (void) { fprintf (stderr, " {GC"); if (n1) - fprintf (stderr, " released %luk", (unsigned long)(n1 / 1024)); + fprintf (stderr, " released " PRsa (0), SIZE_AMOUNT (n1)); if (n2) - fprintf (stderr, " madv_dontneed %luk", (unsigned long)(n2 / 1024)); + fprintf (stderr, " madv_dontneed " PRsa (0), SIZE_AMOUNT (n2)); fprintf (stderr, "}"); } } @@ -2208,7 +2208,7 @@ ggc_collect (void) /* Output this later so we do not interfere with release_pages. */ if (!quiet_flag) - fprintf (stderr, " {GC %luk -> ", (unsigned long) allocated / 1024); + fprintf (stderr, " {GC " PRsa (0) " -> ", SIZE_AMOUNT (allocated)); /* Indicate that we've seen collections at this context depth. */ G.context_depth_collections = ((unsigned long)1 << (G.context_depth + 1)) - 1; @@ -2235,7 +2235,7 @@ ggc_collect (void) timevar_pop (TV_GC); if (!quiet_flag) - fprintf (stderr, "%luk}", (unsigned long) G.allocated / 1024); + fprintf (stderr, PRsa (0) "}", SIZE_AMOUNT (G.allocated)); if (GGC_DEBUG_LEVEL >= 2) fprintf (G.debug_file, "END COLLECTING\n"); } @@ -2250,9 +2250,8 @@ ggc_trim () sweep_pages (); release_pages (); if (!quiet_flag) - fprintf (stderr, " {GC trimmed to %luk, %luk mapped}", - (unsigned long) G.allocated / 1024, - (unsigned long) G.bytes_mapped / 1024); + fprintf (stderr, " {GC trimmed to " PRsa (0) ", " PRsa (0) " mapped}", + SIZE_AMOUNT (G.allocated), SIZE_AMOUNT (G.bytes_mapped)); timevar_pop (TV_GC); } @@ -2269,7 +2268,7 @@ ggc_grow (void) else ggc_collect (); if (!quiet_flag) - fprintf (stderr, " {GC %luk} ", (unsigned long) G.allocated / 1024); + fprintf (stderr, " {GC " PRsa (0) "} ", SIZE_AMOUNT (G.allocated)); } void diff --git a/gcc/testsuite/g++.dg/ext/timevar1.C b/gcc/testsuite/g++.dg/ext/timevar1.C index 3f891a50aba..988a6f8543d 100644 --- a/gcc/testsuite/g++.dg/ext/timevar1.C +++ b/gcc/testsuite/g++.dg/ext/timevar1.C @@ -2,7 +2,8 @@ // { dg-options "-ftime-report" } // { dg-allow-blank-lines-in-output 1 } // { dg-prune-output "Time variable" } -// { dg-prune-output " kB" } +// { dg-prune-output "k" } +// { dg-prune-output " 0 " } // { dg-prune-output "checks" } void diff --git a/gcc/testsuite/g++.dg/ext/timevar2.C b/gcc/testsuite/g++.dg/ext/timevar2.C index dd96d45c01e..46c3e1b4794 100644 --- a/gcc/testsuite/g++.dg/ext/timevar2.C +++ b/gcc/testsuite/g++.dg/ext/timevar2.C @@ -1,7 +1,8 @@ // PR c++/57524 // { dg-options "-ftime-report" } // { dg-prune-output "Time variable" } -// { dg-prune-output " kB" } +// { dg-prune-output "k" } +// { dg-prune-output " 0 " } // { dg-prune-output "checks" } namespace detail { diff --git a/gcc/timevar.c b/gcc/timevar.c index a3a882d3204..8fbf5faa4e3 100644 --- a/gcc/timevar.c +++ b/gcc/timevar.c @@ -661,8 +661,8 @@ timer::print_row (FILE *fp, #endif /* HAVE_WALL_TIME */ /* Print the amount of ggc memory allocated. */ - fprintf (fp, "%8u kB (%3.0f%%)", - (unsigned) (elapsed.ggc_mem >> 10), + fprintf (fp, PRsa (6) " (%3.0f%%)", + SIZE_AMOUNT (elapsed.ggc_mem), (total->ggc_mem == 0 ? 0 : (float) elapsed.ggc_mem / total->ggc_mem) * 100); @@ -712,7 +712,7 @@ timer::print (FILE *fp) TIMEVAR. */ m_start_time = now; - fprintf (fp, "\n%-35s%16s%14s%14s%18s\n", "Time variable", "usr", "sys", + fprintf (fp, "\n%-35s%16s%14s%14s%14s\n", "Time variable", "usr", "sys", "wall", "GGC"); if (m_jit_client_items) fputs ("GCC items:\n", fp); @@ -776,7 +776,7 @@ timer::print (FILE *fp) #ifdef HAVE_WALL_TIME fprintf (fp, "%8.2f ", total->wall); #endif - fprintf (fp, "%9u kB\n", (unsigned) (total->ggc_mem >> 10)); + fprintf (fp, PRsa (7) "\n", SIZE_AMOUNT (total->ggc_mem)); if (CHECKING_P || flag_checking) fprintf (fp, "Extra diagnostic checks enabled; compiler may run slowly.\n"); -- 2.28.0