aboutsummaryrefslogtreecommitdiff
path: root/gcc/bitmap.c
diff options
context:
space:
mode:
authorSteven Bosscher <steven@gcc.gnu.org>2012-07-24 09:49:56 +0000
committerSteven Bosscher <steven@gcc.gnu.org>2012-07-24 09:49:56 +0000
commit7aa6d18a7c51ff7b19149d1e03db839b6b1033dc (patch)
tree7524c306e4effe5958489e003d2bb147a0439144 /gcc/bitmap.c
parent38ad2d079800cafd77f35c32a335697f643fa1a3 (diff)
sbitmap.h (SBITMAP_ELT_BITS): Use "1u" trick as for BITMAP_WORD_BITS.
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. From-SVN: r189803
Diffstat (limited to 'gcc/bitmap.c')
-rw-r--r--gcc/bitmap.c130
1 files changed, 63 insertions, 67 deletions
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"