diff gcc/hash-table.c @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents 04ced10e8804
children 1830386684a0
line wrap: on
line diff
--- a/gcc/hash-table.c	Fri Oct 27 22:46:09 2017 +0900
+++ b/gcc/hash-table.c	Thu Oct 25 07:37:49 2018 +0900
@@ -1,5 +1,5 @@
 /* A type-safe hash table template.
-   Copyright (C) 2012-2017 Free Software Foundation, Inc.
+   Copyright (C) 2012-2018 Free Software Foundation, Inc.
    Contributed by Lawrence Crowl <crowl@google.com>
 
 This file is part of GCC.
@@ -98,7 +98,16 @@
   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)
@@ -109,7 +118,6 @@
   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);
     }
 }
-