* hash-table.c (hash_table_usage): Change from variable to function.
* hash-table.h: Adjust.
* Makefile.in: Add missing dependencies on hash-table.h.
From-SVN: r264313
+2018-09-14 Jason Merrill <jason@redhat.com>
+
+ Fix --enable-gather-detailed-mem-stats.
+ * hash-table.c (hash_table_usage): Change from variable to function.
+ * hash-table.h: Adjust.
+ * Makefile.in: Add missing dependencies on hash-table.h.
+
2018-09-14 Kyrylo Tkachov <kyrylo.tkachov@arm.com>
PR tree-optimization/87259
build/errors.o : errors.c $(BCONFIG_H) $(SYSTEM_H) errors.h
build/gensupport.o: gensupport.c $(BCONFIG_H) $(SYSTEM_H) \
$(CORETYPES_H) $(GTM_H) $(RTL_BASE_H) $(OBSTACK_H) errors.h \
- $(HASHTAB_H) $(READ_MD_H) $(GENSUPPORT_H)
+ $(HASHTAB_H) $(READ_MD_H) $(GENSUPPORT_H) $(HASH_TABLE_H)
build/ggc-none.o : ggc-none.c $(BCONFIG_H) $(SYSTEM_H) $(CORETYPES_H) \
$(GGC_H)
build/min-insn-modes.o : min-insn-modes.c $(BCONFIG_H) $(SYSTEM_H) \
build/rtl.o: rtl.c $(BCONFIG_H) $(CORETYPES_H) $(GTM_H) $(SYSTEM_H) \
$(RTL_H) $(GGC_H) errors.h
build/vec.o : vec.c $(BCONFIG_H) $(SYSTEM_H) $(CORETYPES_H) $(VEC_H) \
- $(GGC_H) toplev.h $(DIAGNOSTIC_CORE_H)
+ $(GGC_H) toplev.h $(DIAGNOSTIC_CORE_H) $(HASH_TABLE_H)
build/hash-table.o : hash-table.c $(BCONFIG_H) $(SYSTEM_H) \
$(CORETYPES_H) $(HASH_TABLE_H) $(GGC_H) toplev.h $(DIAGNOSTIC_CORE_H)
build/sort.o : sort.cc $(BCONFIG_H) $(SYSTEM_H)
return low;
}
-mem_alloc_description<mem_usage> hash_table_usage;
+/* Return a reference to the lazily initialized hash-table usage description.
+ This needs to be a function rather than a simple global variable so that it
+ is reliably initialized before hash table variables in other files such as
+ sem_item::m_type_hash_cache. */
+mem_alloc_description<mem_usage>&
+hash_table_usage ()
+{
+ static mem_alloc_description<mem_usage> usage;
+ return usage;
+}
/* Support function for statistics. */
void dump_hash_table_loc_statistics (void)
for (unsigned i = HASH_TABLE_ORIGIN; i <= HASH_SET_ORIGIN; i++)
{
mem_alloc_origin origin = (mem_alloc_origin) i;
- hash_table_usage.dump (origin);
+ hash_table_usage ().dump (origin);
}
}
-
#include "mem-stats.h"
#include "hash-map.h"
-extern mem_alloc_description<mem_usage> hash_table_usage;
+extern mem_alloc_description<mem_usage>& hash_table_usage (void);
/* Support function for statistics. */
extern void dump_hash_table_loc_statistics (void);
size = prime_tab[size_prime_index].prime;
if (m_gather_mem_stats)
- hash_table_usage.register_descriptor (this, origin, ggc
+ hash_table_usage ().register_descriptor (this, origin, ggc
FINAL_PASS_MEM_STAT);
m_entries = alloc_entries (size PASS_MEM_STAT);
size_t size = h.m_size;
if (m_gather_mem_stats)
- hash_table_usage.register_descriptor (this, origin, ggc
+ hash_table_usage ().register_descriptor (this, origin, ggc
FINAL_PASS_MEM_STAT);
value_type *nentries = alloc_entries (size PASS_MEM_STAT);
ggc_free (m_entries);
if (m_gather_mem_stats)
- hash_table_usage.release_instance_overhead (this,
+ hash_table_usage ().release_instance_overhead (this,
sizeof (value_type) * m_size,
true);
}
value_type *nentries;
if (m_gather_mem_stats)
- hash_table_usage.register_instance_overhead (sizeof (value_type) * n, this);
+ hash_table_usage ().register_instance_overhead (sizeof (value_type) * n, this);
if (!m_ggc)
nentries = Allocator <value_type> ::data_alloc (n);
value_type *nentries = alloc_entries (nsize);
if (m_gather_mem_stats)
- hash_table_usage.release_instance_overhead (this, sizeof (value_type)
+ hash_table_usage ().release_instance_overhead (this, sizeof (value_type)
* osize);
m_entries = nentries;