And there's one more piece needed for -ftime-report:

Time variable                                   usr           sys          wall 
               GGC
 phase setup                        :   0.00 (  0%)   0.00 (  0%)   0.01 (  1%) 
      2 MiB (  6%)
 phase opt and generate             :   0.25 ( 40%)   0.02 ( 25%)   0.26 ( 37%) 
      0 MiB (  1%)
 phase stream in                    :   0.18 ( 29%)   0.02 ( 25%)   0.20 ( 29%) 
     30 MiB ( 93%)
 phase stream out                   :   0.19 ( 31%)   0.04 ( 50%)   0.23 ( 33%) 
      0 MiB (  0%)
 garbage collection                 :   0.03 (  5%)   0.00 (  0%)   0.03 (  4%) 
      0 MiB (  0%)
 callgraph optimization             :   0.00 (  0%)   0.00 (  0%)   0.02 (  3%) 
      0 MiB (  0%)
 ipa ODR types                      :   0.00 (  0%)   0.01 ( 12%)   0.00 (  0%) 
      0 MiB (  0%)
 ipa function summary               :   0.01 (  2%)   0.00 (  0%)   0.00 (  0%) 
      2 MiB (  8%)
 ipa dead code removal              :   0.03 (  5%)   0.00 (  0%)   0.03 (  4%) 
      0 MiB (  0%)
 ipa cp                             :   0.01 (  2%)   0.00 (  0%)   0.01 (  1%) 
      0 MiB (  0%)
 ipa inlining heuristics            :   0.01 (  2%)   0.00 (  0%)   0.01 (  1%) 
      0 MiB (  0%)
 lto stream decompression           :   0.01 (  2%)   0.00 (  0%)   0.00 (  0%) 
      0 MiB (  0%)
 ipa lto gimple out                 :   0.06 ( 10%)   0.01 ( 13%)   0.07 ( 10%) 
      0 MiB (  0%)
 ipa lto decl in                    :   0.07 ( 11%)   0.01 ( 12%)   0.08 ( 11%) 
     18 MiB ( 57%)
 ipa lto decl out                   :   0.12 ( 19%)   0.00 (  0%)   0.12 ( 17%) 
      0 MiB (  0%)
 ipa lto cgraph I/O                 :   0.01 (  2%)   0.00 (  0%)   0.01 (  1%) 
      8 MiB ( 27%)
 ipa lto decl merge                 :   0.04 (  6%)   0.00 (  0%)   0.04 (  6%) 
      0 MiB (  2%)
 whopr wpa I/O                      :   0.01 (  2%)   0.03 ( 38%)   0.04 (  6%) 
      0 MiB (  0%)
 whopr partitioning                 :   0.04 (  6%)   0.00 (  0%)   0.04 (  6%) 
      0 MiB (  1%)
 ipa reference                      :   0.01 (  2%)   0.00 (  0%)   0.01 (  1%) 
      0 MiB (  0%)
 ipa profile                        :   0.01 (  2%)   0.00 (  0%)   0.01 (  1%) 
      0 MiB (  0%)
 ipa pure const                     :   0.01 (  2%)   0.00 (  0%)   0.01 (  1%) 
      0 MiB (  0%)
 ipa SRA                            :   0.01 (  2%)   0.00 (  0%)   0.01 (  1%) 
      0 MiB (  0%)
 callgraph verifier                 :   0.12 ( 19%)   0.02 ( 25%)   0.14 ( 20%) 
      0 MiB (  0%)
 TOTAL                              :   0.62          0.08          0.70        
     32 MiB

Martin
>From e177610161e8ec22fee70bb2339195b5104bd30e Mon Sep 17 00:00:00 2001
From: Martin Liska <mli...@suse.cz>
Date: Tue, 1 Sep 2020 14:44:40 +0200
Subject: [PATCH] Change timevar memory allocation to MiB.

gcc/ChangeLog:

	* timevar.c (timer::print): Print memory allocation in MiB.

gcc/testsuite/ChangeLog:

	* g++.dg/ext/timevar1.C: Expect values in MiB.
	* g++.dg/ext/timevar2.C: Likewise.
---
 gcc/testsuite/g++.dg/ext/timevar1.C | 2 +-
 gcc/testsuite/g++.dg/ext/timevar2.C | 2 +-
 gcc/timevar.c                       | 8 ++++----
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/gcc/testsuite/g++.dg/ext/timevar1.C b/gcc/testsuite/g++.dg/ext/timevar1.C
index 3f891a50aba..d810ebe3451 100644
--- a/gcc/testsuite/g++.dg/ext/timevar1.C
+++ b/gcc/testsuite/g++.dg/ext/timevar1.C
@@ -2,7 +2,7 @@
 // { dg-options "-ftime-report" }
 // { dg-allow-blank-lines-in-output 1 }
 // { dg-prune-output "Time variable" }
-// { dg-prune-output " kB" }
+// { dg-prune-output " MiB" }
 // { 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..fa68aac7e72 100644
--- a/gcc/testsuite/g++.dg/ext/timevar2.C
+++ b/gcc/testsuite/g++.dg/ext/timevar2.C
@@ -1,7 +1,7 @@
 // PR c++/57524
 // { dg-options "-ftime-report" }
 // { dg-prune-output "Time variable" }
-// { dg-prune-output " kB" }
+// { dg-prune-output " MiB" }
 // { dg-prune-output "checks" }
 
 namespace detail {
diff --git a/gcc/timevar.c b/gcc/timevar.c
index a3a882d3204..43b17571da2 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, "%8u MiB (%3.0f%%)",
+	   (unsigned ) (elapsed.ggc_mem / ONE_M),
 	   (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%19s\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, "%9u MiB\n", (unsigned) (total->ggc_mem / ONE_M));
 
   if (CHECKING_P || flag_checking)
     fprintf (fp, "Extra diagnostic checks enabled; compiler may run slowly.\n");
-- 
2.28.0

Reply via email to