From 439a7e544da9c5f6e9c1b14ec054e3bdda7eddc2 Mon Sep 17 00:00:00 2001 From: Dan Nicolaescu Date: Mon, 22 Dec 2003 07:42:43 +0000 Subject: Patch from Dan Nicolaescu * rtl.h (dump_rtx_statistics): Declare it. * rtl.c (rtx_alloc_counts, rtx_alloc_sizes, rtvec_alloc_counts, rtx_alloc_sizes): New static vars. (rtx_alloc, rtvec_alloc): Update them. (dump_rtx_statistics): New function. * toplev.c (finalize): Call it. * ggc-page.c (struct globals): Fix comments. Add new member total_allocated_per_order. (ggc_alloc): Keep track of the total allocated memory. (ggc_print_statistics): Clarify message. Print total allocated memory stats. * configure.in (gather-detailed-mem-stats): New flag. * configure: Regenerate. * config.in: Regenerate. * doc/install.texi (Configuration): Document --enable-gather-detailed-mem-stats. From-SVN: r74930 --- gcc/ggc-page.c | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) (limited to 'gcc/ggc-page.c') diff --git a/gcc/ggc-page.c b/gcc/ggc-page.c index 0f73411..bf18e3f 100644 --- a/gcc/ggc-page.c +++ b/gcc/ggc-page.c @@ -401,13 +401,12 @@ static struct globals zero otherwise. We allocate them all together, to enable a better runtime data access pattern. */ unsigned long **save_in_use; - #ifdef GATHER_STATISTICS struct { - /* Total memory allocated with ggc_alloc */ + /* Total memory allocated with ggc_alloc. */ unsigned long long total_allocated; - /* Total overhead for memory to be allocated with ggc_alloc */ + /* Total overhead for memory to be allocated with ggc_alloc. */ unsigned long long total_overhead; /* Total allocations and overhead for sizes less than 32, 64 and 128. @@ -423,6 +422,9 @@ static struct globals unsigned long long total_allocated_under128; unsigned long long total_overhead_under128; + /* The allocations for each of the allocation orders. */ + unsigned long long total_allocated_per_order[NUM_ORDERS]; + /* The overhead for each of the allocation orders. */ unsigned long long total_overhead_per_order[NUM_ORDERS]; } stats; @@ -1171,8 +1173,9 @@ ggc_alloc (size_t size) #ifdef GATHER_STATISTICS { G.stats.total_overhead += OBJECT_SIZE (order) - size; - G.stats.total_overhead_per_order[order] += OBJECT_SIZE (order) - size; G.stats.total_allocated += OBJECT_SIZE(order); + G.stats.total_overhead_per_order[order] += OBJECT_SIZE (order) - size; + G.stats.total_allocated_per_order[order] += OBJECT_SIZE (order); if (size <= 32){ G.stats.total_overhead_under32 += OBJECT_SIZE (order) - size; @@ -1844,6 +1847,8 @@ ggc_print_statistics (void) /* Collect some information about the various sizes of allocation. */ + fprintf (stderr, + "Memory still allocated at the end of the compilation process\n"); fprintf (stderr, "%-5s %10s %10s %10s\n", "Size", "Allocated", "Used", "Overhead"); for (i = 0; i < NUM_ORDERS; ++i) @@ -1885,6 +1890,8 @@ ggc_print_statistics (void) #ifdef GATHER_STATISTICS { + fprintf (stderr, "\nTotal allocations and overheads during the compilation process\n"); + fprintf (stderr, "Total Overhead: %10lld\n", G.stats.total_overhead); fprintf (stderr, "Total Allocated: %10lld\n", @@ -1904,9 +1911,13 @@ ggc_print_statistics (void) G.stats.total_allocated_under128); for (i = 0; i < NUM_ORDERS; i++) - if (G.stats.total_overhead_per_order[i]) - fprintf (stderr, "Total Overhead page size %7d: %10lld\n", - OBJECT_SIZE (i), G.stats.total_overhead_per_order[i]); + if (G.stats.total_allocated_per_order[i]) + { + fprintf (stderr, "Total Overhead page size %7d: %10lld\n", + OBJECT_SIZE (i), G.stats.total_overhead_per_order[i]); + fprintf (stderr, "Total Allocated page size %7d: %10lld\n", + OBJECT_SIZE (i), G.stats.total_allocated_per_order[i]); + } } #endif } -- cgit v1.1