Commit 439a7e54 by Dan Nicolaescu Committed by Jim Wilson

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
parent d9dd2c4e
2003-12-21 Dan Nicolaescu <dann@ics.uci.edu>
* 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.
2003-12-22 Kazu Hirata <kazu@cs.umass.edu> 2003-12-22 Kazu Hirata <kazu@cs.umass.edu>
* system.h (CONVERT_HARD_REGISTER_TO_SSA_P): Poison. * system.h (CONVERT_HARD_REGISTER_TO_SSA_P): Poison.
......
...@@ -250,6 +250,9 @@ ...@@ -250,6 +250,9 @@
/* Define if valgrind's memcheck.h header is installed. */ /* Define if valgrind's memcheck.h header is installed. */
#undef HAVE_MEMCHECK_H #undef HAVE_MEMCHECK_H
/* Define to enable detailed memory allocation stats gathering. */
#undef GATHER_STATISTICS
/* Always define this when using the GNU C Library */ /* Always define this when using the GNU C Library */
#undef _GNU_SOURCE #undef _GNU_SOURCE
......
...@@ -471,6 +471,14 @@ esac], ...@@ -471,6 +471,14 @@ esac],
[coverage_flags=""]) [coverage_flags=""])
AC_SUBST(coverage_flags) AC_SUBST(coverage_flags)
AC_ARG_ENABLE(gather-detailed-mem-stats,
[ --enable-gather-detailed-mem-stats enable detailed memory allocation stats gathering], [],
[enable_gather_detailed_mem_stats=no])
if test x$enable_gather_detailed_mem_stats = xyes ; then
AC_DEFINE(GATHER_STATISTICS, 1,
[Define to enable detailed memory allocation stats gathering.])
fi
# ------------------------------- # -------------------------------
# Miscenalleous configure options # Miscenalleous configure options
# ------------------------------- # -------------------------------
......
...@@ -1087,6 +1087,11 @@ want to disable optimization, for performance analysis you want to ...@@ -1087,6 +1087,11 @@ want to disable optimization, for performance analysis you want to
enable optimization. When coverage is enabled, the default level is enable optimization. When coverage is enabled, the default level is
without optimization. without optimization.
@item --enable-gather-detailed-mem-stats
When this option is specfied more detailed information on memory
allocation is gathered. This information is printed when using
@option{-fmem-report}.
@item --enable-nls @item --enable-nls
@itemx --disable-nls @itemx --disable-nls
The @option{--enable-nls} option enables Native Language Support (NLS), The @option{--enable-nls} option enables Native Language Support (NLS),
......
...@@ -401,13 +401,12 @@ static struct globals ...@@ -401,13 +401,12 @@ static struct globals
zero otherwise. We allocate them all together, to enable a zero otherwise. We allocate them all together, to enable a
better runtime data access pattern. */ better runtime data access pattern. */
unsigned long **save_in_use; unsigned long **save_in_use;
#ifdef GATHER_STATISTICS #ifdef GATHER_STATISTICS
struct struct
{ {
/* Total memory allocated with ggc_alloc */ /* Total memory allocated with ggc_alloc. */
unsigned long long total_allocated; 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; unsigned long long total_overhead;
/* Total allocations and overhead for sizes less than 32, 64 and 128. /* Total allocations and overhead for sizes less than 32, 64 and 128.
...@@ -423,6 +422,9 @@ static struct globals ...@@ -423,6 +422,9 @@ static struct globals
unsigned long long total_allocated_under128; unsigned long long total_allocated_under128;
unsigned long long total_overhead_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. */ /* The overhead for each of the allocation orders. */
unsigned long long total_overhead_per_order[NUM_ORDERS]; unsigned long long total_overhead_per_order[NUM_ORDERS];
} stats; } stats;
...@@ -1171,8 +1173,9 @@ ggc_alloc (size_t size) ...@@ -1171,8 +1173,9 @@ ggc_alloc (size_t size)
#ifdef GATHER_STATISTICS #ifdef GATHER_STATISTICS
{ {
G.stats.total_overhead += OBJECT_SIZE (order) - size; 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_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){ if (size <= 32){
G.stats.total_overhead_under32 += OBJECT_SIZE (order) - size; G.stats.total_overhead_under32 += OBJECT_SIZE (order) - size;
...@@ -1844,6 +1847,8 @@ ggc_print_statistics (void) ...@@ -1844,6 +1847,8 @@ ggc_print_statistics (void)
/* Collect some information about the various sizes of /* Collect some information about the various sizes of
allocation. */ allocation. */
fprintf (stderr,
"Memory still allocated at the end of the compilation process\n");
fprintf (stderr, "%-5s %10s %10s %10s\n", fprintf (stderr, "%-5s %10s %10s %10s\n",
"Size", "Allocated", "Used", "Overhead"); "Size", "Allocated", "Used", "Overhead");
for (i = 0; i < NUM_ORDERS; ++i) for (i = 0; i < NUM_ORDERS; ++i)
...@@ -1885,6 +1890,8 @@ ggc_print_statistics (void) ...@@ -1885,6 +1890,8 @@ ggc_print_statistics (void)
#ifdef GATHER_STATISTICS #ifdef GATHER_STATISTICS
{ {
fprintf (stderr, "\nTotal allocations and overheads during the compilation process\n");
fprintf (stderr, "Total Overhead: %10lld\n", fprintf (stderr, "Total Overhead: %10lld\n",
G.stats.total_overhead); G.stats.total_overhead);
fprintf (stderr, "Total Allocated: %10lld\n", fprintf (stderr, "Total Allocated: %10lld\n",
...@@ -1904,9 +1911,13 @@ ggc_print_statistics (void) ...@@ -1904,9 +1911,13 @@ ggc_print_statistics (void)
G.stats.total_allocated_under128); G.stats.total_allocated_under128);
for (i = 0; i < NUM_ORDERS; i++) for (i = 0; i < NUM_ORDERS; i++)
if (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 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 #endif
} }
......
...@@ -138,6 +138,14 @@ const char * const reg_note_name[] = ...@@ -138,6 +138,14 @@ const char * const reg_note_name[] =
"REG_VTABLE_REF" "REG_VTABLE_REF"
}; };
#ifdef GATHER_STATISTICS
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;
#endif
/* Allocate an rtx vector of N elements. /* Allocate an rtx vector of N elements.
Store the length, and initialize all elements to zero. */ Store the length, and initialize all elements to zero. */
...@@ -152,6 +160,12 @@ rtvec_alloc (int n) ...@@ -152,6 +160,12 @@ rtvec_alloc (int n)
memset (&rt->elem[0], 0, n * sizeof (rtx)); memset (&rt->elem[0], 0, n * sizeof (rtx));
PUT_NUM_ELEM (rt, n); PUT_NUM_ELEM (rt, n);
#ifdef GATHER_STATISTICS
rtvec_alloc_counts++;
rtvec_alloc_sizes += n * sizeof (rtx);
#endif
return rt; return rt;
} }
...@@ -171,6 +185,12 @@ rtx_alloc (RTX_CODE code) ...@@ -171,6 +185,12 @@ rtx_alloc (RTX_CODE code)
memset (rt, 0, RTX_HDR_SIZE); memset (rt, 0, RTX_HDR_SIZE);
PUT_CODE (rt, code); PUT_CODE (rt, code);
#ifdef GATHER_STATISTICS
rtx_alloc_counts[code]++;
rtx_alloc_sizes[code] += RTX_SIZE (code);
#endif
return rt; return rt;
} }
...@@ -417,6 +437,36 @@ rtx_equal_p (rtx x, rtx y) ...@@ -417,6 +437,36 @@ rtx_equal_p (rtx x, rtx y)
} }
return 1; return 1;
} }
void dump_rtx_statistics (void)
{
#ifdef GATHER_STATISTICS
int i;
int total_counts = 0;
int total_sizes = 0;
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];
}
if (rtvec_alloc_counts)
{
fprintf (stderr, "%-20s %7d %10d\n", "rtvec",
rtvec_alloc_counts, 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");
#endif
}
#if defined ENABLE_RTL_CHECKING && (GCC_VERSION >= 2007) #if defined ENABLE_RTL_CHECKING && (GCC_VERSION >= 2007)
void void
......
...@@ -1457,6 +1457,7 @@ extern void set_reg_attrs_for_parm (rtx, rtx); ...@@ -1457,6 +1457,7 @@ extern void set_reg_attrs_for_parm (rtx, rtx);
extern rtx rtx_alloc (RTX_CODE); extern rtx rtx_alloc (RTX_CODE);
extern rtvec rtvec_alloc (int); extern rtvec rtvec_alloc (int);
extern rtx copy_rtx (rtx); extern rtx copy_rtx (rtx);
extern void dump_rtx_statistics (void);
/* In emit-rtl.c */ /* In emit-rtl.c */
extern rtx copy_rtx_if_shared (rtx); extern rtx copy_rtx_if_shared (rtx);
......
...@@ -4548,6 +4548,7 @@ finalize (void) ...@@ -4548,6 +4548,7 @@ finalize (void)
ggc_print_statistics (); ggc_print_statistics ();
stringpool_statistics (); stringpool_statistics ();
dump_tree_statistics (); dump_tree_statistics ();
dump_rtx_statistics ();
} }
/* Free up memory for the benefit of leak detectors. */ /* Free up memory for the benefit of leak detectors. */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment