* sbitmap.h (SBITMAP_ELT_BITS): Use "1u" trick as for BITMAP_WORD_BITS.
Move test to check that there is a popcount function for the the number
of bits in SBITMAP_ELT_BITS to sbitmap.c.
* sbitmap.c: Test SBITMAP_ELT_BITS, not HOST_BITS_PER_WIDEST_FAST_INT.
MEM_STAT_INFO): Define in terms of their ALONE counterparts.
* configure.ac (GATHER_STATISTICS): Always define, non-zero if enabled.
* configure: Regenerate.
* statistics.h (GATHER_STATISTICS): Error out if it is not defined.
(GCC_MEM_STAT_ARGUMENTS): New define.
(ALONE_MEM_STAT_DECL): Define in terms of GCC_MEM_STAT_ARGUMENTS.
(ALONE_FINAL_MEM_STAT_DECL, ALONE_FINAL_PASS_MEM_STAT): New defines.
(MEM_STAT_DECL, FINAL_MEM_STAT_DECL, PASS_MEM_STAT, FINAL_PASS_MEM_STAT,
* ggc-internal.h (ggc_record_overhead): Use FINAL_MEM_STAT_DECL.
* ggc.h (ggc_record_overhead, ggc_free_overhead,
ggc_prune_overhead_list): Remove internal prototypes, they are defined
already in ggc-internal.h.
* ggc-common.c (struct loc_descriptor): Remove #ifdef GATHER_STATISTICS
wrappers.
(add_statistics): Likewise.
(dump_ggc_loc_statistics): Likewise. Return if GATHER_STATISTICS is 0.
* ggc-zone.c (struct page_entry): Remove #ifdef GATHER_STATISTICS
wrappers around "survived" and "stats" members.
(alloc_large_page): Always initialize survived.
(ggc_internal_alloc_zone_stat): Likewise.
Remove #ifdef GATHER_STATISTICS wrappers. Record overhead if
GATHER_STATISTICS is non-0.
(ggc_free): Convert #ifdef GATHER_STATISTICS to if-code.
(sweep_pages): Always increase survived.
(ggc_collect_1): Convert #ifdef GATHER_STATISTICS to if-code.
(calculate_average_page_survival): Always define.
(ggc_collect): Convert #ifdef GATHER_STATISTICS to if-code.
(ggc_print_statistics): Likewise.
(ggc_pch_read): Likewise.
* ggc-page.c (struct globals): Always define "stats" member.
(ggc_internal_alloc_stat): Convert #ifdef GATHER_STATISTICS to if-code.
(ggc_free): Likewise.
(ggc_collec): Likewise.
(ggc_print_statistics): Likewise.
* bitmap.h (struct bitmap_head_def): Always define "desc" member.
(bitmap_initialize_stat): Convert #ifdef GATHER_STATISTICS to if-code.
* gimple.h (enum gimple_alloc_kind): Always define.
(gimple_alloc_kind): Likewise.
* tree-flow.h (phinodes_print_statistics): Always define.
(ssanames_print_statistics): Likewise.
* vec.h (vec_heap_free): Always define.
(VEC_stack_alloc): Define if GATHER_STATISTICS is non-0.
* alloc-pool.c (alloc_pool_descriptor): Always define.
(create_alloc_pool): Convert #ifdef GATHER_STATISTICS to if-code.
(empty_alloc_pool): Likewise.
(pool_alloc): Likewise.
(pool_free): Likewise.
(dump_alloc_pool_statistics): Likewise.
(print_statistics): Always define.
* bitmap.c (struct bitmap_descriptor): Always define.
(bitmap_register): Pass ALONE_FINAL_PASS_MEM_STAT.
(register_overhead): Always define.
(bitmap_element_free): Convert #ifdef GATHER_STATISTICS to if-code.
(bitmap_element_allocate): Likewise.
(bitmap_elt_clear_from): Likewise.
(bitmap_obstack_alloc_stat): Likewise.
(bitmap_gc_alloc_stat): Likewise.
(bitmap_obstack_free): Likewise.
(bitmap_find_bit): Likewise.
(bitmap_ior_and_into): Likewise.
(bitmap_print): Likewise.
(dump_bitmap_statistics): Likewise. Return if GATHER_STATISTICS is 0.
* gimple.c (gimple_alloc_counts, gimple_alloc_sizes): Always define.
(gimple_alloc_kind_names): Likewise.
(gimple_alloc_stat): Convert #ifdef GATHER_STATISTICS to if-code.
(dump_gimple_statistics): Likewise. Return if GATHER_STATISTICS is 0.
* rtl.c (rtx_alloc_counts, rtx_alloc_sizes, rtvec_alloc_counts,
rtvec_alloc_sizes): Always define.
(rvec_alloc): Convert #ifdef GATHER_STATISTICS to if-code.
(rtx_alloc_stat): Likewise.
(dump_rtx_statistics): Likewise. Return if GATHER_STATISTICS is 0.
* tree.c (_obstack_allocated_p, tree_code_counts, tree_node_counts,
tree_node_sizes, tree_node_kind_names): Always define.
(record_node_allocation_statistics): Convert #ifdef GATHER_STATISTICS
to if-code.
(type_hash_canon): Likewise.
(dump_tree_statistics): Likewise.
* tree-ssanames.c (ssa_name_nodes_reused, ssa_name_nodes_created):
Always define.
(ssanames_print_statistics): Likewise.
(make_ssa_name_fn): Convert #ifdef GATHER_STATISTICS to if-code.
* tree-phinodes.c (phi_nodes_reused, phi_nodes_created): Always define.
(phinodes_print_statistics): Likewise.
(allocate_phi_node): Convert #ifdef GATHER_STATISTICS to if-code.
* vec.c (struct vec_descriptor): Always define.
(hash_descriptor, eq_descriptor, ptr_hash_entry, hash_ptr, eq_ptr,
vec_descriptor, rester_overhead, free_overhead): Likewise.
(cmp_statistic): Likewise.
(vec_heap_free): Convert #ifdef GATHER_STATISTICS to if-code.
(vec_heap_o_reserve_1): Likewise.
(dump_vec_loc_statistics): Likewise.
cp/
* cp/class.c (n_vtables, n_vtable_entries, n_vtable_searches,
n_vtable_elems, n_convert_harshness, n_compute_conversion_costs,
n_inner_fields_searched): Always define.
(build_primary_vtable): Convert #ifdef GATHER_STATISTICS to if-code.
(print_class_statistics): Convert #ifdef GATHER_STATISTICS to if-code.
* cp/tree.c (depth_reached): Always define global.
(cxx_print_statistics): Convert #ifdef GATHER_STATISTICS to if-code.
* cp/pt.c (depth_reached): Always define.
(push_tinst_level): Convert #ifdef GATHER_STATISTICS to if-code.
* cp/search.c (n_fields_searched, n_calls_lookup_field,
n_calls_lookup_field_1, n_calls_lookup_fnfields,
n_calls_lookup_fnfields_1, n_calls_get_base_type,
n_outer_fields_searched, n_contexts_saved): Always define.
(lookup_field_1): Convert #ifdef GATHER_STATISTICS to if-code.
(lookup_member): Likewise.
(lookup_fnfields_idx_nolazy): Likewise.
(print_search_statistics): Likewise.
(reinit_search_statistics): Unconditionally re-set counters.
* cp/lex.c (retrofit_lang_decl): Convert #ifdef GATHER_STATISTICS
to if-code.
(cxx_dup_lang_specific_decl): Likewise.
(copy_lang_type): Likewise.
(cxx_make_type): Likewise.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@189803
138bc75d-0d04-0410-961f-
82ee72b054a4
+2012-07-24 Steven Bosscher <steven@gcc.gnu.org>
+
+ * sbitmap.h (SBITMAP_ELT_BITS): Use "1u" trick as for BITMAP_WORD_BITS.
+ Move test to check that there is a popcount function for the the number
+ of bits in SBITMAP_ELT_BITS to sbitmap.c.
+ * sbitmap.c: Test SBITMAP_ELT_BITS, not HOST_BITS_PER_WIDEST_FAST_INT.
+ MEM_STAT_INFO): Define in terms of their ALONE counterparts.
+
+ * configure.ac (GATHER_STATISTICS): Always define, non-zero if enabled.
+ * configure: Regenerate.
+ * statistics.h (GATHER_STATISTICS): Error out if it is not defined.
+ (GCC_MEM_STAT_ARGUMENTS): New define.
+ (ALONE_MEM_STAT_DECL): Define in terms of GCC_MEM_STAT_ARGUMENTS.
+ (ALONE_FINAL_MEM_STAT_DECL, ALONE_FINAL_PASS_MEM_STAT): New defines.
+ (MEM_STAT_DECL, FINAL_MEM_STAT_DECL, PASS_MEM_STAT, FINAL_PASS_MEM_STAT,
+ * ggc-internal.h (ggc_record_overhead): Use FINAL_MEM_STAT_DECL.
+ * ggc.h (ggc_record_overhead, ggc_free_overhead,
+ ggc_prune_overhead_list): Remove internal prototypes, they are defined
+ already in ggc-internal.h.
+ * ggc-common.c (struct loc_descriptor): Remove #ifdef GATHER_STATISTICS
+ wrappers.
+ (add_statistics): Likewise.
+ (dump_ggc_loc_statistics): Likewise. Return if GATHER_STATISTICS is 0.
+ * ggc-zone.c (struct page_entry): Remove #ifdef GATHER_STATISTICS
+ wrappers around "survived" and "stats" members.
+ (alloc_large_page): Always initialize survived.
+ (ggc_internal_alloc_zone_stat): Likewise.
+ Remove #ifdef GATHER_STATISTICS wrappers. Record overhead if
+ GATHER_STATISTICS is non-0.
+ (ggc_free): Convert #ifdef GATHER_STATISTICS to if-code.
+ (sweep_pages): Always increase survived.
+ (ggc_collect_1): Convert #ifdef GATHER_STATISTICS to if-code.
+ (calculate_average_page_survival): Always define.
+ (ggc_collect): Convert #ifdef GATHER_STATISTICS to if-code.
+ (ggc_print_statistics): Likewise.
+ (ggc_pch_read): Likewise.
+ * ggc-page.c (struct globals): Always define "stats" member.
+ (ggc_internal_alloc_stat): Convert #ifdef GATHER_STATISTICS to if-code.
+ (ggc_free): Likewise.
+ (ggc_collec): Likewise.
+ (ggc_print_statistics): Likewise.
+ * bitmap.h (struct bitmap_head_def): Always define "desc" member.
+ (bitmap_initialize_stat): Convert #ifdef GATHER_STATISTICS to if-code.
+ * gimple.h (enum gimple_alloc_kind): Always define.
+ (gimple_alloc_kind): Likewise.
+ * tree-flow.h (phinodes_print_statistics): Always define.
+ (ssanames_print_statistics): Likewise.
+ * vec.h (vec_heap_free): Always define.
+ (VEC_stack_alloc): Define if GATHER_STATISTICS is non-0.
+ * alloc-pool.c (alloc_pool_descriptor): Always define.
+ (create_alloc_pool): Convert #ifdef GATHER_STATISTICS to if-code.
+ (empty_alloc_pool): Likewise.
+ (pool_alloc): Likewise.
+ (pool_free): Likewise.
+ (dump_alloc_pool_statistics): Likewise.
+ (print_statistics): Always define.
+ * bitmap.c (struct bitmap_descriptor): Always define.
+ (bitmap_register): Pass ALONE_FINAL_PASS_MEM_STAT.
+ (register_overhead): Always define.
+ (bitmap_element_free): Convert #ifdef GATHER_STATISTICS to if-code.
+ (bitmap_element_allocate): Likewise.
+ (bitmap_elt_clear_from): Likewise.
+ (bitmap_obstack_alloc_stat): Likewise.
+ (bitmap_gc_alloc_stat): Likewise.
+ (bitmap_obstack_free): Likewise.
+ (bitmap_find_bit): Likewise.
+ (bitmap_ior_and_into): Likewise.
+ (bitmap_print): Likewise.
+ (dump_bitmap_statistics): Likewise. Return if GATHER_STATISTICS is 0.
+ * gimple.c (gimple_alloc_counts, gimple_alloc_sizes): Always define.
+ (gimple_alloc_kind_names): Likewise.
+ (gimple_alloc_stat): Convert #ifdef GATHER_STATISTICS to if-code.
+ (dump_gimple_statistics): Likewise. Return if GATHER_STATISTICS is 0.
+ * rtl.c (rtx_alloc_counts, rtx_alloc_sizes, rtvec_alloc_counts,
+ rtvec_alloc_sizes): Always define.
+ (rvec_alloc): Convert #ifdef GATHER_STATISTICS to if-code.
+ (rtx_alloc_stat): Likewise.
+ (dump_rtx_statistics): Likewise. Return if GATHER_STATISTICS is 0.
+ * tree.c (_obstack_allocated_p, tree_code_counts, tree_node_counts,
+ tree_node_sizes, tree_node_kind_names): Always define.
+ (record_node_allocation_statistics): Convert #ifdef GATHER_STATISTICS
+ to if-code.
+ (type_hash_canon): Likewise.
+ (dump_tree_statistics): Likewise.
+ * tree-ssanames.c (ssa_name_nodes_reused, ssa_name_nodes_created):
+ Always define.
+ (ssanames_print_statistics): Likewise.
+ (make_ssa_name_fn): Convert #ifdef GATHER_STATISTICS to if-code.
+ * tree-phinodes.c (phi_nodes_reused, phi_nodes_created): Always define.
+ (phinodes_print_statistics): Likewise.
+ (allocate_phi_node): Convert #ifdef GATHER_STATISTICS to if-code.
+ * vec.c (struct vec_descriptor): Always define.
+ (hash_descriptor, eq_descriptor, ptr_hash_entry, hash_ptr, eq_ptr,
+ vec_descriptor, rester_overhead, free_overhead): Likewise.
+ (cmp_statistic): Likewise.
+ (vec_heap_free): Convert #ifdef GATHER_STATISTICS to if-code.
+ (vec_heap_o_reserve_1): Likewise.
+ (dump_vec_loc_statistics): Likewise.
+
2012-07-24 Richard Guenther <rguenther@suse.de>
PR tree-optimization/53616
(ix86_decompose_address): Allow (zero_extend:DI (subreg:SI (...)))
addresses. Prevent zero extensions of CONST_INT operands.
-2012-07-22 Steven Bosscher <steven@gcc.gnu.org>
+2012-07-23 Steven Bosscher <steven@gcc.gnu.org>
* sbitmap.h (struct int_list): Remove.
(sbitmap_intersect_of_predsucc, sbitmap_union_of_predsucc):
* tree-ssa-alias.c (dump_alias_info): Walk over local decls
instead of referenced vars.
-2012-07-22 Steven Bosscher <steven@gcc.gnu.org>
+2012-07-23 Steven Bosscher <steven@gcc.gnu.org>
* coverage.c: Refer to "notes file" instead of "graph file"
in all comments. Explain history of bbg prefix.
static ALLOC_POOL_ID_TYPE last_id;
#endif
-#ifdef GATHER_STATISTICS
-
/* Store information about each particular alloc_pool. Note that this
will underestimate the amount the amount of storage used by a small amount:
1) The overhead in a pool is not accounted for.
(*slot)->name = name;
return *slot;
}
-#endif
/* Create a pool of things of size SIZE, with NUM in each block we
allocate. */
{
alloc_pool pool;
size_t header_size;
-#ifdef GATHER_STATISTICS
- struct alloc_pool_descriptor *desc;
-#endif
gcc_checking_assert (name);
/* Now align the size to a multiple of 4. */
size = align_eight (size);
-#ifdef ENABLE_CHECKING
- /* Add the aligned size of ID. */
- size += offsetof (allocation_object, u.data);
-#endif
+ if (ENABLE_CHECKING)
+ {
+ /* Add the aligned size of ID. */
+ size += offsetof (allocation_object, u.data);
+ }
/* Um, we can't really allocate 0 elements per block. */
gcc_checking_assert (num);
/* Now init the various pieces of our pool structure. */
pool->name = /*xstrdup (name)*/name;
-#ifdef GATHER_STATISTICS
- desc = alloc_pool_descriptor (name);
- desc->elt_size = size;
- desc->created++;
-#endif
pool->elt_size = size;
pool->elts_per_block = num;
+ if (GATHER_STATISTICS)
+ {
+ struct alloc_pool_descriptor *desc = alloc_pool_descriptor (name);
+ desc->elt_size = size;
+ desc->created++;
+ }
+
/* List header size should be a multiple of 8. */
header_size = align_eight (sizeof (struct alloc_pool_list_def));
empty_alloc_pool (alloc_pool pool)
{
alloc_pool_list block, next_block;
-#ifdef GATHER_STATISTICS
- struct alloc_pool_descriptor *desc = alloc_pool_descriptor (pool->name);
-#endif
gcc_checking_assert (pool);
free (block);
}
-#ifdef GATHER_STATISTICS
- desc->current -= (pool->elts_allocated - pool->elts_free) * pool->elt_size;
-#endif
+ if (GATHER_STATISTICS)
+ {
+ struct alloc_pool_descriptor *desc = alloc_pool_descriptor (pool->name);
+ desc->current -= (pool->elts_allocated - pool->elts_free) * pool->elt_size;
+ }
+
pool->returned_free_list = NULL;
pool->virgin_free_list = NULL;
pool->virgin_elts_remaining = 0;
pool_alloc (alloc_pool pool)
{
alloc_pool_list header;
-#ifdef GATHER_STATISTICS
- struct alloc_pool_descriptor *desc = alloc_pool_descriptor (pool->name);
- desc->allocated += pool->elt_size;
- desc->current += pool->elt_size;
- if (desc->peak < desc->current)
- desc->peak = desc->current;
-#endif
+ if (GATHER_STATISTICS)
+ {
+ struct alloc_pool_descriptor *desc = alloc_pool_descriptor (pool->name);
+
+ desc->allocated += pool->elt_size;
+ desc->current += pool->elt_size;
+ if (desc->peak < desc->current)
+ desc->peak = desc->current;
+ }
gcc_checking_assert (pool);
pool_free (alloc_pool pool, void *ptr)
{
alloc_pool_list header;
-#ifdef GATHER_STATISTICS
- struct alloc_pool_descriptor *desc = alloc_pool_descriptor (pool->name);
-#endif
-
#ifdef ENABLE_CHECKING
gcc_assert (ptr
/* Mark the element to be free. */
ALLOCATION_OBJECT_PTR_FROM_USER_PTR (ptr)->id = 0;
-#else
#endif
header = (alloc_pool_list) ptr;
pool->returned_free_list = header;
pool->elts_free++;
-#ifdef GATHER_STATISTICS
- desc->current -= pool->elt_size;
-#endif
-
+ if (GATHER_STATISTICS)
+ {
+ struct alloc_pool_descriptor *desc = alloc_pool_descriptor (pool->name);
+ desc->current -= pool->elt_size;
+ }
}
+
/* Output per-alloc_pool statistics. */
-#ifdef GATHER_STATISTICS
/* Used to accumulate statistics about alloc_pool sizes. */
struct output_info
}
return 1;
}
-#endif
/* Output per-alloc_pool memory usage statistics. */
void
dump_alloc_pool_statistics (void)
{
-#ifdef GATHER_STATISTICS
struct output_info info;
+ if (! GATHER_STATISTICS)
+ return;
+
if (!alloc_pool_hash)
return;
fprintf (stderr, "%-22s %7lu %10lu\n",
"Total", info.total_created, info.total_allocated);
fprintf (stderr, "--------------------------------------------------------------------------------------------------------------\n");
-#endif
}
#include "bitmap.h"
#include "hashtab.h"
-#ifdef GATHER_STATISTICS
-
/* Store information about each particular bitmap. */
struct bitmap_descriptor
{
void
bitmap_register (bitmap b MEM_STAT_DECL)
{
- b->desc = bitmap_descriptor (_loc_name, _loc_function, _loc_line);
+ b->desc = bitmap_descriptor (ALONE_FINAL_PASS_MEM_STAT);
b->desc->created++;
}
if (b->desc->peak < b->desc->current)
b->desc->peak = b->desc->current;
}
-#endif
/* Global data */
bitmap_element bitmap_zero_bits; /* An element of all zero bits. */
else
head->indx = 0;
}
-#ifdef GATHER_STATISTICS
- register_overhead (head, -((int)sizeof (bitmap_element)));
-#endif
+
+ if (GATHER_STATISTICS)
+ register_overhead (head, -((int)sizeof (bitmap_element)));
+
bitmap_elem_to_freelist (head, elt);
}
\f
element = ggc_alloc_bitmap_element_def ();
}
-#ifdef GATHER_STATISTICS
- register_overhead (head, sizeof (bitmap_element));
-#endif
+ if (GATHER_STATISTICS)
+ register_overhead (head, sizeof (bitmap_element));
+
memset (element->bits, 0, sizeof (element->bits));
return element;
{
bitmap_element *prev;
bitmap_obstack *bit_obstack = head->obstack;
-#ifdef GATHER_STATISTICS
- int n;
-#endif
if (!elt) return;
-#ifdef GATHER_STATISTICS
- n = 0;
- for (prev = elt; prev; prev = prev->next)
- n++;
- register_overhead (head, -sizeof (bitmap_element) * n);
-#endif
+
+ if (GATHER_STATISTICS)
+ {
+ int n = 0;
+ for (prev = elt; prev; prev = prev->next)
+ n++;
+ register_overhead (head, -sizeof (bitmap_element) * n);
+ }
prev = elt->prev;
if (prev)
else
map = XOBNEW (&bit_obstack->obstack, bitmap_head);
bitmap_initialize_stat (map, bit_obstack PASS_MEM_STAT);
-#ifdef GATHER_STATISTICS
- register_overhead (map, sizeof (bitmap_head));
-#endif
+
+ if (GATHER_STATISTICS)
+ register_overhead (map, sizeof (bitmap_head));
return map;
}
map = ggc_alloc_bitmap_head_def ();
bitmap_initialize_stat (map, NULL PASS_MEM_STAT);
-#ifdef GATHER_STATISTICS
- register_overhead (map, sizeof (bitmap_head));
-#endif
+
+ if (GATHER_STATISTICS)
+ register_overhead (map, sizeof (bitmap_head));
return map;
}
{
bitmap_clear (map);
map->first = (bitmap_element *) map->obstack->heads;
-#ifdef GATHER_STATISTICS
- register_overhead (map, -((int)sizeof (bitmap_head)));
-#endif
+
+ if (GATHER_STATISTICS)
+ register_overhead (map, -((int)sizeof (bitmap_head)));
+
map->obstack->heads = map;
}
}
if (head->current == 0
|| head->indx == indx)
return head->current;
-#ifdef GATHER_STATISTICS
- head->desc->nsearches++;
-#endif
+
+ if (GATHER_STATISTICS)
+ head->desc->nsearches++;
if (head->indx < indx)
/* INDX is beyond head->indx. Search from head->current
for (element = head->current;
element->next != 0 && element->indx < indx;
element = element->next)
-#ifdef GATHER_STATISTICS
- head->desc->search_iter++;
-#else
- ;
-#endif
+ {
+ if (GATHER_STATISTICS)
+ head->desc->search_iter++;
+ }
else if (head->indx / 2 < indx)
/* INDX is less than head->indx and closer to head->indx than to
for (element = head->current;
element->prev != 0 && element->indx > indx;
element = element->prev)
-#ifdef GATHER_STATISTICS
- head->desc->search_iter++;
-#else
- ;
-#endif
+ {
+ if (GATHER_STATISTICS)
+ head->desc->search_iter++;
+ }
else
/* INDX is less than head->indx and closer to 0 than to
for (element = head->first;
element->next != 0 && element->indx < indx;
element = element->next)
-#ifdef GATHER_STATISTICS
- head->desc->search_iter++;
-#else
- ;
-#endif
+ if (GATHER_STATISTICS)
+ {
+ head->desc->search_iter++;
+ }
/* `element' is the nearest to the one we want. If it's not the one we
want, the one we want doesn't exist. */
a->indx = a->current->indx;
return changed;
}
+
+/* Compute hash of bitmap (for purposes of hashing). */
+hashval_t
+bitmap_hash (const_bitmap head)
+{
+ const bitmap_element *ptr;
+ BITMAP_WORD hash = 0;
+ int ix;
+
+ for (ptr = head->first; ptr; ptr = ptr->next)
+ {
+ hash ^= ptr->indx;
+ for (ix = 0; ix != BITMAP_ELEMENT_WORDS; ix++)
+ hash ^= ptr->bits[ix];
+ }
+ return (hashval_t)hash;
+}
+
\f
/* Debugging function to print out the contents of a bitmap. */
}
fputs (suffix, file);
}
-#ifdef GATHER_STATISTICS
/* Used to accumulate statistics about bitmap sizes. */
}
return 1;
}
-#endif
+
/* Output per-bitmap memory usage statistics. */
void
dump_bitmap_statistics (void)
{
-#ifdef GATHER_STATISTICS
struct output_info info;
+ if (! GATHER_STATISTICS)
+ return;
+
if (!bitmap_desc_hash)
return;
fprintf (stderr, "%-40s %9d %15"HOST_WIDEST_INT_PRINT"d\n",
"Total", info.count, info.size);
fprintf (stderr, "---------------------------------------------------------------------------------\n");
-#endif
-}
-
-/* Compute hash of bitmap (for purposes of hashing). */
-hashval_t
-bitmap_hash (const_bitmap head)
-{
- const bitmap_element *ptr;
- BITMAP_WORD hash = 0;
- int ix;
-
- for (ptr = head->first; ptr; ptr = ptr->next)
- {
- hash ^= ptr->indx;
- for (ix = 0; ix != BITMAP_ELEMENT_WORDS; ix++)
- hash ^= ptr->bits[ix];
- }
- return (hashval_t)hash;
}
#include "gt-bitmap.h"
unsigned int indx; /* Index of last element looked at. */
bitmap_obstack *obstack; /* Obstack to allocate elements from.
If NULL, then use GGC allocation. */
-#ifdef GATHER_STATISTICS
struct bitmap_descriptor GTY((skip)) *desc;
-#endif
} bitmap_head;
/* Global data */
{
head->first = head->current = NULL;
head->obstack = obstack;
-#ifdef GATHER_STATISTICS
- bitmap_register (head PASS_MEM_STAT);
-#endif
+ if (GATHER_STATISTICS)
+ bitmap_register (head PASS_MEM_STAT);
}
#define bitmap_initialize(h,o) bitmap_initialize_stat (h,o MEM_STAT_INFO)
enable_gather_detailed_mem_stats=no
fi
-if test x$enable_gather_detailed_mem_stats = xyes ; then
+gather_stats=`if test $enable_gather_detailed_mem_stats != no; then echo 1; else echo 0; fi`
-$as_echo "#define GATHER_STATISTICS 1" >>confdefs.h
+cat >>confdefs.h <<_ACEOF
+#define GATHER_STATISTICS $gather_stats
+_ACEOF
-fi
# -------------------------------
# Miscenalleous configure options
[AS_HELP_STRING([--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
+gather_stats=`if test $enable_gather_detailed_mem_stats != no; then echo 1; else echo 0; fi`
+AC_DEFINE_UNQUOTED(GATHER_STATISTICS, $gather_stats,
+[Define to enable detailed memory allocation stats gathering.])
# -------------------------------
# Miscenalleous configure options
+2012-07-24 Steven Bosscher <steven@gcc.gnu.org>
+
+ * cp/class.c (n_vtables, n_vtable_entries, n_vtable_searches,
+ n_vtable_elems, n_convert_harshness, n_compute_conversion_costs,
+ n_inner_fields_searched): Always define.
+ (build_primary_vtable): Convert #ifdef GATHER_STATISTICS to if-code.
+ (print_class_statistics): Convert #ifdef GATHER_STATISTICS to if-code.
+ * cp/tree.c (depth_reached): Always define global.
+ (cxx_print_statistics): Convert #ifdef GATHER_STATISTICS to if-code.
+ * cp/pt.c (depth_reached): Always define.
+ (push_tinst_level): Convert #ifdef GATHER_STATISTICS to if-code.
+ * cp/search.c (n_fields_searched, n_calls_lookup_field,
+ n_calls_lookup_field_1, n_calls_lookup_fnfields,
+ n_calls_lookup_fnfields_1, n_calls_get_base_type,
+ n_outer_fields_searched, n_contexts_saved): Always define.
+ (lookup_field_1): Convert #ifdef GATHER_STATISTICS to if-code.
+ (lookup_member): Likewise.
+ (lookup_fnfields_idx_nolazy): Likewise.
+ (print_search_statistics): Likewise.
+ (reinit_search_statistics): Unconditionally re-set counters.
+ * cp/lex.c (retrofit_lang_decl): Convert #ifdef GATHER_STATISTICS
+ to if-code.
+ (cxx_dup_lang_specific_decl): Likewise.
+ (copy_lang_type): Likewise.
+ (cxx_make_type): Likewise.
+
2012-07-20 Jason Merrill <jason@redhat.com>
PR c++/54038
/* Variables shared between class.c and call.c. */
-#ifdef GATHER_STATISTICS
int n_vtables = 0;
int n_vtable_entries = 0;
int n_vtable_searches = 0;
int n_convert_harshness = 0;
int n_compute_conversion_costs = 0;
int n_inner_fields_searched = 0;
-#endif
/* Convert to or from a base subobject. EXPR is an expression of type
`A' or `A*', an expression of type `B' or `B*' is returned. To
virtuals = NULL_TREE;
}
-#ifdef GATHER_STATISTICS
- n_vtables += 1;
- n_vtable_elems += list_length (virtuals);
-#endif
+ if (GATHER_STATISTICS)
+ {
+ n_vtables += 1;
+ n_vtable_elems += list_length (virtuals);
+ }
/* Initialize the association list for this type, based
on our first approximation. */
void
print_class_statistics (void)
{
-#ifdef GATHER_STATISTICS
+ if (! GATHER_STATISTICS)
+ return;
+
fprintf (stderr, "convert_harshness = %d\n", n_convert_harshness);
fprintf (stderr, "compute_conversion_costs = %d\n", n_compute_conversion_costs);
if (n_vtables)
fprintf (stderr, "vtable entries = %d; vtable elems = %d\n",
n_vtable_entries, n_vtable_elems);
}
-#endif
}
/* Build a dummy reference to ourselves so Derived::Base (and A::A) works,
else
gcc_unreachable ();
-#ifdef GATHER_STATISTICS
- tree_node_counts[(int)lang_decl] += 1;
- tree_node_sizes[(int)lang_decl] += size;
-#endif
+ if (GATHER_STATISTICS)
+ {
+ tree_node_counts[(int)lang_decl] += 1;
+ tree_node_sizes[(int)lang_decl] += size;
+ }
}
void
memcpy (ld, DECL_LANG_SPECIFIC (node), size);
DECL_LANG_SPECIFIC (node) = ld;
-#ifdef GATHER_STATISTICS
- tree_node_counts[(int)lang_decl] += 1;
- tree_node_sizes[(int)lang_decl] += size;
-#endif
+ if (GATHER_STATISTICS)
+ {
+ tree_node_counts[(int)lang_decl] += 1;
+ tree_node_sizes[(int)lang_decl] += size;
+ }
}
/* Copy DECL, including any language-specific parts. */
memcpy (lt, TYPE_LANG_SPECIFIC (node), size);
TYPE_LANG_SPECIFIC (node) = lt;
-#ifdef GATHER_STATISTICS
- tree_node_counts[(int)lang_type] += 1;
- tree_node_sizes[(int)lang_type] += size;
-#endif
+ if (GATHER_STATISTICS)
+ {
+ tree_node_counts[(int)lang_type] += 1;
+ tree_node_sizes[(int)lang_type] += size;
+ }
}
/* Copy TYPE, including any language-specific parts. */
TYPE_LANG_SPECIFIC (t) = pi;
pi->u.c.h.is_lang_type_class = 1;
-#ifdef GATHER_STATISTICS
- tree_node_counts[(int)lang_type] += 1;
- tree_node_sizes[(int)lang_type] += sizeof (struct lang_type);
-#endif
+ if (GATHER_STATISTICS)
+ {
+ tree_node_counts[(int)lang_type] += 1;
+ tree_node_sizes[(int)lang_type] += sizeof (struct lang_type);
+ }
}
/* Set up some flags that give proper default behavior. */
static int tinst_depth;
extern int max_tinst_depth;
-#ifdef GATHER_STATISTICS
int depth_reached;
-#endif
+
static GTY(()) struct tinst_level *last_error_tinst_level;
/* We're starting to instantiate D; record the template instantiation context
current_tinst_level = new_level;
++tinst_depth;
-#ifdef GATHER_STATISTICS
- if (tinst_depth > depth_reached)
+ if (GATHER_STATISTICS && (tinst_depth > depth_reached))
depth_reached = tinst_depth;
-#endif
return 1;
}
\f
/* Variables for gathering statistics. */
-#ifdef GATHER_STATISTICS
static int n_fields_searched;
static int n_calls_lookup_field, n_calls_lookup_field_1;
static int n_calls_lookup_fnfields, n_calls_lookup_fnfields_1;
static int n_calls_get_base_type;
static int n_outer_fields_searched;
static int n_contexts_saved;
-#endif /* GATHER_STATISTICS */
\f
/* Data for lookup_base and its workers. */
{
i = (lo + hi) / 2;
-#ifdef GATHER_STATISTICS
- n_fields_searched++;
-#endif /* GATHER_STATISTICS */
+ if (GATHER_STATISTICS)
+ n_fields_searched++;
if (DECL_NAME (fields[i]) > name)
hi = i;
field = TYPE_FIELDS (type);
-#ifdef GATHER_STATISTICS
- n_calls_lookup_field_1++;
-#endif /* GATHER_STATISTICS */
+ if (GATHER_STATISTICS)
+ n_calls_lookup_field_1++;
+
for (field = TYPE_FIELDS (type); field; field = DECL_CHAIN (field))
{
tree decl = field;
-#ifdef GATHER_STATISTICS
- n_fields_searched++;
-#endif /* GATHER_STATISTICS */
+ if (GATHER_STATISTICS)
+ n_fields_searched++;
+
gcc_assert (DECL_P (field));
if (DECL_NAME (field) == NULL_TREE
&& ANON_AGGR_TYPE_P (TREE_TYPE (field)))
if (!basetype_path)
return NULL_TREE;
-#ifdef GATHER_STATISTICS
- n_calls_lookup_field++;
-#endif /* GATHER_STATISTICS */
+ if (GATHER_STATISTICS)
+ n_calls_lookup_field++;
memset (&lfi, 0, sizeof (lfi));
lfi.type = type;
if (!method_vec)
return -1;
-#ifdef GATHER_STATISTICS
- n_calls_lookup_fnfields_1++;
-#endif /* GATHER_STATISTICS */
+ if (GATHER_STATISTICS)
+ n_calls_lookup_fnfields_1++;
/* Constructors are first... */
if (name == ctor_identifier)
{
i = (lo + hi) / 2;
-#ifdef GATHER_STATISTICS
- n_outer_fields_searched++;
-#endif /* GATHER_STATISTICS */
+ if (GATHER_STATISTICS)
+ n_outer_fields_searched++;
tmp = VEC_index (tree, method_vec, i);
tmp = DECL_NAME (OVL_CURRENT (tmp));
else
for (; VEC_iterate (tree, method_vec, i, fn); ++i)
{
-#ifdef GATHER_STATISTICS
- n_outer_fields_searched++;
-#endif /* GATHER_STATISTICS */
+ if (GATHER_STATISTICS)
+ n_outer_fields_searched++;
if (DECL_NAME (OVL_CURRENT (fn)) == name)
return i;
}
void
print_search_statistics (void)
{
-#ifdef GATHER_STATISTICS
+ if (! GATHER_STATISTICS)
+ {
+ fprintf (stderr, "no search statistics\n");
+ return;
+ }
+
fprintf (stderr, "%d fields searched in %d[%d] calls to lookup_field[_1]\n",
n_fields_searched, n_calls_lookup_field, n_calls_lookup_field_1);
fprintf (stderr, "%d fnfields searched in %d calls to lookup_fnfields\n",
n_outer_fields_searched, n_calls_lookup_fnfields);
fprintf (stderr, "%d calls to get_base_type\n", n_calls_get_base_type);
-#else /* GATHER_STATISTICS */
- fprintf (stderr, "no search statistics\n");
-#endif /* GATHER_STATISTICS */
}
void
reinit_search_statistics (void)
{
-#ifdef GATHER_STATISTICS
n_fields_searched = 0;
n_calls_lookup_field = 0, n_calls_lookup_field_1 = 0;
n_calls_lookup_fnfields = 0, n_calls_lookup_fnfields_1 = 0;
n_calls_get_base_type = 0;
n_outer_fields_searched = 0;
n_contexts_saved = 0;
-#endif /* GATHER_STATISTICS */
}
/* Helper for lookup_conversions_r. TO_TYPE is the type converted to
}
}
-#ifdef GATHER_STATISTICS
extern int depth_reached;
-#endif
void
cxx_print_statistics (void)
print_search_statistics ();
print_class_statistics ();
print_template_statistics ();
-#ifdef GATHER_STATISTICS
- fprintf (stderr, "maximum template instantiation depth reached: %d\n",
- depth_reached);
-#endif
+ if (GATHER_STATISTICS)
+ fprintf (stderr, "maximum template instantiation depth reached: %d\n",
+ depth_reached);
}
/* Return, as an INTEGER_CST node, the number of elements for TYPE
#endif
}
-#ifdef GATHER_STATISTICS
-
/* Datastructure used to store per-call-site statistics. */
struct loc_descriptor
{
}
/* Dump per-site memory statistics. */
-#endif
+
void
-dump_ggc_loc_statistics (bool final ATTRIBUTE_UNUSED)
+dump_ggc_loc_statistics (bool final)
{
-#ifdef GATHER_STATISTICS
int nentries = 0;
char s[4096];
size_t collected = 0, freed = 0, allocated = 0, overhead = 0, times = 0;
int i;
+ if (! GATHER_STATISTICS)
+ return;
+
ggc_force_collect = true;
ggc_collect ();
"source location", "Garbage", "Freed", "Leak", "Overhead", "Times");
fprintf (stderr, "-------------------------------------------------------\n");
ggc_force_collect = false;
-#endif
}
/* When set, ggc_collect will do collection. */
extern bool ggc_force_collect;
-extern void ggc_record_overhead (size_t, size_t, void * MEM_STAT_DECL);
+extern void ggc_record_overhead (size_t, size_t, void * FINAL_MEM_STAT_DECL);
extern void ggc_free_overhead (void *);
struct free_object *free_object_list;
#endif
-#ifdef GATHER_STATISTICS
struct
{
/* Total GC-allocated memory. */
/* The overhead for each of the allocation orders. */
unsigned long long total_overhead_per_order[NUM_ORDERS];
} stats;
-#endif
} G;
/* The size in bytes required to maintain a bitmap for the objects
/* Calculate the object's address. */
result = entry->page + object_offset;
-#ifdef GATHER_STATISTICS
- ggc_record_overhead (OBJECT_SIZE (order), OBJECT_SIZE (order) - size,
- result PASS_MEM_STAT);
-#endif
+ if (GATHER_STATISTICS)
+ ggc_record_overhead (OBJECT_SIZE (order), OBJECT_SIZE (order) - size,
+ result FINAL_PASS_MEM_STAT);
#ifdef ENABLE_GC_CHECKING
/* Keep poisoning-by-writing-0xaf the object, in an attempt to keep the
/* For timevar statistics. */
timevar_ggc_mem_total += object_size;
-#ifdef GATHER_STATISTICS
- {
- size_t overhead = object_size - size;
+ if (GATHER_STATISTICS)
+ {
+ size_t overhead = object_size - size;
- G.stats.total_overhead += overhead;
- G.stats.total_allocated += object_size;
- G.stats.total_overhead_per_order[order] += overhead;
- G.stats.total_allocated_per_order[order] += object_size;
+ G.stats.total_overhead += overhead;
+ G.stats.total_allocated += object_size;
+ G.stats.total_overhead_per_order[order] += overhead;
+ G.stats.total_allocated_per_order[order] += object_size;
- if (size <= 32)
- {
- G.stats.total_overhead_under32 += overhead;
- G.stats.total_allocated_under32 += object_size;
- }
- if (size <= 64)
- {
- G.stats.total_overhead_under64 += overhead;
- G.stats.total_allocated_under64 += object_size;
- }
- if (size <= 128)
- {
- G.stats.total_overhead_under128 += overhead;
- G.stats.total_allocated_under128 += object_size;
- }
- }
-#endif
+ if (size <= 32)
+ {
+ G.stats.total_overhead_under32 += overhead;
+ G.stats.total_allocated_under32 += object_size;
+ }
+ if (size <= 64)
+ {
+ G.stats.total_overhead_under64 += overhead;
+ G.stats.total_allocated_under64 += object_size;
+ }
+ if (size <= 128)
+ {
+ G.stats.total_overhead_under128 += overhead;
+ G.stats.total_allocated_under128 += object_size;
+ }
+ }
if (GGC_DEBUG_LEVEL >= 3)
fprintf (G.debug_file,
size_t order = pe->order;
size_t size = OBJECT_SIZE (order);
-#ifdef GATHER_STATISTICS
- ggc_free_overhead (p);
-#endif
+ if (GATHER_STATISTICS)
+ ggc_free_overhead (p);
if (GGC_DEBUG_LEVEL >= 3)
fprintf (G.debug_file,
clear_marks ();
ggc_mark_roots ();
-#ifdef GATHER_STATISTICS
- ggc_prune_overhead_list ();
-#endif
+
+ if (GATHER_STATISTICS)
+ ggc_prune_overhead_list ();
+
poison_pages ();
validate_free_objects ();
sweep_pages ();
SCALE (G.allocated), STAT_LABEL(G.allocated),
SCALE (total_overhead), STAT_LABEL (total_overhead));
-#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",
- G.stats.total_allocated);
-
- fprintf (stderr, "Total Overhead under 32B: %10lld\n",
- G.stats.total_overhead_under32);
- fprintf (stderr, "Total Allocated under 32B: %10lld\n",
- G.stats.total_allocated_under32);
- fprintf (stderr, "Total Overhead under 64B: %10lld\n",
- G.stats.total_overhead_under64);
- fprintf (stderr, "Total Allocated under 64B: %10lld\n",
- G.stats.total_allocated_under64);
- fprintf (stderr, "Total Overhead under 128B: %10lld\n",
- G.stats.total_overhead_under128);
- fprintf (stderr, "Total Allocated under 128B: %10lld\n",
- 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 %7lu: %10lld\n",
- (unsigned long) OBJECT_SIZE (i),
- G.stats.total_overhead_per_order[i]);
- fprintf (stderr, "Total Allocated page size %7lu: %10lld\n",
- (unsigned long) OBJECT_SIZE (i),
- G.stats.total_allocated_per_order[i]);
- }
+ if (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",
+ G.stats.total_allocated);
+
+ fprintf (stderr, "Total Overhead under 32B: %10lld\n",
+ G.stats.total_overhead_under32);
+ fprintf (stderr, "Total Allocated under 32B: %10lld\n",
+ G.stats.total_allocated_under32);
+ fprintf (stderr, "Total Overhead under 64B: %10lld\n",
+ G.stats.total_overhead_under64);
+ fprintf (stderr, "Total Allocated under 64B: %10lld\n",
+ G.stats.total_allocated_under64);
+ fprintf (stderr, "Total Overhead under 128B: %10lld\n",
+ G.stats.total_overhead_under128);
+ fprintf (stderr, "Total Allocated under 128B: %10lld\n",
+ 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 %7lu: %10lld\n",
+ (unsigned long) OBJECT_SIZE (i),
+ G.stats.total_overhead_per_order[i]);
+ fprintf (stderr, "Total Allocated page size %7lu: %10lld\n",
+ (unsigned long) OBJECT_SIZE (i),
+ G.stats.total_allocated_per_order[i]);
+ }
}
-#endif
}
\f
struct ggc_pch_ondisk
/* The zone that this page entry belongs to. */
struct alloc_zone *zone;
-#ifdef GATHER_STATISTICS
/* How many collections we've survived. */
size_t survived;
-#endif
/* Does this page contain small objects, or one large object? */
bool large_p;
/* True if this zone should be destroyed after the next collection. */
bool dead;
-#ifdef GATHER_STATISTICS
struct
{
/* Total GC-allocated memory. */
unsigned long long total_allocated_under128;
unsigned long long total_overhead_under128;
} stats;
-#endif
} main_zone;
/* Some default zones. */
entry->common.large_p = true;
entry->common.pch_p = false;
entry->common.zone = zone;
-#ifdef GATHER_STATISTICS
entry->common.survived = 0;
-#endif
entry->mark_p = false;
entry->bytes = size;
entry->prev = NULL;
{
struct large_page_entry *entry = alloc_large_page (size, zone);
-#ifdef GATHER_STATISTICS
entry->common.survived = 0;
-#endif
entry->next = zone->large_pages;
if (zone->large_pages)
timevar_ggc_mem_total += size;
-#ifdef GATHER_STATISTICS
- ggc_record_overhead (orig_size, size - orig_size, result PASS_MEM_STAT);
+ if (GATHER_STATISTICS)
+ ggc_record_overhead (orig_size, size - orig_size, result FINAL_PASS_MEM_STAT);
{
size_t object_size = size;
{
struct page_entry *page;
-#ifdef GATHER_STATISTICS
- ggc_free_overhead (p);
-#endif
+ if (GATHER_STATISTICS)
+ ggc_free_overhead (p);
poison_region (p, ggc_get_size (p));
lnext = lp->next;
-#ifdef GATHER_STATISTICS
/* This page has now survived another collection. */
lp->common.survived++;
-#endif
if (lp->mark_p)
{
snext = sp->next;
-#ifdef GATHER_STATISTICS
/* This page has now survived another collection. */
sp->common.survived++;
-#endif
/* Step through all chunks, consolidate those that are free and
insert them into the free lists. Note that consolidation
{
zone_allocate_marks ();
ggc_mark_roots ();
-#ifdef GATHER_STATISTICS
- ggc_prune_overhead_list ();
-#endif
+ if (GATHER_STATISTICS)
+ ggc_prune_overhead_list ();
}
sweep_pages (zone);
return true;
}
-#ifdef GATHER_STATISTICS
/* Calculate the average page survival rate in terms of number of
collections. */
}
return survival/count;
}
-#endif
/* Top level collection routine. */
}
}
-#ifdef GATHER_STATISTICS
/* Print page survival stats, if someone wants them. */
- if (GGC_DEBUG_LEVEL >= 2)
+ if (GATHER_STATISTICS && GGC_DEBUG_LEVEL >= 2)
{
for (zone = G.zones; zone; zone = zone->next_zone)
{
}
}
}
-#endif
if (marked)
zone_free_marks ();
SCALE (total_allocated), LABEL(total_allocated),
SCALE (total_overhead), LABEL (total_overhead));
-#ifdef GATHER_STATISTICS
- {
- unsigned long long all_overhead = 0, all_allocated = 0;
- unsigned long long all_overhead_under32 = 0, all_allocated_under32 = 0;
- unsigned long long all_overhead_under64 = 0, all_allocated_under64 = 0;
- unsigned long long all_overhead_under128 = 0, all_allocated_under128 = 0;
+ if (GATHER_STATISTICS)
+ {
+ unsigned long long all_overhead = 0, all_allocated = 0;
+ unsigned long long all_overhead_under32 = 0, all_allocated_under32 = 0;
+ unsigned long long all_overhead_under64 = 0, all_allocated_under64 = 0;
+ unsigned long long all_overhead_under128 = 0, all_allocated_under128 = 0;
- fprintf (stderr, "\nTotal allocations and overheads during the compilation process\n");
+ fprintf (stderr, "\nTotal allocations and overheads during the compilation process\n");
- for (zone = G.zones; zone; zone = zone->next_zone)
- {
- all_overhead += zone->stats.total_overhead;
- all_allocated += zone->stats.total_allocated;
+ for (zone = G.zones; zone; zone = zone->next_zone)
+ {
+ all_overhead += zone->stats.total_overhead;
+ all_allocated += zone->stats.total_allocated;
- all_allocated_under32 += zone->stats.total_allocated_under32;
- all_overhead_under32 += zone->stats.total_overhead_under32;
+ all_allocated_under32 += zone->stats.total_allocated_under32;
+ all_overhead_under32 += zone->stats.total_overhead_under32;
- all_allocated_under64 += zone->stats.total_allocated_under64;
- all_overhead_under64 += zone->stats.total_overhead_under64;
+ all_allocated_under64 += zone->stats.total_allocated_under64;
+ all_overhead_under64 += zone->stats.total_overhead_under64;
- all_allocated_under128 += zone->stats.total_allocated_under128;
- all_overhead_under128 += zone->stats.total_overhead_under128;
+ all_allocated_under128 += zone->stats.total_allocated_under128;
+ all_overhead_under128 += zone->stats.total_overhead_under128;
- fprintf (stderr, "%20s: %10lld\n",
- zone->name, zone->stats.total_allocated);
- }
+ fprintf (stderr, "%20s: %10lld\n",
+ zone->name, zone->stats.total_allocated);
+ }
- fprintf (stderr, "\n");
-
- fprintf (stderr, "Total Overhead: %10lld\n",
- all_overhead);
- fprintf (stderr, "Total Allocated: %10lld\n",
- all_allocated);
-
- fprintf (stderr, "Total Overhead under 32B: %10lld\n",
- all_overhead_under32);
- fprintf (stderr, "Total Allocated under 32B: %10lld\n",
- all_allocated_under32);
- fprintf (stderr, "Total Overhead under 64B: %10lld\n",
- all_overhead_under64);
- fprintf (stderr, "Total Allocated under 64B: %10lld\n",
- all_allocated_under64);
- fprintf (stderr, "Total Overhead under 128B: %10lld\n",
- all_overhead_under128);
- fprintf (stderr, "Total Allocated under 128B: %10lld\n",
- all_allocated_under128);
- }
-#endif
+ fprintf (stderr, "\n");
+
+ fprintf (stderr, "Total Overhead: %10lld\n",
+ all_overhead);
+ fprintf (stderr, "Total Allocated: %10lld\n",
+ all_allocated);
+
+ fprintf (stderr, "Total Overhead under 32B: %10lld\n",
+ all_overhead_under32);
+ fprintf (stderr, "Total Allocated under 32B: %10lld\n",
+ all_allocated_under32);
+ fprintf (stderr, "Total Overhead under 64B: %10lld\n",
+ all_overhead_under64);
+ fprintf (stderr, "Total Allocated under 64B: %10lld\n",
+ all_allocated_under64);
+ fprintf (stderr, "Total Overhead under 128B: %10lld\n",
+ all_overhead_under128);
+ fprintf (stderr, "Total Allocated under 128B: %10lld\n",
+ all_allocated_under128);
+ }
}
/* Precompiled header support. */
pch_zone.page = (char *) addr;
pch_zone.end = (char *) pch_zone.alloc_bits;
- /* We've just read in a PCH file. So, every object that used to be
- allocated is now free. */
-#ifdef GATHER_STATISTICS
- zone_allocate_marks ();
- ggc_prune_overhead_list ();
- zone_free_marks ();
-#endif
+ if (GATHER_STATISTICS)
+ {
+ /* We've just read in a PCH file. So, every object that used to be
+ allocated is now free. */
+ zone_allocate_marks ();
+ ggc_prune_overhead_list ();
+ zone_free_marks ();
+ }
for (zone = G.zones; zone; zone = zone->next_zone)
{
/* Free a block. To be used when known for certain it's not reachable. */
extern void ggc_free (void *);
-extern void ggc_record_overhead (size_t, size_t, void * MEM_STAT_DECL);
-extern void ggc_free_overhead (void *);
-extern void ggc_prune_overhead_list (void);
-
extern void dump_ggc_loc_statistics (bool);
/* Reallocators. */
};
#undef DEFGSCODE
-#ifdef GATHER_STATISTICS
/* Gimple stats. */
int gimple_alloc_counts[(int) gimple_alloc_kind_all];
"everything else"
};
-#endif /* GATHER_STATISTICS */
-
/* Private API manipulation functions shared only with some
other files. */
extern void gimple_set_stored_syms (gimple, bitmap, bitmap_obstack *);
if (num_ops > 0)
size += sizeof (tree) * (num_ops - 1);
-#ifdef GATHER_STATISTICS
- {
- enum gimple_alloc_kind kind = gimple_alloc_kind (code);
- gimple_alloc_counts[(int) kind]++;
- gimple_alloc_sizes[(int) kind] += size;
- }
-#endif
+ if (GATHER_STATISTICS)
+ {
+ enum gimple_alloc_kind kind = gimple_alloc_kind (code);
+ gimple_alloc_counts[(int) kind]++;
+ gimple_alloc_sizes[(int) kind] += size;
+ }
stmt = ggc_alloc_cleared_gimple_statement_d_stat (size PASS_MEM_STAT);
gimple_set_code (stmt, code);
p->gimple_asm.nl = nlabels;
p->gimple_asm.string = ggc_alloc_string (string, size);
-#ifdef GATHER_STATISTICS
- gimple_alloc_sizes[(int) gimple_alloc_kind (GIMPLE_ASM)] += size;
-#endif
+ if (GATHER_STATISTICS)
+ gimple_alloc_sizes[(int) gimple_alloc_kind (GIMPLE_ASM)] += size;
return p;
}
void
dump_gimple_statistics (void)
{
-#ifdef GATHER_STATISTICS
int i, total_tuples = 0, total_bytes = 0;
+ if (! GATHER_STATISTICS)
+ {
+ fprintf (stderr, "No gimple statistics\n");
+ return;
+ }
+
fprintf (stderr, "\nGIMPLE statements\n");
fprintf (stderr, "Kind Stmts Bytes\n");
fprintf (stderr, "---------------------------------------\n");
fprintf (stderr, "---------------------------------------\n");
fprintf (stderr, "%-20s %7d %10d\n", "Total", total_tuples, total_bytes);
fprintf (stderr, "---------------------------------------\n");
-#else
- fprintf (stderr, "No gimple statistics\n");
-#endif
}
struct walk_stmt_info *);
tree walk_gimple_op (gimple, walk_tree_fn, struct walk_stmt_info *);
-#ifdef GATHER_STATISTICS
/* Enum and arrays used for allocation stats. Keep in sync with
gimple.c:gimple_alloc_kind_names. */
enum gimple_alloc_kind
return gimple_alloc_kind_rest;
}
}
-#endif /* GATHER_STATISTICS */
extern void dump_gimple_statistics (void);
#undef DEF_REG_NOTE
};
-#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
\f
/* Allocate an rtx vector of N elements.
PUT_NUM_ELEM (rt, n);
-#ifdef GATHER_STATISTICS
- rtvec_alloc_counts++;
- rtvec_alloc_sizes += n * sizeof (rtx);
-#endif
+ if (GATHER_STATISTICS)
+ {
+ rtvec_alloc_counts++;
+ rtvec_alloc_sizes += n * sizeof (rtx);
+ }
return rt;
}
memset (rt, 0, RTX_HDR_SIZE);
PUT_CODE (rt, code);
-#ifdef GATHER_STATISTICS
- rtx_alloc_counts[code]++;
- rtx_alloc_sizes[code] += RTX_CODE_SIZE (code);
-#endif
+ if (GATHER_STATISTICS)
+ {
+ rtx_alloc_counts[code]++;
+ rtx_alloc_sizes[code] += RTX_CODE_SIZE (code);
+ }
return rt;
}
void
dump_rtx_statistics (void)
{
-#ifdef GATHER_STATISTICS
int i;
int total_counts = 0;
int total_sizes = 0;
+
+ if (! GATHER_STATISTICS)
+ {
+ fprintf (stderr, "No RTX statistics\n");
+ return;
+ }
+
fprintf (stderr, "\nRTX Kind Count Bytes\n");
fprintf (stderr, "---------------------------------------\n");
for (i = 0; i < LAST_AND_UNUSED_RTX_CODE; i++)
fprintf (stderr, "%-20s %7d %10d\n",
"Total", total_counts, total_sizes);
fprintf (stderr, "---------------------------------------\n");
-#endif
}
\f
#if defined ENABLE_RTL_CHECKING && (GCC_VERSION >= 2007)
#include "coretypes.h"
#include "sbitmap.h"
+/* This suffices for roughly 99% of the hosts we run on, and the rest
+ don't have 256 bit integers. */
+#if SBITMAP_ELT_BITS > 255
+#error Need to increase size of datatype used for popcount
+#endif
+
#if GCC_VERSION >= 3400
-# if HOST_BITS_PER_WIDEST_FAST_INT == HOST_BITS_PER_LONG
+# if SBITMAP_ELT_BITS == HOST_BITS_PER_LONG
# define do_popcount(x) __builtin_popcountl(x)
-# elif HOST_BITS_PER_WIDEST_FAST_INT == HOST_BITS_PER_LONGLONG
+# elif SBITMAP_ELT_BITS == HOST_BITS_PER_LONGLONG
# define do_popcount(x) __builtin_popcountll(x)
# else
# error "internal error: sbitmap.h and hwint.h are inconsistent"
It should be straightforward to convert so for now we keep things simple
while more important issues are dealt with. */
-#define SBITMAP_ELT_BITS ((unsigned) HOST_BITS_PER_WIDEST_FAST_INT)
+#define SBITMAP_ELT_BITS (HOST_BITS_PER_WIDEST_FAST_INT * 1u)
#define SBITMAP_ELT_TYPE unsigned HOST_WIDEST_FAST_INT
-/* Can't use SBITMAP_ELT_BITS in this macro because it contains a
- cast. There is no perfect macro in GCC to test against. This
- suffices for roughly 99% of the hosts we run on, and the rest
- don't have 256 bit integers. */
-#if HOST_BITS_PER_WIDEST_FAST_INT > 255
-#error Need to increase size of datatype used for popcount
-#endif
-
struct simple_bitmap_def
{
unsigned char *popcount; /* Population count. */
#ifndef GCC_STATISTICS
#define GCC_STATISTICS
-#ifdef GATHER_STATISTICS
-#define MEM_STAT_DECL , const char * ARG_UNUSED (_loc_name), int ARG_UNUSED (_loc_line), const char * ARG_UNUSED (_loc_function)
-#define ALONE_MEM_STAT_DECL const char * ARG_UNUSED (_loc_name), int ARG_UNUSED (_loc_line), const char * ARG_UNUSED (_loc_function)
-#define PASS_MEM_STAT , _loc_name, _loc_line, _loc_function
+#if ! defined GATHER_STATISTICS
+#error GATHER_STATISTICS must be defined
+#endif
+
+#define GCC_MEM_STAT_ARGUMENTS const char * ARG_UNUSED (_loc_name), int ARG_UNUSED (_loc_line), const char * ARG_UNUSED (_loc_function)
+#if GATHER_STATISTICS
+#define ALONE_MEM_STAT_DECL GCC_MEM_STAT_ARGUMENTS
+#define ALONE_FINAL_MEM_STAT_DECL ALONE_MEM_STAT_INFO
#define ALONE_PASS_MEM_STAT _loc_name, _loc_line, _loc_function
-#define MEM_STAT_INFO , __FILE__, __LINE__, __FUNCTION__
+#define ALONE_FINAL_PASS_MEM_STAT ALONE_PASS_MEM_STAT
#define ALONE_MEM_STAT_INFO __FILE__, __LINE__, __FUNCTION__
+#define MEM_STAT_DECL , ALONE_MEM_STAT_DECL
+#define FINAL_MEM_STAT_DECL , ALONE_FINAL_MEM_STAT_DECL
+#define PASS_MEM_STAT , ALONE_PASS_MEM_STAT
+#define FINAL_PASS_MEM_STAT , ALONE_FINAL_PASS_MEM_STAT
+#define MEM_STAT_INFO , ALONE_MEM_STAT_INFO
#else
-#define MEM_STAT_DECL
#define ALONE_MEM_STAT_DECL void
-#define PASS_MEM_STAT
+#define ALONE_FINAL_MEM_STAT_DECL GCC_MEM_STAT_ARGUMENTS
#define ALONE_PASS_MEM_STAT
-#define MEM_STAT_INFO
+#define ALONE_FINAL_PASS_MEM_STAT 0,0,0
#define ALONE_MEM_STAT_INFO
+#define MEM_STAT_DECL
+#define FINAL_MEM_STAT_DECL , ALONE_FINAL_MEM_STAT_DECL
+#define PASS_MEM_STAT
+#define FINAL_PASS_MEM_STAT , ALONE_FINAL_PASS_MEM_STAT
+#define MEM_STAT_INFO ALONE_MEM_STAT_INFO
#endif
struct function;
extern void remove_phi_node (gimple_stmt_iterator *, bool);
extern void remove_phi_nodes (basic_block);
extern void release_phi_node (gimple);
-#ifdef GATHER_STATISTICS
extern void phinodes_print_statistics (void);
-#endif
/* In gimple-low.c */
extern void record_vars_into (tree, tree);
extern void adjust_ptr_info_misalignment (struct ptr_info_def *,
unsigned int);
-#ifdef GATHER_STATISTICS
extern void ssanames_print_statistics (void);
-#endif
/* In tree-ssa-ccp.c */
tree fold_const_aggregate_ref (tree);
static int ideal_phi_node_len (int);
-#ifdef GATHER_STATISTICS
unsigned int phi_nodes_reused;
unsigned int phi_nodes_created;
-#endif
/* Dump some simple statistics regarding the re-use of PHI nodes. */
-#ifdef GATHER_STATISTICS
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);
}
-#endif
/* Allocate a PHI node with at least LEN arguments. If the free list
happens to contain a PHI node with LEN arguments or more, return
phi = VEC_pop (gimple, free_phinodes[bucket]);
if (VEC_empty (gimple, free_phinodes[bucket]))
VEC_free (gimple, gc, free_phinodes[bucket]);
-#ifdef GATHER_STATISTICS
- phi_nodes_reused++;
-#endif
+ if (GATHER_STATISTICS)
+ phi_nodes_reused++;
}
else
{
phi = ggc_alloc_gimple_statement_d (size);
-#ifdef GATHER_STATISTICS
- phi_nodes_created++;
+ if (GATHER_STATISTICS)
{
enum gimple_alloc_kind kind = gimple_alloc_kind (GIMPLE_PHI);
- gimple_alloc_counts[(int) kind]++;
- gimple_alloc_sizes[(int) kind] += size;
+ phi_nodes_created++;
+ gimple_alloc_counts[(int) kind]++;
+ gimple_alloc_sizes[(int) kind] += size;
}
-#endif
}
return phi;
numbers after the special ones. */
#define UNUSED_NAME_VERSION 0
-#ifdef GATHER_STATISTICS
unsigned int ssa_name_nodes_reused;
unsigned int ssa_name_nodes_created;
-#endif
/* Initialize management of SSA_NAMEs to default SIZE. If SIZE is
zero use default. */
/* Dump some simple statistics regarding the re-use of SSA_NAME nodes. */
-#ifdef GATHER_STATISTICS
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);
}
-#endif
/* Return an SSA_NAME node for variable VAR defined in statement STMT
in function FN. STMT may be an empty statement for artificial
if (!VEC_empty (tree, FREE_SSANAMES (fn)))
{
t = VEC_pop (tree, FREE_SSANAMES (fn));
-#ifdef GATHER_STATISTICS
- ssa_name_nodes_reused++;
-#endif
+ if (GATHER_STATISTICS)
+ ssa_name_nodes_reused++;
/* The node was cleared out when we put it on the free list, so
there is no need to do so again here. */
t = make_node (SSA_NAME);
SSA_NAME_VERSION (t) = VEC_length (tree, SSANAMES (fn));
VEC_safe_push (tree, gc, SSANAMES (fn), t);
-#ifdef GATHER_STATISTICS
- ssa_name_nodes_created++;
-#endif
+ if (GATHER_STATISTICS)
+ ssa_name_nodes_created++;
}
TREE_TYPE (t) = TREE_TYPE (var);
/* obstack.[ch] explicitly declined to prototype this. */
extern int _obstack_allocated_p (struct obstack *h, void *obj);
-#ifdef GATHER_STATISTICS
/* Statistics-gathering stuff. */
static int tree_code_counts[MAX_TREE_CODES];
"lang_type kinds",
"omp clauses",
};
-#endif /* GATHER_STATISTICS */
/* Unique id for next decl created. */
static GTY(()) int next_decl_uid;
record_node_allocation_statistics (enum tree_code code ATTRIBUTE_UNUSED,
size_t length ATTRIBUTE_UNUSED)
{
-#ifdef GATHER_STATISTICS
enum tree_code_class type = TREE_CODE_CLASS (code);
tree_node_kind kind;
+ if (!GATHER_STATISTICS)
+ return;
+
switch (type)
{
case tcc_declaration: /* A decl node */
tree_code_counts[(int) code]++;
tree_node_counts[(int) kind]++;
tree_node_sizes[(int) kind] += length;
-#endif
}
/* Allocate and return a new UID from the DECL_UID namespace. */
t1 = type_hash_lookup (hashcode, type);
if (t1 != 0)
{
-#ifdef GATHER_STATISTICS
- tree_code_counts[(int) TREE_CODE (type)]--;
- tree_node_counts[(int) t_kind]--;
- tree_node_sizes[(int) t_kind] -= sizeof (struct tree_type_non_common);
-#endif
+ if (GATHER_STATISTICS)
+ {
+ tree_code_counts[(int) TREE_CODE (type)]--;
+ tree_node_counts[(int) t_kind]--;
+ tree_node_sizes[(int) t_kind] -= sizeof (struct tree_type_non_common);
+ }
return t1;
}
else
void
dump_tree_statistics (void)
{
-#ifdef GATHER_STATISTICS
- int i;
- int total_nodes, total_bytes;
-#endif
+ if (GATHER_STATISTICS)
+ {
+ int i;
+ int total_nodes, total_bytes;
+ fprintf (stderr, "Kind Nodes Bytes\n");
+ fprintf (stderr, "---------------------------------------\n");
+ total_nodes = total_bytes = 0;
+ for (i = 0; i < (int) all_kinds; i++)
+ {
+ fprintf (stderr, "%-20s %7d %10d\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];
+ }
+ fprintf (stderr, "---------------------------------------\n");
+ fprintf (stderr, "%-20s %7d %10d\n", "Total", total_nodes, total_bytes);
+ fprintf (stderr, "---------------------------------------\n");
+ fprintf (stderr, "Code Nodes\n");
+ fprintf (stderr, "----------------------------\n");
+ for (i = 0; i < (int) MAX_TREE_CODES; i++)
+ fprintf (stderr, "%-20s %7d\n", tree_code_name[i], tree_code_counts[i]);
+ fprintf (stderr, "----------------------------\n");
+ ssanames_print_statistics ();
+ phinodes_print_statistics ();
+ }
+ else
+ fprintf (stderr, "(No per-node statistics)\n");
- fprintf (stderr, "\n??? tree nodes created\n\n");
-#ifdef GATHER_STATISTICS
- fprintf (stderr, "Kind Nodes Bytes\n");
- fprintf (stderr, "---------------------------------------\n");
- total_nodes = total_bytes = 0;
- for (i = 0; i < (int) all_kinds; i++)
- {
- fprintf (stderr, "%-20s %7d %10d\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];
- }
- fprintf (stderr, "---------------------------------------\n");
- fprintf (stderr, "%-20s %7d %10d\n", "Total", total_nodes, total_bytes);
- fprintf (stderr, "---------------------------------------\n");
- fprintf (stderr, "Code Nodes\n");
- fprintf (stderr, "----------------------------\n");
- for (i = 0; i < (int) MAX_TREE_CODES; i++)
- fprintf (stderr, "%-20s %7d\n", tree_code_name[i], tree_code_counts[i]);
- fprintf (stderr, "----------------------------\n");
- ssanames_print_statistics ();
- phinodes_print_statistics ();
-#else
- fprintf (stderr, "(No per-node statistics)\n");
-#endif
print_type_hash_statistics ();
print_debug_expr_statistics ();
print_value_expr_statistics ();
#include "diagnostic-core.h"
#include "hashtab.h"
-#ifdef GATHER_STATISTICS
-
/* Store information about each particular vector. */
struct vec_descriptor
{
void
vec_heap_free (void *ptr)
{
- free_overhead ((struct vec_prefix *)ptr);
+ if (GATHER_STATISTICS)
+ free_overhead ((struct vec_prefix *)ptr);
free (ptr);
}
-#endif
/* Calculate the new ALLOC value, making sure that RESERVE slots are
free. If EXACT grow exactly, otherwise grow exponentially. */
return NULL;
}
-#ifdef GATHER_STATISTICS
- if (vec)
+ if (GATHER_STATISTICS && vec)
free_overhead (pfx);
-#endif
vec = xrealloc (vec, vec_offset + alloc * elt_size);
((struct vec_prefix *)vec)->alloc = alloc;
if (!pfx)
((struct vec_prefix *)vec)->num = 0;
-#ifdef GATHER_STATISTICS
- if (vec)
+ if (GATHER_STATISTICS && vec)
register_overhead ((struct vec_prefix *)vec,
- vec_offset + alloc * elt_size PASS_MEM_STAT);
-#endif
+ vec_offset + alloc * elt_size FINAL_PASS_MEM_STAT);
return vec;
}
}
#endif
-#ifdef GATHER_STATISTICS
/* Helper for qsort; sort descriptors by amount of memory consumed. */
static int
cmp_statistic (const void *loc1, const void *loc2)
}
/* Dump per-site memory statistics. */
-#endif
+
void
dump_vec_loc_statistics (void)
{
-#ifdef GATHER_STATISTICS
int nentries = 0;
char s[4096];
size_t allocated = 0;
size_t times = 0;
int i;
+ if (! GATHER_STATISTICS)
+ return;
+
loc_array = XCNEWVEC (struct vec_descriptor *, vec_desc_hash->n_elements);
fprintf (stderr, "Heap vectors:\n");
fprintf (stderr, "\n%-48s %10s %10s %10s\n",
fprintf (stderr, "\n%-48s %10s %10s %10s\n",
"source location", "Leak", "Peak", "Times");
fprintf (stderr, "-------------------------------------------------------\n");
-#endif
}
extern void *vec_heap_o_reserve_exact (void *, int, size_t, size_t
MEM_STAT_DECL);
extern void dump_vec_loc_statistics (void);
-#ifdef GATHER_STATISTICS
-void vec_heap_free (void *);
-#else
-/* Avoid problems with frontends that #define free(x). */
-#define vec_heap_free(V) (free) (V)
-#endif
+extern void vec_heap_free (void *);
#if ENABLE_CHECKING
#define VEC_CHECK_INFO ,__FILE__,__LINE__,__FUNCTION__
MEM_STAT_DECL);
extern void vec_stack_free (void *);
-#ifdef GATHER_STATISTICS
+/* Unfortunately, we cannot use MEM_STAT_DECL here. */
+#if GATHER_STATISTICS
#define VEC_stack_alloc(T,alloc,name,line,function) \
(VEC_OP (T,stack,alloc1) \
(alloc, XALLOCAVAR (VEC(T,stack), VEC_embedded_size (T, alloc))))