diff mbox

[02/10] Add stats on adhoc table to dump_line_table_statistics

Message ID 1445632918-29617-3-git-send-email-dmalcolm@redhat.com
State New
Headers show

Commit Message

David Malcolm Oct. 23, 2015, 8:41 p.m. UTC
The stats on line-table memory usage emitted via -fmem-report
from input.c's dump_line_table_statistics don't include
information on the ad-hoc data table.

This patch adds lines like this:
 Ad-hoc table size:                     192k
 Ad-hoc table entries used:            4336

OK for trunk?

gcc/ChangeLog:
	* input.c (dump_line_table_statistics): Dump stats on adhoc table.

libcpp/ChangeLog:
	* include/line-map.h (struct linemap_stats): Add fields
	"adhoc_table_size" and "adhoc_table_entries_used".
	* line-map.c (linemap_get_statistics): Populate above fields.
---
 gcc/input.c               | 6 ++++++
 libcpp/include/line-map.h | 2 ++
 libcpp/line-map.c         | 3 +++
 3 files changed, 11 insertions(+)

Comments

Jeff Law Oct. 23, 2015, 9:02 p.m. UTC | #1
On 10/23/2015 02:41 PM, David Malcolm wrote:
> The stats on line-table memory usage emitted via -fmem-report
> from input.c's dump_line_table_statistics don't include
> information on the ad-hoc data table.
>
> This patch adds lines like this:
>   Ad-hoc table size:                     192k
>   Ad-hoc table entries used:            4336
>
> OK for trunk?
>
> gcc/ChangeLog:
> 	* input.c (dump_line_table_statistics): Dump stats on adhoc table.
>
> libcpp/ChangeLog:
> 	* include/line-map.h (struct linemap_stats): Add fields
> 	"adhoc_table_size" and "adhoc_table_entries_used".
> 	* line-map.c (linemap_get_statistics): Populate above fields.
OK.
jeff
diff mbox

Patch

diff --git a/gcc/input.c b/gcc/input.c
index e7302a4..ff80dd9 100644
--- a/gcc/input.c
+++ b/gcc/input.c
@@ -866,6 +866,12 @@  dump_line_table_statistics (void)
   fprintf (stderr, "Total used maps size:                %5ld%c\n",
            SCALE (total_used_map_size),
            STAT_LABEL (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, "\n");
 }
 
diff --git a/libcpp/include/line-map.h b/libcpp/include/line-map.h
index 30bad87..09378f9 100644
--- a/libcpp/include/line-map.h
+++ b/libcpp/include/line-map.h
@@ -1143,6 +1143,8 @@  struct linemap_stats
   long macro_maps_used_size;
   long macro_maps_locations_size;
   long duplicated_macro_maps_locations_size;
+  long adhoc_table_size;
+  long adhoc_table_entries_used;
 };
 
 /* Return the highest location emitted for a given file for which
diff --git a/libcpp/line-map.c b/libcpp/line-map.c
index 3d82e9b..84403de 100644
--- a/libcpp/line-map.c
+++ b/libcpp/line-map.c
@@ -1712,6 +1712,9 @@  linemap_get_statistics (struct line_maps *set,
   s->macro_maps_used_size = macro_maps_used_size;
   s->duplicated_macro_maps_locations_size =
     duplicated_macro_maps_locations_size;
+  s->adhoc_table_size = (set->location_adhoc_data_map.allocated
+			 * sizeof (struct location_adhoc_data));
+  s->adhoc_table_entries_used = set->location_adhoc_data_map.curr_loc;
 }