diff options
author | steven <steven@138bc75d-0d04-0410-961f-82ee72b054a4> | 2012-07-24 09:49:56 +0000 |
---|---|---|
committer | steven <steven@138bc75d-0d04-0410-961f-82ee72b054a4> | 2012-07-24 09:49:56 +0000 |
commit | ecd52ea9dc3f3adb75bdc4f4897dfbb455a5d0f8 (patch) | |
tree | 7524c306e4effe5958489e003d2bb147a0439144 | |
parent | ed74aa4415517f167aefeda7baadce6d572f713a (diff) | |
download | gcc-ecd52ea9dc3f3adb75bdc4f4897dfbb455a5d0f8.tar.gz |
gcc/
* 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
-rw-r--r-- | gcc/ChangeLog | 103 | ||||
-rw-r--r-- | gcc/alloc-pool.c | 77 | ||||
-rw-r--r-- | gcc/bitmap.c | 130 | ||||
-rw-r--r-- | gcc/bitmap.h | 7 | ||||
-rwxr-xr-x | gcc/configure | 7 | ||||
-rw-r--r-- | gcc/configure.ac | 7 | ||||
-rw-r--r-- | gcc/cp/ChangeLog | 26 | ||||
-rw-r--r-- | gcc/cp/class.c | 16 | ||||
-rw-r--r-- | gcc/cp/lex.c | 36 | ||||
-rw-r--r-- | gcc/cp/pt.c | 7 | ||||
-rw-r--r-- | gcc/cp/search.c | 51 | ||||
-rw-r--r-- | gcc/cp/tree.c | 9 | ||||
-rw-r--r-- | gcc/ggc-common.c | 11 | ||||
-rw-r--r-- | gcc/ggc-internal.h | 2 | ||||
-rw-r--r-- | gcc/ggc-page.c | 133 | ||||
-rw-r--r-- | gcc/ggc-zone.c | 128 | ||||
-rw-r--r-- | gcc/ggc.h | 4 | ||||
-rw-r--r-- | gcc/gimple.c | 31 | ||||
-rw-r--r-- | gcc/gimple.h | 2 | ||||
-rw-r--r-- | gcc/rtl.c | 29 | ||||
-rw-r--r-- | gcc/sbitmap.c | 10 | ||||
-rw-r--r-- | gcc/sbitmap.h | 10 | ||||
-rw-r--r-- | gcc/statistics.h | 29 | ||||
-rw-r--r-- | gcc/tree-flow.h | 4 | ||||
-rw-r--r-- | gcc/tree-phinodes.c | 18 | ||||
-rw-r--r-- | gcc/tree-ssanames.c | 14 | ||||
-rw-r--r-- | gcc/tree.c | 74 | ||||
-rw-r--r-- | gcc/vec.c | 24 | ||||
-rw-r--r-- | gcc/vec.h | 10 |
29 files changed, 534 insertions, 475 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 6c386867b1c..c74db97fa1d 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,102 @@ +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 @@ -95,7 +194,7 @@ (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): @@ -127,7 +226,7 @@ * 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. diff --git a/gcc/alloc-pool.c b/gcc/alloc-pool.c index 4dbd0fd570d..5a1ada70802 100644 --- a/gcc/alloc-pool.c +++ b/gcc/alloc-pool.c @@ -62,8 +62,6 @@ typedef struct allocation_object_def 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. @@ -123,7 +121,6 @@ alloc_pool_descriptor (const char *name) (*slot)->name = name; return *slot; } -#endif /* Create a pool of things of size SIZE, with NUM in each block we allocate. */ @@ -133,9 +130,6 @@ create_alloc_pool (const char *name, size_t size, size_t num) { alloc_pool pool; size_t header_size; -#ifdef GATHER_STATISTICS - struct alloc_pool_descriptor *desc; -#endif gcc_checking_assert (name); @@ -146,10 +140,11 @@ create_alloc_pool (const char *name, size_t size, size_t num) /* 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); @@ -159,14 +154,16 @@ create_alloc_pool (const char *name, size_t size, size_t 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)); @@ -197,9 +194,6 @@ void 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); @@ -210,9 +204,12 @@ empty_alloc_pool (alloc_pool 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; @@ -251,14 +248,16 @@ void * 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); @@ -324,10 +323,6 @@ void 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 @@ -340,7 +335,6 @@ pool_free (alloc_pool pool, void *ptr) /* Mark the element to be free. */ ALLOCATION_OBJECT_PTR_FROM_USER_PTR (ptr)->id = 0; -#else #endif header = (alloc_pool_list) ptr; @@ -348,13 +342,14 @@ pool_free (alloc_pool pool, void *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 @@ -382,15 +377,16 @@ print_statistics (void **slot, void *b) } 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; @@ -403,5 +399,4 @@ dump_alloc_pool_statistics (void) fprintf (stderr, "%-22s %7lu %10lu\n", "Total", info.total_created, info.total_allocated); fprintf (stderr, "--------------------------------------------------------------------------------------------------------------\n"); -#endif } diff --git a/gcc/bitmap.c b/gcc/bitmap.c index 8d7f1b2aa95..2b779677550 100644 --- a/gcc/bitmap.c +++ b/gcc/bitmap.c @@ -26,8 +26,6 @@ along with GCC; see the file COPYING3. If not see #include "bitmap.h" #include "hashtab.h" -#ifdef GATHER_STATISTICS - /* Store information about each particular bitmap. */ struct bitmap_descriptor { @@ -99,7 +97,7 @@ bitmap_descriptor (const char *file, const char *function, int line) 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++; } @@ -114,7 +112,6 @@ register_overhead (bitmap b, int amount) 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. */ @@ -180,9 +177,10 @@ bitmap_element_free (bitmap head, bitmap_element *elt) 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); } @@ -230,9 +228,9 @@ bitmap_element_allocate (bitmap head) 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; @@ -245,17 +243,16 @@ bitmap_elt_clear_from (bitmap head, bitmap_element *elt) { 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) @@ -358,9 +355,9 @@ bitmap_obstack_alloc_stat (bitmap_obstack *bit_obstack MEM_STAT_DECL) 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; } @@ -374,9 +371,9 @@ bitmap_gc_alloc_stat (ALONE_MEM_STAT_DECL) 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; } @@ -390,9 +387,10 @@ bitmap_obstack_free (bitmap 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; } } @@ -557,9 +555,9 @@ bitmap_find_bit (bitmap head, unsigned int bit) 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 @@ -567,11 +565,10 @@ bitmap_find_bit (bitmap head, unsigned int bit) 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 @@ -579,11 +576,10 @@ bitmap_find_bit (bitmap head, unsigned int bit) 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 @@ -591,11 +587,10 @@ bitmap_find_bit (bitmap head, unsigned int bit) 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. */ @@ -2032,6 +2027,24 @@ bitmap_ior_and_into (bitmap a, const_bitmap b, const_bitmap c) 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; +} + /* Debugging function to print out the contents of a bitmap. */ @@ -2099,7 +2112,6 @@ bitmap_print (FILE *file, const_bitmap head, const char *prefix, const char *suf } fputs (suffix, file); } -#ifdef GATHER_STATISTICS /* Used to accumulate statistics about bitmap sizes. */ @@ -2135,14 +2147,16 @@ print_statistics (void **slot, void *b) } 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; @@ -2157,24 +2171,6 @@ dump_bitmap_statistics (void) 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" diff --git a/gcc/bitmap.h b/gcc/bitmap.h index 411443f360f..b6edc244030 100644 --- a/gcc/bitmap.h +++ b/gcc/bitmap.h @@ -78,9 +78,7 @@ typedef struct GTY(()) bitmap_head_def { 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 */ @@ -166,9 +164,8 @@ bitmap_initialize_stat (bitmap head, bitmap_obstack *obstack MEM_STAT_DECL) { 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) diff --git a/gcc/configure b/gcc/configure index 817b3d6e88b..a457d3eb3ac 100755 --- a/gcc/configure +++ b/gcc/configure @@ -6986,11 +6986,12 @@ else 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 diff --git a/gcc/configure.ac b/gcc/configure.ac index 44d96a98216..e4069e8d042 100644 --- a/gcc/configure.ac +++ b/gcc/configure.ac @@ -588,10 +588,9 @@ AC_ARG_ENABLE(gather-detailed-mem-stats, [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 diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 07ed0a0a5eb..90064b29775 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,29 @@ +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 diff --git a/gcc/cp/class.c b/gcc/cp/class.c index 96a742097a8..7ccbccbc0bd 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -212,7 +212,6 @@ static tree get_vcall_index (tree, tree); /* 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; @@ -220,7 +219,6 @@ int n_vtable_elems = 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 @@ -836,10 +834,11 @@ build_primary_vtable (tree binfo, tree type) 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. */ @@ -7332,7 +7331,9 @@ get_vfield_name (tree type) 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) @@ -7342,7 +7343,6 @@ print_class_statistics (void) 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, diff --git a/gcc/cp/lex.c b/gcc/cp/lex.c index 743f4752c1c..54021f1e351 100644 --- a/gcc/cp/lex.c +++ b/gcc/cp/lex.c @@ -571,10 +571,11 @@ retrofit_lang_decl (tree t) 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 @@ -601,10 +602,11 @@ cxx_dup_lang_specific_decl (tree node) 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. */ @@ -638,10 +640,11 @@ copy_lang_type (tree node) 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. */ @@ -671,10 +674,11 @@ cxx_make_type (enum tree_code code) 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. */ diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 0d253982233..1e70213a636 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -7754,9 +7754,8 @@ limit_bad_template_recursion (tree decl) 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 @@ -7799,10 +7798,8 @@ push_tinst_level (tree d) 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; } diff --git a/gcc/cp/search.c b/gcc/cp/search.c index 048fdf3270a..dc802e4e9a2 100644 --- a/gcc/cp/search.c +++ b/gcc/cp/search.c @@ -66,14 +66,12 @@ static tree dfs_get_pure_virtuals (tree, void *); /* 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 */ /* Data for lookup_base and its workers. */ @@ -407,9 +405,8 @@ lookup_field_1 (tree type, tree name, bool want_type) { 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; @@ -454,16 +451,16 @@ lookup_field_1 (tree type, tree name, bool want_type) 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))) @@ -1203,9 +1200,8 @@ lookup_member (tree xbasetype, tree name, int protect, bool want_type, 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; @@ -1370,9 +1366,8 @@ lookup_fnfields_idx_nolazy (tree type, tree name) 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) @@ -1408,9 +1403,8 @@ lookup_fnfields_idx_nolazy (tree type, tree name) { 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)); @@ -1425,9 +1419,8 @@ lookup_fnfields_idx_nolazy (tree type, tree name) 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; } @@ -2207,28 +2200,28 @@ note_debug_info_needed (tree type) 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 diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index 83b8ca7ad1c..26e7fced793 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -2044,9 +2044,7 @@ no_linkage_check (tree t, bool relaxed_p) } } -#ifdef GATHER_STATISTICS extern int depth_reached; -#endif void cxx_print_statistics (void) @@ -2054,10 +2052,9 @@ 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 diff --git a/gcc/ggc-common.c b/gcc/ggc-common.c index 3ff64ffdd7d..6a997238629 100644 --- a/gcc/ggc-common.c +++ b/gcc/ggc-common.c @@ -845,8 +845,6 @@ init_ggc_heuristics (void) #endif } -#ifdef GATHER_STATISTICS - /* Datastructure used to store per-call-site statistics. */ struct loc_descriptor { @@ -1040,16 +1038,18 @@ add_statistics (void **slot, void *b) } /* 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 (); @@ -1102,5 +1102,4 @@ dump_ggc_loc_statistics (bool final ATTRIBUTE_UNUSED) "source location", "Garbage", "Freed", "Leak", "Overhead", "Times"); fprintf (stderr, "-------------------------------------------------------\n"); ggc_force_collect = false; -#endif } diff --git a/gcc/ggc-internal.h b/gcc/ggc-internal.h index 7b875eec9cb..dcb048777e5 100644 --- a/gcc/ggc-internal.h +++ b/gcc/ggc-internal.h @@ -94,7 +94,7 @@ extern void ggc_pch_read (FILE *, void *); /* 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 *); diff --git a/gcc/ggc-page.c b/gcc/ggc-page.c index ff23092b1d7..d3d186d8d7f 100644 --- a/gcc/ggc-page.c +++ b/gcc/ggc-page.c @@ -432,7 +432,6 @@ static struct globals struct free_object *free_object_list; #endif -#ifdef GATHER_STATISTICS struct { /* Total GC-allocated memory. */ @@ -459,7 +458,6 @@ static struct globals /* 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 @@ -1324,10 +1322,9 @@ ggc_internal_alloc_stat (size_t size MEM_STAT_DECL) /* 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 @@ -1358,32 +1355,31 @@ ggc_internal_alloc_stat (size_t size MEM_STAT_DECL) /* 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, @@ -1524,9 +1520,8 @@ ggc_free (void *p) 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, @@ -2070,9 +2065,10 @@ ggc_collect (void) 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 (); @@ -2160,40 +2156,39 @@ ggc_print_statistics (void) 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 } struct ggc_pch_ondisk diff --git a/gcc/ggc-zone.c b/gcc/ggc-zone.c index 5257ada28fa..baf807649ab 100644 --- a/gcc/ggc-zone.c +++ b/gcc/ggc-zone.c @@ -216,10 +216,8 @@ typedef struct page_entry /* 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; @@ -403,7 +401,6 @@ struct alloc_zone /* True if this zone should be destroyed after the next collection. */ bool dead; -#ifdef GATHER_STATISTICS struct { /* Total GC-allocated memory. */ @@ -424,7 +421,6 @@ struct alloc_zone unsigned long long total_allocated_under128; unsigned long long total_overhead_under128; } stats; -#endif } main_zone; /* Some default zones. */ @@ -931,9 +927,7 @@ alloc_large_page (size_t size, struct alloc_zone *zone) 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; @@ -1250,9 +1244,7 @@ ggc_internal_alloc_zone_stat (size_t orig_size, struct alloc_zone *zone { 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) @@ -1315,8 +1307,8 @@ ggc_internal_alloc_zone_stat (size_t orig_size, struct alloc_zone *zone 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; @@ -1413,9 +1405,8 @@ ggc_free (void *p) { 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)); @@ -1753,10 +1744,8 @@ sweep_pages (struct alloc_zone *zone) lnext = lp->next; -#ifdef GATHER_STATISTICS /* This page has now survived another collection. */ lp->common.survived++; -#endif if (lp->mark_p) { @@ -1791,10 +1780,8 @@ sweep_pages (struct alloc_zone *zone) 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 @@ -1948,9 +1935,8 @@ ggc_collect_1 (struct alloc_zone *zone, bool need_marking) { zone_allocate_marks (); ggc_mark_roots (); -#ifdef GATHER_STATISTICS - ggc_prune_overhead_list (); -#endif + if (GATHER_STATISTICS) + ggc_prune_overhead_list (); } sweep_pages (zone); @@ -1962,7 +1948,6 @@ ggc_collect_1 (struct alloc_zone *zone, bool need_marking) return true; } -#ifdef GATHER_STATISTICS /* Calculate the average page survival rate in terms of number of collections. */ @@ -1985,7 +1970,6 @@ calculate_average_page_survival (struct alloc_zone *zone) } return survival/count; } -#endif /* Top level collection routine. */ @@ -2047,9 +2031,8 @@ ggc_collect (void) } } -#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) { @@ -2061,7 +2044,6 @@ ggc_collect (void) } } } -#endif if (marked) zone_free_marks (); @@ -2210,54 +2192,53 @@ ggc_print_statistics (void) 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. */ @@ -2472,13 +2453,14 @@ ggc_pch_read (FILE *f, void *addr) 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) { diff --git a/gcc/ggc.h b/gcc/ggc.h index d90eec2c207..59a996bc828 100644 --- a/gcc/ggc.h +++ b/gcc/ggc.h @@ -166,10 +166,6 @@ extern void *ggc_realloc_stat (void *, size_t MEM_STAT_DECL); /* 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. */ diff --git a/gcc/gimple.c b/gcc/gimple.c index 4d2a0f5ffde..7686f8105cd 100644 --- a/gcc/gimple.c +++ b/gcc/gimple.c @@ -79,7 +79,6 @@ EXPORTED_CONST enum gimple_statement_structure_enum gss_for_code_[] = { }; #undef DEFGSCODE -#ifdef GATHER_STATISTICS /* Gimple stats. */ int gimple_alloc_counts[(int) gimple_alloc_kind_all]; @@ -93,8 +92,6 @@ static const char * const gimple_alloc_kind_names[] = { "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 *); @@ -134,13 +131,12 @@ gimple_alloc_stat (enum gimple_code code, unsigned num_ops MEM_STAT_DECL) 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); @@ -645,9 +641,8 @@ gimple_build_asm_1 (const char *string, unsigned ninputs, unsigned noutputs, 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; } @@ -2503,9 +2498,14 @@ gimple_assign_rhs_could_trap_p (gimple s) 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"); @@ -2519,9 +2519,6 @@ dump_gimple_statistics (void) 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 } diff --git a/gcc/gimple.h b/gcc/gimple.h index 969a3ae3d02..5180e8e5445 100644 --- a/gcc/gimple.h +++ b/gcc/gimple.h @@ -5270,7 +5270,6 @@ tree walk_gimple_stmt (gimple_stmt_iterator *, walk_stmt_fn, walk_tree_fn, 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 @@ -5301,7 +5300,6 @@ gimple_alloc_kind (enum gimple_code code) return gimple_alloc_kind_rest; } } -#endif /* GATHER_STATISTICS */ extern void dump_gimple_statistics (void); diff --git a/gcc/rtl.c b/gcc/rtl.c index ec48839f61e..0f59991702a 100644 --- a/gcc/rtl.c +++ b/gcc/rtl.c @@ -135,12 +135,10 @@ const char * const reg_note_name[REG_NOTE_MAX] = #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 /* Allocate an rtx vector of N elements. @@ -157,10 +155,11 @@ rtvec_alloc (int n) 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; } @@ -205,10 +204,11 @@ rtx_alloc_stat (RTX_CODE code MEM_STAT_DECL) 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; } @@ -706,10 +706,16 @@ iterative_hash_rtx (const_rtx x, hashval_t hash) 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++) @@ -731,7 +737,6 @@ dump_rtx_statistics (void) fprintf (stderr, "%-20s %7d %10d\n", "Total", total_counts, total_sizes); fprintf (stderr, "---------------------------------------\n"); -#endif } #if defined ENABLE_RTL_CHECKING && (GCC_VERSION >= 2007) diff --git a/gcc/sbitmap.c b/gcc/sbitmap.c index d606736c4c7..a67f1028e01 100644 --- a/gcc/sbitmap.c +++ b/gcc/sbitmap.c @@ -23,10 +23,16 @@ along with GCC; see the file COPYING3. If not see #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" diff --git a/gcc/sbitmap.h b/gcc/sbitmap.h index 9bd4ccdcde0..231dfd4195c 100644 --- a/gcc/sbitmap.h +++ b/gcc/sbitmap.h @@ -25,17 +25,9 @@ along with GCC; see the file COPYING3. If not see 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. */ diff --git a/gcc/statistics.h b/gcc/statistics.h index 6e21e855797..60fd68a36d1 100644 --- a/gcc/statistics.h +++ b/gcc/statistics.h @@ -22,20 +22,33 @@ #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; diff --git a/gcc/tree-flow.h b/gcc/tree-flow.h index 061a3f8dab5..4dc7ec96146 100644 --- a/gcc/tree-flow.h +++ b/gcc/tree-flow.h @@ -511,9 +511,7 @@ extern void remove_phi_args (edge); 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); @@ -599,9 +597,7 @@ extern void set_ptr_info_alignment (struct ptr_info_def *, unsigned int, 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); diff --git a/gcc/tree-phinodes.c b/gcc/tree-phinodes.c index 6408a525298..d488941f36d 100644 --- a/gcc/tree-phinodes.c +++ b/gcc/tree-phinodes.c @@ -77,21 +77,17 @@ static unsigned long free_phinode_count; 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 @@ -119,21 +115,19 @@ allocate_phi_node (size_t len) 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; diff --git a/gcc/tree-ssanames.c b/gcc/tree-ssanames.c index ac63bc671eb..35e8751316d 100644 --- a/gcc/tree-ssanames.c +++ b/gcc/tree-ssanames.c @@ -61,10 +61,8 @@ along with GCC; see the file COPYING3. If not see 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. */ @@ -101,14 +99,12 @@ fini_ssanames (void) /* 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 @@ -127,9 +123,8 @@ make_ssa_name_fn (struct function *fn, tree var, gimple stmt) 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. */ @@ -141,9 +136,8 @@ make_ssa_name_fn (struct function *fn, tree var, gimple stmt) 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); diff --git a/gcc/tree.c b/gcc/tree.c index f54e89060a5..4fea005a525 100644 --- a/gcc/tree.c +++ b/gcc/tree.c @@ -121,7 +121,6 @@ const char *const tree_code_class_strings[] = /* 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]; @@ -147,7 +146,6 @@ static const char * const tree_node_kind_names[] = { "lang_type kinds", "omp clauses", }; -#endif /* GATHER_STATISTICS */ /* Unique id for next decl created. */ static GTY(()) int next_decl_uid; @@ -751,10 +749,12 @@ static void 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 */ @@ -832,7 +832,6 @@ record_node_allocation_statistics (enum tree_code code ATTRIBUTE_UNUSED, 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. */ @@ -6337,11 +6336,12 @@ type_hash_canon (unsigned int hashcode, tree type) 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 @@ -8709,36 +8709,34 @@ get_callee_fndecl (const_tree call) 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 (); diff --git a/gcc/vec.c b/gcc/vec.c index 783a3cfd52d..85274c4e00c 100644 --- a/gcc/vec.c +++ b/gcc/vec.c @@ -34,8 +34,6 @@ along with GCC; see the file COPYING3. If not see #include "diagnostic-core.h" #include "hashtab.h" -#ifdef GATHER_STATISTICS - /* Store information about each particular vector. */ struct vec_descriptor { @@ -158,10 +156,10 @@ free_overhead (struct vec_prefix *ptr) 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. */ @@ -316,20 +314,16 @@ vec_heap_o_reserve_1 (void *vec, int reserve, size_t vec_offset, 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; } @@ -529,7 +523,6 @@ vec_assert_fail (const char *op, const char *struct_name, } #endif -#ifdef GATHER_STATISTICS /* Helper for qsort; sort descriptors by amount of memory consumed. */ static int cmp_statistic (const void *loc1, const void *loc2) @@ -558,17 +551,19 @@ add_statistics (void **slot, void *b) } /* 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", @@ -603,5 +598,4 @@ dump_vec_loc_statistics (void) fprintf (stderr, "\n%-48s %10s %10s %10s\n", "source location", "Leak", "Peak", "Times"); fprintf (stderr, "-------------------------------------------------------\n"); -#endif } diff --git a/gcc/vec.h b/gcc/vec.h index d47795879f1..f38c763104f 100644 --- a/gcc/vec.h +++ b/gcc/vec.h @@ -482,12 +482,7 @@ extern void *vec_heap_o_reserve (void *, int, size_t, size_t MEM_STAT_DECL); 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__ @@ -1356,7 +1351,8 @@ extern void *vec_stack_o_reserve_exact (void *, int, size_t, size_t 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)))) |