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
This commit is contained in:
Dan Nicolaescu 2003-12-22 07:42:43 +00:00 committed by Jim Wilson
parent d9dd2c4ed7
commit 439a7e544d
9 changed files with 423 additions and 308 deletions

View File

@ -1,3 +1,22 @@
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>
* system.h (CONVERT_HARD_REGISTER_TO_SSA_P): Poison.

View File

@ -250,6 +250,9 @@
/* Define if valgrind's memcheck.h header is installed. */
#undef HAVE_MEMCHECK_H
/* Define to enable detailed memory allocation stats gathering. */
#undef GATHER_STATISTICS
/* Always define this when using the GNU C Library */
#undef _GNU_SOURCE

619
gcc/configure vendored

File diff suppressed because it is too large Load Diff

View File

@ -471,6 +471,14 @@ esac],
[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
# -------------------------------

View File

@ -1087,6 +1087,11 @@ want to disable optimization, for performance analysis you want to
enable optimization. When coverage is enabled, the default level is
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
@itemx --disable-nls
The @option{--enable-nls} option enables Native Language Support (NLS),

View File

@ -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
}

View File

@ -138,6 +138,14 @@ const char * const reg_note_name[] =
"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.
Store the length, and initialize all elements to zero. */
@ -152,6 +160,12 @@ rtvec_alloc (int n)
memset (&rt->elem[0], 0, n * sizeof (rtx));
PUT_NUM_ELEM (rt, n);
#ifdef GATHER_STATISTICS
rtvec_alloc_counts++;
rtvec_alloc_sizes += n * sizeof (rtx);
#endif
return rt;
}
@ -171,6 +185,12 @@ rtx_alloc (RTX_CODE code)
memset (rt, 0, RTX_HDR_SIZE);
PUT_CODE (rt, code);
#ifdef GATHER_STATISTICS
rtx_alloc_counts[code]++;
rtx_alloc_sizes[code] += RTX_SIZE (code);
#endif
return rt;
}
@ -417,6 +437,36 @@ rtx_equal_p (rtx x, rtx y)
}
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)
void

View File

@ -1457,6 +1457,7 @@ extern void set_reg_attrs_for_parm (rtx, rtx);
extern rtx rtx_alloc (RTX_CODE);
extern rtvec rtvec_alloc (int);
extern rtx copy_rtx (rtx);
extern void dump_rtx_statistics (void);
/* In emit-rtl.c */
extern rtx copy_rtx_if_shared (rtx);

View File

@ -4548,6 +4548,7 @@ finalize (void)
ggc_print_statistics ();
stringpool_statistics ();
dump_tree_statistics ();
dump_rtx_statistics ();
}
/* Free up memory for the benefit of leak detectors. */