Hi.

The patch is fixing an error in vec_safe_grow_cleared function.
Apart from that I improved readability of the report.

Patch bootstrap with --enable-gather-detailed-mem-stats.

Ready to be installed?
Thanks,
Martin

gcc/ChangeLog:

2019-02-26  Martin Liska  <mli...@suse.cz>

        * alloc-pool.h (struct pool_usage): Remove extra
        print_dash_line.
        * bitmap.h (struct bitmap_usage): Likewise.
        * ggc-common.c (struct ggc_usage): Likewise.
        * mem-stats.h (struct mem_usage): Likewise.
        (mem_alloc_description::dump): Print dash lines
        here and repeat header at the end of a table report.
        It's then more readable.
        * tree-phinodes.c (phinodes_print_statistics): Make
        horizontal alignment.
        * tree-ssanames.c (ssanames_print_statistics): Likewise.
        * vec.c (struct vec_usage): Remove extra print_dash_line.
        * vec.h (vec_safe_grow_cleared): Pass PASS_MEM_STAT.

libcpp/ChangeLog:

2019-02-26  Martin Liska  <mli...@suse.cz>

        * symtab.c (ht_dump_statistics): Make
        horizontal alignment for statistics.
---
 gcc/alloc-pool.h    |  3 ---
 gcc/bitmap.h        |  1 -
 gcc/ggc-common.c    |  3 ---
 gcc/mem-stats.h     |  9 ++++++---
 gcc/tree-phinodes.c |  4 ++--
 gcc/tree-ssanames.c |  4 ++--
 gcc/vec.c           |  3 ---
 gcc/vec.h           |  2 +-
 libcpp/symtab.c     | 24 +++++++++++++-----------
 9 files changed, 24 insertions(+), 29 deletions(-)


diff --git a/gcc/alloc-pool.h b/gcc/alloc-pool.h
index 4af926dcff1..d3208100316 100644
--- a/gcc/alloc-pool.h
+++ b/gcc/alloc-pool.h
@@ -83,17 +83,14 @@ struct pool_usage: public mem_usage
   {
     fprintf (stderr, "%-32s%-48s %6s%11s%16s%17s%12s\n", "Pool name", name,
 	     "Pools", "Leak", "Peak", "Times", "Elt size");
-    print_dash_line ();
   }
 
   /* Dump footer.  */
   inline void
   dump_footer ()
   {
-    print_dash_line ();
     fprintf (stderr, "%s" PRsa(82) PRsa(10) "\n", "Total",
 	     SIZE_AMOUNT (m_instances), SIZE_AMOUNT (m_allocated));
-    print_dash_line ();
   }
 
   /* Element size.  */
diff --git a/gcc/bitmap.h b/gcc/bitmap.h
index 11c75e9ef69..ed25c1ee5da 100644
--- a/gcc/bitmap.h
+++ b/gcc/bitmap.h
@@ -258,7 +258,6 @@ struct bitmap_usage: public mem_usage
   {
     fprintf (stderr, "%-48s %11s%16s%17s%12s%12s%10s\n", name, "Leak", "Peak",
 	     "Times", "N searches", "Search iter", "Type");
-    print_dash_line ();
   }
 
   /* Number search operations.  */
diff --git a/gcc/ggc-common.c b/gcc/ggc-common.c
index 9a12fad5838..0d1e5bf2bf5 100644
--- a/gcc/ggc-common.c
+++ b/gcc/ggc-common.c
@@ -910,9 +910,7 @@ struct ggc_usage: public mem_usage
   inline void
   dump_footer ()
   {
-    print_dash_line ();
     dump ("Total", *this);
-    print_dash_line ();
   }
 
   /* Get balance which is GGC allocation leak.  */
@@ -955,7 +953,6 @@ struct ggc_usage: public mem_usage
   {
     fprintf (stderr, "%-48s %11s%17s%17s%16s%17s\n", name, "Garbage", "Freed",
 	     "Leak", "Overhead", "Times");
-    print_dash_line ();
   }
 
   /* Freed memory in bytes.  */
diff --git a/gcc/mem-stats.h b/gcc/mem-stats.h
index cbc328f4b3d..7612e7de3d2 100644
--- a/gcc/mem-stats.h
+++ b/gcc/mem-stats.h
@@ -219,10 +219,8 @@ struct mem_usage
   inline void
   dump_footer () const
   {
-    print_dash_line ();
     fprintf (stderr, "%s" PRsa (53) PRsa (26) "\n", "Total",
 	     SIZE_AMOUNT (m_allocated), SIZE_AMOUNT (m_times));
-    print_dash_line ();
   }
 
   /* Return fraction of NOMINATOR and DENOMINATOR in percent.  */
@@ -247,7 +245,6 @@ struct mem_usage
   {
     fprintf (stderr, "%-48s %11s%16s%10s%17s\n", name, "Leak", "Peak",
 	     "Times", "Type");
-    print_dash_line ();
   }
 
   /* Current number of allocated bytes.  */
@@ -631,11 +628,17 @@ mem_alloc_description<T>::dump (mem_alloc_origin origin,
   mem_list_t *list = get_list (origin, &length, cmp);
   T total = get_sum (origin);
 
+  T::print_dash_line ();
   T::dump_header (mem_location::get_origin_name (origin));
+  T::print_dash_line ();
   for (int i = length - 1; i >= 0; i--)
     list[i].second->dump (list[i].first, total);
+  T::print_dash_line ();
 
+  T::dump_header (mem_location::get_origin_name (origin));
+  T::print_dash_line ();
   total.dump_footer ();
+  T::print_dash_line ();
 
   XDELETEVEC (list);
 
diff --git a/gcc/tree-phinodes.c b/gcc/tree-phinodes.c
index 54e1452e80c..d062f4e36f6 100644
--- a/gcc/tree-phinodes.c
+++ b/gcc/tree-phinodes.c
@@ -80,9 +80,9 @@ unsigned int phi_nodes_created;
 void
 phinodes_print_statistics (void)
 {
-  fprintf (stderr, "PHI nodes allocated: " PRsa (11) "\n",
+  fprintf (stderr, "%-32s" PRsa (11) "\n", "PHI nodes allocated:",
 	   SIZE_AMOUNT (phi_nodes_created));
-  fprintf (stderr, "PHI nodes reused: " PRsa (11) "\n",
+  fprintf (stderr, "%-32s" PRsa (11) "\n", "PHI nodes reused:",
 	   SIZE_AMOUNT (phi_nodes_reused));
 }
 
diff --git a/gcc/tree-ssanames.c b/gcc/tree-ssanames.c
index 51f52bb5bd3..c457334bb31 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: " PRsa (11) "\n",
+  fprintf (stderr, "%-32s" PRsa (11) "\n", "SSA_NAME nodes allocated:",
 	   SIZE_AMOUNT (ssa_name_nodes_created));
-  fprintf (stderr, "SSA_NAME nodes reused: " PRsa (11) "\n",
+  fprintf (stderr, "%-32s" PRsa (11) "\n", "SSA_NAME nodes reused:",
 	   SIZE_AMOUNT (ssa_name_nodes_reused));
 }
 
diff --git a/gcc/vec.c b/gcc/vec.c
index c418cb8660a..f4749229ca2 100644
--- a/gcc/vec.c
+++ b/gcc/vec.c
@@ -98,11 +98,9 @@ struct vec_usage: public mem_usage
   inline void
   dump_footer ()
   {
-    print_dash_line ();
     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 ();
   }
 
   /* Dump header with NAME.  */
@@ -111,7 +109,6 @@ struct vec_usage: public mem_usage
   {
     fprintf (stderr, "%-48s %10s%11s%16s%10s%17s%11s\n", name, "sizeof(T)",
 	     "Leak", "Peak", "Times", "Leak items", "Peak items");
-    print_dash_line ();
   }
 
   /* Current number of items allocated.  */
diff --git a/gcc/vec.h b/gcc/vec.h
index 4bd9df9aba5..2dbf3074da0 100644
--- a/gcc/vec.h
+++ b/gcc/vec.h
@@ -739,7 +739,7 @@ inline void
 vec_safe_grow_cleared (vec<T, va_heap, vl_ptr> *&v,
 		       unsigned len CXX_MEM_STAT_INFO)
 {
-  v->safe_grow_cleared (len);
+  v->safe_grow_cleared (len PASS_MEM_STAT);
 }
 
 
diff --git a/libcpp/symtab.c b/libcpp/symtab.c
index 26c094e85c8..5048b47bc78 100644
--- a/libcpp/symtab.c
+++ b/libcpp/symtab.c
@@ -306,39 +306,41 @@ ht_dump_statistics (cpp_hash_table *table)
   nelts = table->nelements;
   headers = table->nslots * sizeof (hashnode);
 
-  fprintf (stderr, "\nString pool\nentries\t\t%lu\n",
+  fprintf (stderr, "\nString pool\n%-32s%lu\n", "entries:",
 	   (unsigned long) nelts);
-  fprintf (stderr, "identifiers\t%lu (%.2f%%)\n",
+  fprintf (stderr, "%-32s%lu (%.2f%%)\n", "identifiers:",
 	   (unsigned long) nids, nids * 100.0 / nelts);
-  fprintf (stderr, "slots\t\t%lu\n",
+  fprintf (stderr, "%-32s%lu\n", "slots:",
 	   (unsigned long) table->nslots);
-  fprintf (stderr, "deleted\t\t%lu\n",
+  fprintf (stderr, "%-32s%lu\n", "deleted:",
 	   (unsigned long) deleted);
 
   if (table->alloc_subobject)
-    fprintf (stderr, "GGC bytes\t%lu%c\n",
+    fprintf (stderr, "%-32s%lu%c\n", "GGC bytes:",
 	     SCALE (total_bytes), LABEL (total_bytes));
   else
     {
       overhead = obstack_memory_used (&table->stack) - total_bytes;
-      fprintf (stderr, "obstack bytes\t%lu%c (%lu%c overhead)\n",
+      fprintf (stderr, "%-32s%lu%c (%lu%c overhead)\n",
+	       "obstack bytes:",
 	       SCALE (total_bytes), LABEL (total_bytes),
 	       SCALE (overhead), LABEL (overhead));
     }
-  fprintf (stderr, "table size\t%lu%c\n",
+  fprintf (stderr, "%-32s%lu%c\n", "table size:",
 	   SCALE (headers), LABEL (headers));
 
   exp_len = (double)total_bytes / (double)nelts;
   exp2_len = exp_len * exp_len;
   exp_len2 = (double) sum_of_squares / (double) nelts;
 
-  fprintf (stderr, "coll/search\t%.4f\n",
+  fprintf (stderr, "%-32s%.4f\n", "coll/search:",
 	   (double) table->collisions / (double) table->searches);
-  fprintf (stderr, "ins/search\t%.4f\n",
+  fprintf (stderr, "%-32s%.4f\n", "ins/search:",
 	   (double) nelts / (double) table->searches);
-  fprintf (stderr, "avg. entry\t%.2f bytes (+/- %.2f)\n",
+  fprintf (stderr, "%-32s%.2f bytes (+/- %.2f)\n",
+	   "avg. entry:",
 	   exp_len, approx_sqrt (exp_len2 - exp2_len));
-  fprintf (stderr, "longest entry\t%lu\n",
+  fprintf (stderr, "%-32s%lu\n", "longest entry:",
 	   (unsigned long) longest);
 #undef SCALE
 #undef LABEL

Reply via email to