]> gcc.gnu.org Git - gcc.git/commitdiff
Come up with SIZE_AMOUNT and use it in memory statistics and sort stats.
authorMartin Liska <mliska@suse.cz>
Mon, 5 Nov 2018 13:36:29 +0000 (14:36 +0100)
committerMartin Liska <marxin@gcc.gnu.org>
Mon, 5 Nov 2018 13:36:29 +0000 (13:36 +0000)
2018-11-05  Martin Liska  <mliska@suse.cz>

* 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

18 files changed:
gcc/ChangeLog
gcc/alloc-pool.h
gcc/bitmap.h
gcc/ggc-common.c
gcc/ggc-page.c
gcc/gimple.c
gcc/gimple.h
gcc/input.c
gcc/mem-stats.h
gcc/rtl.c
gcc/system.h
gcc/trans-mem.c
gcc/tree-cfg.c
gcc/tree-dfa.c
gcc/tree-phinodes.c
gcc/tree-ssanames.c
gcc/tree.c
gcc/vec.c

index fd48d8fda965f998c0d3017129326b5cda31b234..775461b936e098e60239832557623408e5160b26 100644 (file)
@@ -1,3 +1,46 @@
+2018-11-05  Martin Liska  <mliska@suse.cz>
+
+       * 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.
+
 2018-11-05  Martin Liska  <mliska@suse.cz>
 
        * mem-stats.h (mem_alloc_description::release_instance_overhead):
index d2ee00057611453cee567bab76d0e1f19effb238..d17a05ca4fb18bdc7bcfc70b429143f54b81b7ab 100644 (file)
@@ -63,12 +63,16 @@ struct pool_usage: public mem_usage
   {
     char *location_string = loc->to_string ();
 
-    fprintf (stderr, "%-32s%-48s %6li%10li:%5.1f%%%10li%10li:%5.1f%%%12li\n",
-            m_pool_name, location_string, (long)m_instances,
-            (long)m_allocated, get_percent (m_allocated, total.m_allocated),
-            (long)m_peak, (long)m_times,
+    fprintf (stderr, "%-32s%-48s %5zu%c%9zu%c:%5.1f%%%9zu"
+            "%c%9zu%c:%5.1f%%%12zu\n",
+            m_pool_name, location_string,
+            SIZE_AMOUNT (m_instances),
+            SIZE_AMOUNT (m_allocated),
+            get_percent (m_allocated, total.m_allocated),
+            SIZE_AMOUNT (m_peak),
+            SIZE_AMOUNT (m_times),
             get_percent (m_times, total.m_times),
-            (long)m_element_size);
+            m_element_size);
 
     free (location_string);
   }
@@ -87,8 +91,8 @@ struct pool_usage: public mem_usage
   dump_footer ()
   {
     print_dash_line ();
-    fprintf (stderr, "%s%82li%10li\n", "Total", (long)m_instances,
-            (long)m_allocated);
+    fprintf (stderr, "%s%82zu%c%10zu%c\n", "Total",
+            SIZE_AMOUNT (m_instances), SIZE_AMOUNT (m_allocated));
     print_dash_line ();
   }
 
index 5d3e8a5088e7f513594982e0010e7f9c0a2aaecf..973ea846baf100b1bf9a2ae5718e7b9f0426c99d 100644 (file)
@@ -239,14 +239,14 @@ struct bitmap_usage: public mem_usage
   {
     char *location_string = loc->to_string ();
 
-    fprintf (stderr, "%-48s %10" PRIu64 ":%5.1f%%"
-            "%10" PRIu64 "%10" PRIu64 ":%5.1f%%"
-            "%12" PRIu64 "%12" PRIu64 "%10s\n",
-            location_string, (uint64_t)m_allocated,
+    fprintf (stderr, "%-48s %9zu%c:%5.1f%%"
+            "%9zu%c%9zu%c:%5.1f%%"
+            "%11" PRIu64 "%c%11" PRIu64 "%c%10s\n",
+            location_string, SIZE_AMOUNT (m_allocated),
             get_percent (m_allocated, total.m_allocated),
-            (uint64_t)m_peak, (uint64_t)m_times,
+            SIZE_AMOUNT (m_peak), SIZE_AMOUNT (m_times),
             get_percent (m_times, total.m_times),
-            m_nsearches, m_search_iter,
+            SIZE_AMOUNT (m_nsearches), SIZE_AMOUNT (m_search_iter),
             loc->m_ggc ? "ggc" : "heap");
 
     free (location_string);
index f83fc136d04ee553a8bd4519db9ad812e4cf9493..9fdba23ce4c268957957dfae55d25779156c1778 100644 (file)
@@ -195,14 +195,6 @@ ggc_splay_dont_free (void * x ATTRIBUTE_UNUSED, void *nl)
   gcc_assert (!nl);
 }
 
-/* Print statistics that are independent of the collector in use.  */
-#define SCALE(x) ((unsigned long) ((x) < 1024*10 \
-                 ? (x) \
-                 : ((x) < 1024*1024*10 \
-                    ? (x) / 1024 \
-                    : (x) / (1024*1024))))
-#define LABEL(x) ((x) < 1024*10 ? ' ' : ((x) < 1024*1024*10 ? 'k' : 'M'))
-
 void
 ggc_print_common_statistics (FILE *stream ATTRIBUTE_UNUSED,
                             ggc_statistics *stats)
@@ -890,16 +882,17 @@ struct ggc_usage: public mem_usage
   inline void
   dump (const char *prefix, ggc_usage &total) const
   {
-    long balance = get_balance ();
+    size_t balance = get_balance ();
     fprintf (stderr,
-            "%-48s %10li:%5.1f%%%10li:%5.1f%%"
-            "%10li:%5.1f%%%10li:%5.1f%%%10li\n",
-            prefix, (long)m_collected,
+            "%-48s %9zu%c:%5.1f%%%9zu%c:%5.1f%%"
+            "%9zu%c:%5.1f%%%9zu%c:%5.1f%%%9zu%c\n",
+            prefix, SIZE_AMOUNT (m_collected),
             get_percent (m_collected, total.m_collected),
-            (long)m_freed, get_percent (m_freed, total.m_freed),
-            (long)balance, get_percent (balance, total.get_balance ()),
-            (long)m_overhead, get_percent (m_overhead, total.m_overhead),
-            (long)m_times);
+            SIZE_AMOUNT (m_freed), get_percent (m_freed, total.m_freed),
+            SIZE_AMOUNT (balance), get_percent (balance, total.get_balance ()),
+            SIZE_AMOUNT (m_overhead),
+            get_percent (m_overhead, total.m_overhead),
+            SIZE_AMOUNT (m_times));
   }
 
   /* Dump usage coupled to LOC location, where TOTAL is sum of all rows.  */
@@ -923,7 +916,7 @@ struct ggc_usage: public mem_usage
   }
 
   /* Get balance which is GGC allocation leak.  */
-  inline long
+  inline size_t
   get_balance () const
   {
     return m_allocated + m_overhead - m_collected - m_freed;
@@ -938,10 +931,7 @@ struct ggc_usage: public mem_usage
     const mem_pair_t f = *(const mem_pair_t *)first;
     const mem_pair_t s = *(const mem_pair_t *)second;
 
-    if (*f.second == *s.second)
-      return 0;
-
-    return *f.second < *s.second ? 1 : -1;
+    return s.second->get_balance () - f.second->get_balance ();
   }
 
   /* Compare rows in final GGC summary dump.  */
index 51783e51356ab694e5d10739473c538e6b707b03..00c2864711f00ed812d3d3a3cc0807e033301110 100644 (file)
@@ -2237,14 +2237,6 @@ ggc_grow (void)
     fprintf (stderr, " {GC start %luk} ", (unsigned long) G.allocated / 1024);
 }
 
-/* Print allocation statistics.  */
-#define SCALE(x) ((unsigned long) ((x) < 1024*10 \
-                 ? (x) \
-                 : ((x) < 1024*1024*10 \
-                    ? (x) / 1024 \
-                    : (x) / (1024*1024))))
-#define STAT_LABEL(x) ((x) < 1024*10 ? ' ' : ((x) < 1024*1024*10 ? 'k' : 'M'))
-
 void
 ggc_print_statistics (void)
 {
@@ -2296,53 +2288,61 @@ ggc_print_statistics (void)
          overhead += (sizeof (page_entry) - sizeof (long)
                       + BITMAP_SIZE (OBJECTS_IN_PAGE (p) + 1));
        }
-      fprintf (stderr, "%-8lu %10lu%c %10lu%c %10lu%c\n",
-              (unsigned long) OBJECT_SIZE (i),
-              SCALE (allocated), STAT_LABEL (allocated),
-              SCALE (in_use), STAT_LABEL (in_use),
-              SCALE (overhead), STAT_LABEL (overhead));
+      fprintf (stderr, "%-8zu %10zu%c %10zu%c %10zu%c\n",
+              OBJECT_SIZE (i),
+              SIZE_AMOUNT (allocated),
+              SIZE_AMOUNT (in_use),
+              SIZE_AMOUNT (overhead));
       total_overhead += overhead;
     }
-  fprintf (stderr, "%-8s %10lu%c %10lu%c %10lu%c\n", "Total",
-          SCALE (G.bytes_mapped), STAT_LABEL (G.bytes_mapped),
-          SCALE (G.allocated), STAT_LABEL (G.allocated),
-          SCALE (total_overhead), STAT_LABEL (total_overhead));
+  fprintf (stderr, "%-8s %10zu%c %10zu%c %10zu%c\n",
+          "Total",
+          SIZE_AMOUNT (G.bytes_mapped),
+          SIZE_AMOUNT (G.allocated),
+          SIZE_AMOUNT (total_overhead));
 
   if (GATHER_STATISTICS)
     {
       fprintf (stderr, "\nTotal allocations and overheads during "
               "the compilation process\n");
 
-      fprintf (stderr, "Total Overhead:                          %10"
-              HOST_LONG_LONG_FORMAT "d\n", G.stats.total_overhead);
-      fprintf (stderr, "Total Allocated:                         %10"
-              HOST_LONG_LONG_FORMAT "d\n",
-              G.stats.total_allocated);
-
-      fprintf (stderr, "Total Overhead  under  32B:              %10"
-              HOST_LONG_LONG_FORMAT "d\n", G.stats.total_overhead_under32);
-      fprintf (stderr, "Total Allocated under  32B:              %10"
-              HOST_LONG_LONG_FORMAT "d\n", G.stats.total_allocated_under32);
-      fprintf (stderr, "Total Overhead  under  64B:              %10"
-              HOST_LONG_LONG_FORMAT "d\n", G.stats.total_overhead_under64);
-      fprintf (stderr, "Total Allocated under  64B:              %10"
-              HOST_LONG_LONG_FORMAT "d\n", G.stats.total_allocated_under64);
-      fprintf (stderr, "Total Overhead  under 128B:              %10"
-              HOST_LONG_LONG_FORMAT "d\n", G.stats.total_overhead_under128);
-      fprintf (stderr, "Total Allocated under 128B:              %10"
-              HOST_LONG_LONG_FORMAT "d\n", G.stats.total_allocated_under128);
+      fprintf (stderr, "Total Overhead:                          %9"
+              HOST_LONG_LONG_FORMAT "d%c\n",
+              SIZE_AMOUNT (G.stats.total_overhead));
+      fprintf (stderr, "Total Allocated:                         %9"
+              HOST_LONG_LONG_FORMAT "d%c\n",
+              SIZE_AMOUNT (G.stats.total_allocated));
+
+      fprintf (stderr, "Total Overhead  under  32B:              %9"
+              HOST_LONG_LONG_FORMAT "d%c\n",
+              SIZE_AMOUNT (G.stats.total_overhead_under32));
+      fprintf (stderr, "Total Allocated under  32B:              %9"
+              HOST_LONG_LONG_FORMAT "d%c\n",
+              SIZE_AMOUNT (G.stats.total_allocated_under32));
+      fprintf (stderr, "Total Overhead  under  64B:              %9"
+              HOST_LONG_LONG_FORMAT "d%c\n",
+              SIZE_AMOUNT (G.stats.total_overhead_under64));
+      fprintf (stderr, "Total Allocated under  64B:              %9"
+              HOST_LONG_LONG_FORMAT "d%c\n",
+              SIZE_AMOUNT (G.stats.total_allocated_under64));
+      fprintf (stderr, "Total Overhead  under 128B:              %9"
+              HOST_LONG_LONG_FORMAT "d%c\n",
+              SIZE_AMOUNT (G.stats.total_overhead_under128));
+      fprintf (stderr, "Total Allocated under 128B:              %9"
+              HOST_LONG_LONG_FORMAT "d%c\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 %9lu:     %10"
-                    HOST_LONG_LONG_FORMAT "d\n",
-                    (unsigned long) OBJECT_SIZE (i),
-                    G.stats.total_overhead_per_order[i]);
-           fprintf (stderr, "Total Allocated page size %9lu:     %10"
-                    HOST_LONG_LONG_FORMAT "d\n",
-                    (unsigned long) OBJECT_SIZE (i),
-                    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),
+                    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),
+                    SIZE_AMOUNT (G.stats.total_allocated_per_order[i]));
          }
   }
 }
index e3e651b1e61ddd5e817ea7b52deea4abca22d413..579b750d913c8b9026f3aafd9296e640a32bf12a 100644 (file)
@@ -2149,15 +2149,16 @@ dump_gimple_statistics (void)
   fprintf (stderr, "---------------------------------------\n");
   for (i = 0; i < (int) gimple_alloc_kind_all; ++i)
     {
-      fprintf (stderr, "%-20s %7" PRIu64 " %10" PRIu64 "\n",
-              gimple_alloc_kind_names[i], gimple_alloc_counts[i],
-              gimple_alloc_sizes[i]);
+      fprintf (stderr, "%-20s %7" PRIu64 "%c %10" PRIu64 "%c\n",
+              gimple_alloc_kind_names[i],
+              SIZE_AMOUNT (gimple_alloc_counts[i]),
+              SIZE_AMOUNT (gimple_alloc_sizes[i]));
       total_tuples += gimple_alloc_counts[i];
       total_bytes += gimple_alloc_sizes[i];
     }
   fprintf (stderr, "---------------------------------------\n");
-  fprintf (stderr, "%-20s %7" PRIu64 " %10" PRIu64 "\n", "Total",
-          total_tuples, total_bytes);
+  fprintf (stderr, "%-20s %7" PRIu64 "%c %10" PRIu64 "%c\n", "Total",
+          SIZE_AMOUNT (total_tuples), SIZE_AMOUNT (total_bytes));
   fprintf (stderr, "---------------------------------------\n");
 }
 
index a5dda9369bc0b11446ba7cffe0403e93f0222fa6..cdd711dae5b5cd8d48009f3e9b6cc43e7b0586f5 100644 (file)
@@ -6404,14 +6404,4 @@ gimple_set_do_not_emit_location (gimple *g)
   gimple_set_plf (g, GF_PLF_1, true);
 }
 
-
-/* Macros for showing usage statistics.  */
-#define SCALE(x) ((unsigned long) ((x) < 1024*10       \
-                 ? (x)                                 \
-                 : ((x) < 1024*1024*10                 \
-                    ? (x) / 1024                       \
-                    : (x) / (1024*1024))))
-
-#define LABEL(x) ((x) < 1024*10 ? 'b' : ((x) < 1024*1024*10 ? 'k' : 'M'))
-
 #endif  /* GCC_GIMPLE_H */
index a94a010f35371778d2f1e487ea33964399e57284..9fb6e72421fc992b1a854157d086199153616099 100644 (file)
@@ -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");
 }
index b7f7e06a1c7069332d8cea5bebbefb3a0a75be10..10b41651bf310c7b4250f496110b8e0caa04e821 100644 (file)
@@ -205,11 +205,11 @@ struct mem_usage
   {
     char *location_string = loc->to_string ();
 
-    fprintf (stderr, "%-48s %10" PRIu64 ":%5.1f%%"
-            "%10" PRIu64 "%10" PRIu64 ":%5.1f%%%10s\n",
-            location_string, (uint64_t)m_allocated,
+    fprintf (stderr, "%-48s %9zu%c:%5.1f%%"
+            "%9zu%c%9zu%c:%5.1f%%%10s\n",
+            location_string, SIZE_AMOUNT (m_allocated),
             get_percent (m_allocated, total.m_allocated),
-            (uint64_t)m_peak, (uint64_t)m_times,
+            SIZE_AMOUNT (m_peak), SIZE_AMOUNT (m_times),
             get_percent (m_times, total.m_times), loc->m_ggc ? "ggc" : "heap");
 
     free (location_string);
@@ -220,8 +220,8 @@ struct mem_usage
   dump_footer () const
   {
     print_dash_line ();
-    fprintf (stderr, "%s%54" PRIu64 "%27" PRIu64 "\n", "Total",
-            (uint64_t)m_allocated, (uint64_t)m_times);
+    fprintf (stderr, "%s%53zu%c%26zu%c\n", "Total",
+            SIZE_AMOUNT (m_allocated), SIZE_AMOUNT (m_times));
     print_dash_line ();
   }
 
index 86a40b11cf4c4c433cff22f69885996d53f8fb81..bf897bf75b4e7f4aa4dc26b7632cdcde8325b40e 100644 (file)
--- a/gcc/rtl.c
+++ b/gcc/rtl.c
@@ -148,10 +148,10 @@ const char * const reg_note_name[REG_NOTE_MAX] =
 #undef DEF_REG_NOTE
 };
 
-static int rtx_alloc_counts[(int) LAST_AND_UNUSED_RTX_CODE];
-static int rtx_alloc_sizes[(int) LAST_AND_UNUSED_RTX_CODE];
-static int rtvec_alloc_counts;
-static int rtvec_alloc_sizes;
+static size_t rtx_alloc_counts[(int) LAST_AND_UNUSED_RTX_CODE];
+static size_t rtx_alloc_sizes[(int) LAST_AND_UNUSED_RTX_CODE];
+static size_t rtvec_alloc_counts;
+static size_t rtvec_alloc_sizes;
 
 \f
 /* Allocate an rtx vector of N elements.
@@ -785,10 +785,20 @@ classify_insn (rtx x)
   return INSN;
 }
 
+/* Comparator of indices based on rtx_alloc_counts.  */
+
+static int
+rtx_count_cmp (const void *p1, const void *p2)
+{
+  const unsigned *n1 = (const unsigned *)p1;
+  const unsigned *n2 = (const unsigned *)p2;
+
+  return rtx_alloc_counts[*n1] - rtx_alloc_counts[*n2];
+}
+
 void
 dump_rtx_statistics (void)
 {
-  int i;
   int total_counts = 0;
   int total_sizes = 0;
 
@@ -798,27 +808,41 @@ dump_rtx_statistics (void)
       return;
     }
 
-  fprintf (stderr, "\nRTX Kind               Count      Bytes\n");
-  fprintf (stderr, "---------------------------------------\n");
-  for (i = 0; i < LAST_AND_UNUSED_RTX_CODE; i++)
-    if (rtx_alloc_counts[i])
-      {
-        fprintf (stderr, "%-20s %7d %10d\n", GET_RTX_NAME (i),
-                 rtx_alloc_counts[i], rtx_alloc_sizes[i]);
-        total_counts += rtx_alloc_counts[i];
-        total_sizes += rtx_alloc_sizes[i];
-      }
+  fprintf (stderr, "\nRTX Kind                   Count     Bytes\n");
+  fprintf (stderr, "-------------------------------------------\n");
+
+  auto_vec<unsigned> indices (LAST_AND_UNUSED_RTX_CODE);
+  for (unsigned i = 0; i < LAST_AND_UNUSED_RTX_CODE; i++)
+    indices.quick_push (i);
+  indices.qsort (rtx_count_cmp);
+
+  for (unsigned i = 0; i < LAST_AND_UNUSED_RTX_CODE; i++)
+    {
+      unsigned j = indices[i];
+      if (rtx_alloc_counts[j])
+       {
+         fprintf (stderr, "%-24s %6zu%c %9zu%c\n",
+                  GET_RTX_NAME (j),
+                  SIZE_AMOUNT (rtx_alloc_counts[j]),
+                  SIZE_AMOUNT (rtx_alloc_sizes[j]));
+         total_counts += rtx_alloc_counts[j];
+         total_sizes += rtx_alloc_sizes[j];
+       }
+    }
+
   if (rtvec_alloc_counts)
     {
-      fprintf (stderr, "%-20s %7d %10d\n", "rtvec",
-               rtvec_alloc_counts, rtvec_alloc_sizes);
+      fprintf (stderr, "%-24s %6zu%c %9zu%c\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, "%-20s %7d %10d\n",
-           "Total", total_counts, total_sizes);
-  fprintf (stderr, "---------------------------------------\n");
+  fprintf (stderr, "-----------------------------------------------\n");
+  fprintf (stderr, "%-24s %6d%c %9d%c\n",
+          "Total", SIZE_AMOUNT (total_counts),
+          SIZE_AMOUNT (total_sizes));
+  fprintf (stderr, "-----------------------------------------------\n");
 }
 \f
 #if defined ENABLE_RTL_CHECKING && (GCC_VERSION >= 2007)
index 100feb567c9854508c2d1d15b8164ba33964681b..ba328213a693b85c576e433568a2b119802acceb 100644 (file)
@@ -1208,4 +1208,29 @@ void gcc_stablesort (void *, size_t, size_t,
 #undef qsort
 #define qsort(...) PP_5th (__VA_ARGS__, gcc_qsort, 3, 2, qsort, 0) (__VA_ARGS__)
 
+#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 SIZE_SCALE(x) (((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 SIZE_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 SIZE_AMOUNT(size) SIZE_SCALE (size), SIZE_LABEL (size)
+
 #endif /* ! GCC_SYSTEM_H */
index 7e4bcec4030ea65d44c97e9782f5d8c0ffd30833..938f4e28b90a3dc5686401daee203133500daf00 100644 (file)
@@ -4859,7 +4859,7 @@ tm_mangle (tree old_asm_id)
 
   if (dc == NULL)
     {
-      char length[8];
+      char length[12];
 
     do_unencoded:
       sprintf (length, "%u", IDENTIFIER_LENGTH (old_asm_id));
index 5f334ca792717277b7a62c4f377ad90a921fa8c3..8db10898915e02054e34726f98ef4408bbea402b 100644 (file)
@@ -2584,18 +2584,18 @@ dump_cfg_stats (FILE *file)
   size = n_basic_blocks_for_fn (cfun) * sizeof (struct basic_block_def);
   total += size;
   fprintf (file, fmt_str_1, "Basic blocks", n_basic_blocks_for_fn (cfun),
-          SCALE (size), LABEL (size));
+          SIZE_AMOUNT (size));
 
   num_edges = 0;
   FOR_EACH_BB_FN (bb, cfun)
     num_edges += EDGE_COUNT (bb->succs);
   size = num_edges * sizeof (struct edge_def);
   total += size;
-  fprintf (file, fmt_str_2, "Edges", num_edges, SCALE (size), LABEL (size));
+  fprintf (file, fmt_str_2, "Edges", num_edges, SIZE_AMOUNT (size));
 
   fprintf (file, "---------------------------------------------------------\n");
-  fprintf (file, fmt_str_3, "Total memory used by CFG data", SCALE (total),
-          LABEL (total));
+  fprintf (file, fmt_str_3, "Total memory used by CFG data",
+          SIZE_AMOUNT (total));
   fprintf (file, "---------------------------------------------------------\n");
   fprintf (file, "\n");
 
index ee2ff2958dbe53f13fc3bbd1d2840170cec12960..ad49c878f646ca65cb9a5baf4404f5c87220ef44 100644 (file)
@@ -201,36 +201,36 @@ dump_dfa_stats (FILE *file)
   size = dfa_stats.num_uses * sizeof (tree *);
   total += size;
   fprintf (file, fmt_str_1, "USE operands", dfa_stats.num_uses,
-          SCALE (size), LABEL (size));
+          SIZE_AMOUNT (size));
 
   size = dfa_stats.num_defs * sizeof (tree *);
   total += size;
   fprintf (file, fmt_str_1, "DEF operands", dfa_stats.num_defs,
-          SCALE (size), LABEL (size));
+          SIZE_AMOUNT (size));
 
   size = dfa_stats.num_vuses * sizeof (tree *);
   total += size;
   fprintf (file, fmt_str_1, "VUSE operands", dfa_stats.num_vuses,
-          SCALE (size), LABEL (size));
+          SIZE_AMOUNT (size));
 
   size = dfa_stats.num_vdefs * sizeof (tree *);
   total += size;
   fprintf (file, fmt_str_1, "VDEF operands", dfa_stats.num_vdefs,
-          SCALE (size), LABEL (size));
+          SIZE_AMOUNT (size));
 
   size = dfa_stats.num_phis * sizeof (struct gphi);
   total += size;
   fprintf (file, fmt_str_1, "PHI nodes", dfa_stats.num_phis,
-          SCALE (size), LABEL (size));
+          SIZE_AMOUNT (size));
 
   size = dfa_stats.num_phi_args * sizeof (struct phi_arg_d);
   total += size;
   fprintf (file, fmt_str_1, "PHI arguments", dfa_stats.num_phi_args,
-          SCALE (size), LABEL (size));
+          SIZE_AMOUNT (size));
 
   fprintf (file, "---------------------------------------------------------\n");
-  fprintf (file, fmt_str_3, "Total memory used by DFA/SSA data", SCALE (total),
-          LABEL (total));
+  fprintf (file, fmt_str_3, "Total memory used by DFA/SSA data",
+          SIZE_AMOUNT (total));
   fprintf (file, "---------------------------------------------------------\n");
   fprintf (file, "\n");
 
index 9bdb8d587ab04b064b29c8f4dfa5ced8fa7ea78d..48397a1a4416cf20e7105cb21e0bd0f77c143da1 100644 (file)
@@ -80,8 +80,9 @@ unsigned int phi_nodes_created;
 void
 phinodes_print_statistics (void)
 {
-  fprintf (stderr, "PHI nodes allocated: %u\n", phi_nodes_created);
-  fprintf (stderr, "PHI nodes reused: %u\n", phi_nodes_reused);
+  fprintf (stderr, "PHI nodes allocated: %u%c\n",
+          SIZE_AMOUNT (phi_nodes_created));
+  fprintf (stderr, "PHI nodes reused: %u%c\n", SIZE_AMOUNT (phi_nodes_reused));
 }
 
 /* Allocate a PHI node with at least LEN arguments.  If the free list
index 66b2941fbf5af5359efee50b08ef826b941d1075..ff906e831e5746f839a6c325b82d2eabdda87f58 100644 (file)
@@ -112,8 +112,10 @@ fini_ssanames (struct function *fn)
 void
 ssanames_print_statistics (void)
 {
-  fprintf (stderr, "SSA_NAME nodes allocated: %u\n", ssa_name_nodes_created);
-  fprintf (stderr, "SSA_NAME nodes reused: %u\n", ssa_name_nodes_reused);
+  fprintf (stderr, "SSA_NAME nodes allocated: %u%c\n",
+          SIZE_AMOUNT (ssa_name_nodes_created));
+  fprintf (stderr, "SSA_NAME nodes reused: %u%c\n",
+          SIZE_AMOUNT (ssa_name_nodes_reused));
 }
 
 /* Verify the state of the SSA_NAME lists.
index 069d62d51be085f7ad5a710f30f64485994cb7e5..f3e977f5c09f05d2eee727037ae417fca895ca25 100644 (file)
@@ -9226,6 +9226,28 @@ get_call_combined_fn (const_tree call)
   return CFN_LAST;
 }
 
+/* Comparator of indices based on tree_node_counts.  */
+
+static int
+tree_nodes_cmp (const void *p1, const void *p2)
+{
+  const unsigned *n1 = (const unsigned *)p1;
+  const unsigned *n2 = (const unsigned *)p2;
+
+  return tree_node_counts[*n1] - tree_node_counts[*n2];
+}
+
+/* Comparator of indices based on tree_code_counts.  */
+
+static int
+tree_codes_cmp (const void *p1, const void *p2)
+{
+  const unsigned *n1 = (const unsigned *)p1;
+  const unsigned *n2 = (const unsigned *)p2;
+
+  return tree_code_counts[*n1] - tree_code_counts[*n2];
+}
+
 #define TREE_MEM_USAGE_SPACES 40
 
 /* Print debugging information about tree nodes generated during the compile,
@@ -9236,34 +9258,55 @@ dump_tree_statistics (void)
 {
   if (GATHER_STATISTICS)
     {
-      int i;
       uint64_t total_nodes, total_bytes;
       fprintf (stderr, "\nKind                   Nodes      Bytes\n");
       mem_usage::print_dash_line (TREE_MEM_USAGE_SPACES);
       total_nodes = total_bytes = 0;
-      for (i = 0; i < (int) all_kinds; i++)
-       {
-         fprintf (stderr, "%-20s %7" PRIu64 " %10" PRIu64 "\n",
-                  tree_node_kind_names[i], tree_node_counts[i],
-                  tree_node_sizes[i]);
-         total_nodes += tree_node_counts[i];
-         total_bytes += tree_node_sizes[i];
-       }
-      mem_usage::print_dash_line (TREE_MEM_USAGE_SPACES);
-      fprintf (stderr, "%-20s %7" PRIu64 " %10" PRIu64 "\n", "Total",
-              total_nodes, total_bytes);
-      mem_usage::print_dash_line (TREE_MEM_USAGE_SPACES);
-      fprintf (stderr, "Code                   Nodes\n");
-      mem_usage::print_dash_line (TREE_MEM_USAGE_SPACES);
-      for (i = 0; i < (int) MAX_TREE_CODES; i++)
-       fprintf (stderr, "%-32s %7" PRIu64 "\n",
-                get_tree_code_name ((enum tree_code) i), tree_code_counts[i]);
-      mem_usage::print_dash_line (TREE_MEM_USAGE_SPACES);
-      fprintf (stderr, "\n");
-      ssanames_print_statistics ();
-      fprintf (stderr, "\n");
-      phinodes_print_statistics ();
-      fprintf (stderr, "\n");
+
+      {
+       auto_vec<unsigned> indices (all_kinds);
+       for (unsigned i = 0; i < all_kinds; i++)
+         indices.quick_push (i);
+       indices.qsort (tree_nodes_cmp);
+
+       for (unsigned i = 0; i < (int) all_kinds; i++)
+         {
+           unsigned j = indices[i];
+           fprintf (stderr, "%-20s %6" PRIu64 "%c %9" PRIu64 "%c\n",
+                    tree_node_kind_names[i], SIZE_AMOUNT (tree_node_counts[j]),
+                    SIZE_AMOUNT (tree_node_sizes[j]));
+           total_nodes += tree_node_counts[j];
+           total_bytes += tree_node_sizes[j];
+         }
+       mem_usage::print_dash_line (TREE_MEM_USAGE_SPACES);
+       fprintf (stderr, "%-20s %6" PRIu64 "%c %9" PRIu64 "%c\n", "Total",
+                SIZE_AMOUNT (total_nodes), SIZE_AMOUNT (total_bytes));
+       mem_usage::print_dash_line (TREE_MEM_USAGE_SPACES);
+      }
+
+      {
+       fprintf (stderr, "Code                              Nodes\n");
+       mem_usage::print_dash_line (TREE_MEM_USAGE_SPACES);
+
+       auto_vec<unsigned> indices (MAX_TREE_CODES);
+       for (unsigned i = 0; i < MAX_TREE_CODES; i++)
+         indices.quick_push (i);
+       indices.qsort (tree_codes_cmp);
+
+       for (unsigned i = 0; i < MAX_TREE_CODES; i++)
+         {
+           unsigned j = indices[i];
+           fprintf (stderr, "%-32s %6" PRIu64 "%c\n",
+                    get_tree_code_name ((enum tree_code) j),
+                    SIZE_AMOUNT (tree_code_counts[j]));
+         }
+       mem_usage::print_dash_line (TREE_MEM_USAGE_SPACES);
+       fprintf (stderr, "\n");
+       ssanames_print_statistics ();
+       fprintf (stderr, "\n");
+       phinodes_print_statistics ();
+       fprintf (stderr, "\n");
+      }
     }
   else
     fprintf (stderr, "(No per-node statistics)\n");
index bfd52856e4686ae7a8d4b0d2d2f71acf7b2930b2..bd49d0358c5c5002500017e639f35242e21ad26a 100644 (file)
--- a/gcc/vec.c
+++ b/gcc/vec.c
@@ -82,11 +82,16 @@ struct vec_usage: public mem_usage
 
     s[48] = '\0';
 
-    fprintf (stderr, "%-48s %10li%11li:%4.1f%%%10li%10li:%4.1f%%%11li%11li\n", s,
-            (long)m_element_size,
-            (long)m_allocated, m_allocated * 100.0 / total.m_allocated,
-            (long)m_peak, (long)m_times, m_times * 100.0 / total.m_times,
-            (long)m_items, (long)m_items_peak);
+    fprintf (stderr,
+            "%-48s %10zu%10zu%c:%4.1f%%%9zu%c%10zu"
+            ":%4.1f%%%10zu%c%10zu%c\n",
+            s,
+            m_element_size,
+            SIZE_AMOUNT (m_allocated),
+            m_allocated * 100.0 / total.m_allocated,
+            SIZE_AMOUNT (m_peak), m_times,
+            m_times * 100.0 / total.m_times,
+            SIZE_AMOUNT (m_items), SIZE_AMOUNT (m_items_peak));
   }
 
   /* Dump footer.  */
@@ -94,8 +99,9 @@ struct vec_usage: public mem_usage
   dump_footer ()
   {
     print_dash_line ();
-    fprintf (stderr, "%s%55li%25li%17li\n", "Total", (long)m_allocated,
-            (long)m_times, (long)m_items);
+    fprintf (stderr, "%s%64zu%c%25zu%c%16zu%c\n",
+            "Total", SIZE_AMOUNT (m_allocated),
+            SIZE_AMOUNT (m_times), SIZE_AMOUNT (m_items));
     print_dash_line ();
   }
 
This page took 0.121676 seconds and 5 git commands to generate.