On September 21, 2019 11:12:38 AM GMT+02:00, Christian Biesinger via 
gcc-patches <gcc-patches@gcc.gnu.org> wrote:
>Hello,
>
>I would like to move hash-table.h, hash-map.h and related files
>to libiberty, so that GDB can make use of it.
>
>I see that gcc already has a C++ file in include/ (unique-ptr.h),
>which I understand is libiberty.
>
>However, this patch is not complete yet (for a start, it doesn't
>compile). Before I go further down this road, is this acceptable
>in principle to the gcc/libiberty maintainers?
>
>(the bulk of the patch is including vec.h in a lot of files,
>because hash-table.h previously included it. It doesn't
>actually use it, and I didn't think it was necessary to
>move that to libiberty as well, so I removed that include
>and instead am adding it to all the files that now don't
>compile.)

The bulk seems to be hash_table to hash_table_ggc renaming. Can you explain? 
Also we can then rename create_ggc back to create? 

Richard. 

>Thanks!
>Christian
>
>Index: Makefile.in
>===================================================================
>--- Makefile.in        (revision 275695)
>+++ Makefile.in        (working copy)
>@@ -1490,7 +1490,6 @@
>       spellcheck-tree.o \
>       sreal.o \
>       stack-ptr-mod.o \
>-      statistics.o \
>       stmt.o \
>       stor-layout.o \
>       store-motion.o \
>Index: bitmap.c
>===================================================================
>--- bitmap.c   (revision 275695)
>+++ bitmap.c   (working copy)
>@@ -22,6 +22,7 @@
> #include "coretypes.h"
> #include "bitmap.h"
> #include "selftest.h"
>+#include "vec.h"
> 
> /* Memory allocation statistics purpose instance.  */
> mem_alloc_description<bitmap_usage> bitmap_mem_desc;
>Index: cfgloop.c
>===================================================================
>--- cfgloop.c  (revision 275695)
>+++ cfgloop.c  (working copy)
>@@ -1135,7 +1135,7 @@
> 
>   gcc_assert (current_loops->exits == NULL);
>   current_loops->exits
>-    = hash_table<loop_exit_hasher>::create_ggc (2 * number_of_loops
>(cfun));
>+    = hash_table_ggc<loop_exit_hasher>::create_ggc (2 *
>number_of_loops (cfun));
> 
>   FOR_EACH_BB_FN (bb, cfun)
>     {
>Index: cgraph.c
>===================================================================
>--- cgraph.c   (revision 275695)
>+++ cgraph.c   (working copy)
>@@ -183,7 +183,7 @@
>   version_info_node->this_node = this;
> 
>   if (cgraph_fnver_htab == NULL)
>-    cgraph_fnver_htab =
>hash_table<function_version_hasher>::create_ggc (2);
>+    cgraph_fnver_htab =
>hash_table_ggc<function_version_hasher>::create_ggc (2);
> 
>   *cgraph_fnver_htab->find_slot (version_info_node, INSERT)
>     = version_info_node;
>@@ -760,7 +760,7 @@
> 
>   if (n > 100)
>     {
>-      call_site_hash = hash_table<cgraph_edge_hasher>::create_ggc
>(120);
>+      call_site_hash = hash_table_ggc<cgraph_edge_hasher>::create_ggc
>(120);
>       for (e2 = callees; e2; e2 = e2->next_callee)
>       cgraph_add_edge_to_call_site_hash (e2);
>       for (e2 = indirect_calls; e2; e2 = e2->next_callee)
>Index: common/common-target.h
>===================================================================
>--- common/common-target.h     (revision 275695)
>+++ common/common-target.h     (working copy)
>@@ -22,6 +22,7 @@
> #ifndef GCC_COMMON_TARGET_H
> #define GCC_COMMON_TARGET_H
> 
>+#include "vec.h"
> 
> /* Sets of optimization levels at which an option may be enabled by
>    default_options_optimization.  */
>Index: common/common-targhooks.h
>===================================================================
>--- common/common-targhooks.h  (revision 275695)
>+++ common/common-targhooks.h  (working copy)
>@@ -20,6 +20,8 @@
> #ifndef GCC_COMMON_TARGHOOKS_H
> #define GCC_COMMON_TARGHOOKS_H
> 
>+#include "vec.h"
>+
>extern enum unwind_info_type default_except_unwind_info (struct
>gcc_options *);
>extern enum unwind_info_type dwarf2_except_unwind_info (struct
>gcc_options *);
>extern enum unwind_info_type sjlj_except_unwind_info (struct
>gcc_options *);
>Index: config/darwin.c
>===================================================================
>--- config/darwin.c    (revision 275695)
>+++ config/darwin.c    (working copy)
>@@ -572,7 +572,7 @@
>sprintf (buffer, "&%s%c%s%s%s%s", quote, L_or_l, prefix, name, suffix,
>quote);
> 
>   if (!machopic_indirections)
>-    machopic_indirections = hash_table<indirection_hasher>::create_ggc
>(37);
>+    machopic_indirections =
>hash_table_ggc<indirection_hasher>::create_ggc (37);
> 
>   machopic_indirection **slot
>     = machopic_indirections->find_slot_with_hash (buffer,
>@@ -3454,7 +3454,7 @@
>   rest_of_decl_compilation (cfstring_class_reference, 0, 0);
> 
>/* Initialize the hash table used to hold the constant CFString
>objects.  */
>-  cfstring_htab = hash_table<cfstring_hasher>::create_ggc (31);
>+  cfstring_htab = hash_table_ggc<cfstring_hasher>::create_ggc (31);
> 
>   return cfstring_type_node;
> }
>Index: config/i386/i386.c
>===================================================================
>--- config/i386/i386.c (revision 275695)
>+++ config/i386/i386.c (working copy)
>@@ -95,6 +95,7 @@
> #include "i386-builtins.h"
> #include "i386-expand.h"
> #include "i386-features.h"
>+#include "hash-table-ggc.h"
> 
> /* This file should be included last.  */
> #include "target-def.h"
>@@ -11048,7 +11049,7 @@
>   rtx rtl;
> 
>   if (!dllimport_map)
>-    dllimport_map = hash_table<dllimport_hasher>::create_ggc (512);
>+    dllimport_map = hash_table_ggc<dllimport_hasher>::create_ggc
>(512);
> 
>   in.hash = htab_hash_pointer (decl);
>   in.base.from = decl;
>Index: cp/constexpr.c
>===================================================================
>--- cp/constexpr.c     (revision 275695)
>+++ cp/constexpr.c     (working copy)
>@@ -895,7 +895,7 @@
>   /* Create the constexpr function table if necessary.  */
>   if (constexpr_fundef_table == NULL)
>     constexpr_fundef_table
>-      = hash_table<constexpr_fundef_hasher>::create_ggc (101);
>+      = hash_table_ggc<constexpr_fundef_hasher>::create_ggc (101);
> 
>   entry.decl = fun;
>   tree saved_fn = current_function_decl;
>@@ -1081,7 +1081,7 @@
> maybe_initialize_constexpr_call_table (void)
> {
>   if (constexpr_call_table == NULL)
>-    constexpr_call_table =
>hash_table<constexpr_call_hasher>::create_ggc (101);
>+    constexpr_call_table =
>hash_table_ggc<constexpr_call_hasher>::create_ggc (101);
> }
> 
>/* During constexpr CALL_EXPR evaluation, to avoid issues with sharing
>when
>Index: cp/decl.c
>===================================================================
>--- cp/decl.c  (revision 275695)
>+++ cp/decl.c  (working copy)
>@@ -3070,7 +3070,7 @@
>     }
> 
>   if (!named_labels)
>-    named_labels = hash_table<named_label_hash>::create_ggc (13);
>+    named_labels = hash_table_ggc<named_label_hash>::create_ggc (13);
> 
>   hashval_t hash = IDENTIFIER_HASH_VALUE (id);
>   named_label_entry **slot
>@@ -3754,7 +3754,7 @@
>   hashval_t hash;
> 
>   if (typename_htab == NULL)
>-    typename_htab = hash_table<typename_hasher>::create_ggc (61);
>+    typename_htab = hash_table_ggc<typename_hasher>::create_ggc (61);
> 
>   ti.scope = FROB_CONTEXT (context);
>   ti.name = name;
>Index: cp/decl2.c
>===================================================================
>--- cp/decl2.c (revision 275695)
>+++ cp/decl2.c (working copy)
>@@ -4612,7 +4612,7 @@
> record_mangling (tree decl, bool need_warning)
> {
>   if (!mangled_decls)
>-    mangled_decls = hash_table<mangled_decl_hash>::create_ggc (499);
>+    mangled_decls = hash_table_ggc<mangled_decl_hash>::create_ggc
>(499);
> 
>   gcc_checking_assert (DECL_ASSEMBLER_NAME_SET_P (decl));
>   tree id = DECL_ASSEMBLER_NAME_RAW (decl);
>Index: cp/lex.c
>===================================================================
>--- cp/lex.c   (revision 275695)
>+++ cp/lex.c   (working copy)
>@@ -625,7 +625,7 @@
>     return error_mark_node;
> 
>   if (conv_type_names == NULL)
>-    conv_type_names = hash_table<conv_type_hasher>::create_ggc (31);
>+    conv_type_names = hash_table_ggc<conv_type_hasher>::create_ggc
>(31);
> 
>   tree *slot = conv_type_names->find_slot_with_hash
>     (type, (hashval_t) TYPE_UID (type), INSERT);
>@@ -703,7 +703,7 @@
> 
>   if (sel == lds_ns)
>     /* Who'd create a namespace, only to put nothing in it?  */
>-    ld->u.ns.bindings = hash_table<named_decl_hash>::create_ggc (499);
>+    ld->u.ns.bindings = hash_table_ggc<named_decl_hash>::create_ggc
>(499);
> 
>   if (GATHER_STATISTICS)
>     {
>Index: cp/name-lookup.c
>===================================================================
>--- cp/name-lookup.c   (revision 275695)
>+++ cp/name-lookup.c   (working copy)
>@@ -2522,7 +2522,7 @@
>     return;
> 
>   if (!extern_c_decls)
>-    extern_c_decls = hash_table<named_decl_hash>::create_ggc (127);
>+    extern_c_decls = hash_table_ggc<named_decl_hash>::create_ggc
>(127);
> 
>   tree *slot = extern_c_decls
>     ->find_slot_with_hash (DECL_NAME (decl),
>@@ -2907,7 +2907,7 @@
> 
>           if (cp_function_chain->extern_decl_map == NULL)
>             cp_function_chain->extern_decl_map
>-              = hash_table<cxx_int_tree_map_hasher>::create_ggc (20);
>+              = hash_table_ggc<cxx_int_tree_map_hasher>::create_ggc (20);
> 
>           h = ggc_alloc<cxx_int_tree_map> ();
>           h->uid = DECL_UID (decl);
>Index: cp/pt.c
>===================================================================
>--- cp/pt.c    (revision 275695)
>+++ cp/pt.c    (working copy)
>@@ -28306,11 +28306,11 @@
>   if (!flag_concepts)
>     return;
> 
>-  decl_constraints = hash_table<constr_hasher>::create_ggc(37);
>-  constraint_memos =
>hash_table<constraint_sat_hasher>::create_ggc(37);
>-  concept_memos = hash_table<concept_spec_hasher>::create_ggc(37);
>-  concept_expansions =
>hash_table<concept_spec_hasher>::create_ggc(37);
>-  subsumption_table = hash_table<subsumption_hasher>::create_ggc(37);
>+  decl_constraints = hash_table_ggc<constr_hasher>::create_ggc(37);
>+  constraint_memos =
>hash_table_ggc<constraint_sat_hasher>::create_ggc(37);
>+  concept_memos = hash_table_ggc<concept_spec_hasher>::create_ggc(37);
>+  concept_expansions =
>hash_table_ggc<concept_spec_hasher>::create_ggc(37);
>+  subsumption_table =
>hash_table_ggc<subsumption_hasher>::create_ggc(37);
> }
> 
>/* __integer_pack(N) in a pack expansion expands to a sequence of
>numbers from
>@@ -28335,8 +28335,8 @@
> init_template_processing (void)
> {
>   /* FIXME: enable sanitization (PR87847) */
>-  decl_specializations = hash_table<spec_hasher>::create_ggc (37,
>false);
>-  type_specializations = hash_table<spec_hasher>::create_ggc (37,
>false);
>+  decl_specializations = hash_table_ggc<spec_hasher>::create_ggc (37,
>false);
>+  type_specializations = hash_table_ggc<spec_hasher>::create_ggc (37,
>false);
> 
>   if (cxx_dialect >= cxx11)
>     declare_integer_pack ();
>Index: cp/tree.c
>===================================================================
>--- cp/tree.c  (revision 275695)
>+++ cp/tree.c  (working copy)
>@@ -1011,7 +1011,7 @@
>       hashval_t hash;
> 
>       if (cplus_array_htab == NULL)
>-      cplus_array_htab = hash_table<cplus_array_hasher>::create_ggc (61);
>+      cplus_array_htab = hash_table_ggc<cplus_array_hasher>::create_ggc
>(61);
>       
>       hash = TYPE_UID (elt_type);
>       if (index_type)
>@@ -4982,7 +4982,7 @@
> void
> init_tree (void)
> {
>-  list_hash_table = hash_table<list_hasher>::create_ggc (61);
>+  list_hash_table = hash_table_ggc<list_hasher>::create_ggc (61);
>   register_scoped_attributes (std_attribute_table, NULL);
> }
> 
>Index: cp/typeck2.c
>===================================================================
>--- cp/typeck2.c       (revision 275695)
>+++ cp/typeck2.c       (working copy)
>@@ -277,7 +277,7 @@
> 
>       if (!abstract_pending_vars)
>       abstract_pending_vars
>-        = hash_table<abstract_type_hasher>::create_ggc (31);
>+        = hash_table_ggc<abstract_type_hasher>::create_ggc (31);
> 
>       pending_abstract_type **slot
>       = abstract_pending_vars->find_slot_with_hash (type, TYPE_UID (type),
>Index: dbgcnt.c
>===================================================================
>--- dbgcnt.c   (revision 275695)
>+++ dbgcnt.c   (working copy)
>@@ -24,6 +24,7 @@
> #include "coretypes.h"
> #include "diagnostic-core.h"
> #include "dumpfile.h"
>+#include "vec.h"
> 
> #include "dbgcnt.h"
> 
>Index: diagnostic-show-locus.c
>===================================================================
>--- diagnostic-show-locus.c    (revision 275695)
>+++ diagnostic-show-locus.c    (working copy)
>@@ -30,6 +30,7 @@
> #include "gcc-rich-location.h"
> #include "selftest.h"
> #include "selftest-diagnostic.h"
>+#include "vec.h"
> 
> #ifdef HAVE_TERMIOS_H
> # include <termios.h>
>Index: dwarf2out.c
>===================================================================
>--- dwarf2out.c        (revision 275695)
>+++ dwarf2out.c        (working copy)
>@@ -4651,7 +4651,7 @@
> find_AT_string (const char *str, enum insert_option insert = INSERT)
> {
>   if (! debug_str_hash)
>-    debug_str_hash = hash_table<indirect_string_hasher>::create_ggc
>(10);
>+    debug_str_hash =
>hash_table_ggc<indirect_string_hasher>::create_ggc (10);
> 
>   return find_AT_string_in_table (str, debug_str_hash, insert);
> }
>@@ -5023,7 +5023,7 @@
> 
>   gcc_assert (dwarf_split_debug_info);
>   if (! addr_index_table)
>-    addr_index_table = hash_table<addr_hasher>::create_ggc (10);
>+    addr_index_table = hash_table_ggc<addr_hasher>::create_ggc (10);
>   init_addr_table_entry (&finder, kind, addr);
>addr_table_entry **slot = addr_index_table->find_slot (&finder,
>INSERT);
> 
>@@ -11170,7 +11170,7 @@
> 
>   if (! skeleton_debug_str_hash)
>     skeleton_debug_str_hash
>-      = hash_table<indirect_string_hasher>::create_ggc (10);
>+      = hash_table_ggc<indirect_string_hasher>::create_ggc (10);
> 
>   node = find_AT_string_in_table (str, skeleton_debug_str_hash);
>   find_string_form (node);
>@@ -12145,7 +12145,7 @@
>     case DW_FORM_line_strp:
>       if (!debug_line_str_hash)
>       debug_line_str_hash
>-        = hash_table<indirect_string_hasher>::create_ggc (10);
>+        = hash_table_ggc<indirect_string_hasher>::create_ggc (10);
> 
>       struct indirect_string_node *node;
>       node = find_AT_string_in_table (str, debug_line_str_hash);
>@@ -23765,7 +23765,7 @@
>       }
> 
>       if (common_block_die_table == NULL)
>-      common_block_die_table = hash_table<block_die_hasher>::create_ggc
>(10);
>+      common_block_die_table = hash_table_ggc<block_die_hasher>::create_ggc
>(10);
> 
>       com_die_arg.decl_id = DECL_UID (com_decl);
>       com_die_arg.die_parent = context_die;
>@@ -27666,7 +27666,7 @@
> 
>   if (!inline_entry_data_table)
>     inline_entry_data_table
>-      = hash_table<inline_entry_data_hasher>::create_ggc (10);
>+      = hash_table_ggc<inline_entry_data_hasher>::create_ggc (10);
> 
> 
>   inline_entry_data **iedp
>@@ -28836,17 +28836,17 @@
> dwarf2out_init (const char *filename ATTRIBUTE_UNUSED)
> {
>   /* Allocate the file_table.  */
>-  file_table = hash_table<dwarf_file_hasher>::create_ggc (50);
>+  file_table = hash_table_ggc<dwarf_file_hasher>::create_ggc (50);
> 
> #ifndef DWARF2_LINENO_DEBUGGING_INFO
>   /* Allocate the decl_die_table.  */
>-  decl_die_table = hash_table<decl_die_hasher>::create_ggc (10);
>+  decl_die_table = hash_table_ggc<decl_die_hasher>::create_ggc (10);
> 
>   /* Allocate the decl_loc_table.  */
>-  decl_loc_table = hash_table<decl_loc_hasher>::create_ggc (10);
>+  decl_loc_table = hash_table_ggc<decl_loc_hasher>::create_ggc (10);
> 
>   /* Allocate the cached_dw_loc_list_table.  */
>-  cached_dw_loc_list_table =
>hash_table<dw_loc_list_hasher>::create_ggc (10);
>+  cached_dw_loc_list_table =
>hash_table_ggc<dw_loc_list_hasher>::create_ggc (10);
> 
>   /* Allocate the initial hunk of the abbrev_die_table.  */
>   vec_alloc (abbrev_die_table, 256);
>@@ -32002,7 +32002,7 @@
>         {
>           if (!variable_value_hash)
>             variable_value_hash
>-              = hash_table<variable_value_hasher>::create_ggc (10);
>+              = hash_table_ggc<variable_value_hasher>::create_ggc (10);
> 
>           tree fndecl = DECL_CONTEXT (decl);
>           struct variable_value_struct *node;
>@@ -32098,7 +32098,7 @@
> 
>         if (! debug_line_str_hash)
>           debug_line_str_hash
>-            = hash_table<indirect_string_hasher>::create_ggc (10);
>+            = hash_table_ggc<indirect_string_hasher>::create_ggc (10);
> 
>         struct indirect_string_node *node
>           = find_AT_string_in_table (AT_string (a), debug_line_str_hash);
>Index: edit-context.c
>===================================================================
>--- edit-context.c     (revision 275695)
>+++ edit-context.c     (working copy)
>@@ -25,6 +25,7 @@
> #include "pretty-print.h"
> #include "diagnostic-color.h"
> #include "selftest.h"
>+#include "vec.h"
> 
> /* This file implements a way to track the effect of fix-its,
>    via a class edit_context; the other classes are support classes for
>Index: emit-rtl.c
>===================================================================
>--- emit-rtl.c (revision 275695)
>+++ emit-rtl.c (working copy)
>@@ -6218,19 +6218,19 @@
> 
>   /* Initialize the CONST_INT, CONST_WIDE_INT, CONST_DOUBLE,
>      CONST_FIXED, and memory attribute hash tables.  */
>-  const_int_htab = hash_table<const_int_hasher>::create_ggc (37);
>+  const_int_htab = hash_table_ggc<const_int_hasher>::create_ggc (37);
> 
> #if TARGET_SUPPORTS_WIDE_INT
>-  const_wide_int_htab = hash_table<const_wide_int_hasher>::create_ggc
>(37);
>+  const_wide_int_htab =
>hash_table_ggc<const_wide_int_hasher>::create_ggc (37);
> #endif
>-  const_double_htab = hash_table<const_double_hasher>::create_ggc
>(37);
>+  const_double_htab = hash_table_ggc<const_double_hasher>::create_ggc
>(37);
> 
>   if (NUM_POLY_INT_COEFFS > 1)
>-    const_poly_int_htab =
>hash_table<const_poly_int_hasher>::create_ggc (37);
>+    const_poly_int_htab =
>hash_table_ggc<const_poly_int_hasher>::create_ggc (37);
> 
>-  const_fixed_htab = hash_table<const_fixed_hasher>::create_ggc (37);
>+  const_fixed_htab = hash_table_ggc<const_fixed_hasher>::create_ggc
>(37);
> 
>-  reg_attrs_htab = hash_table<reg_attr_hasher>::create_ggc (37);
>+  reg_attrs_htab = hash_table_ggc<reg_attr_hasher>::create_ggc (37);
> 
> #ifdef INIT_EXPANDERS
>/* This is to initialize {init|mark|free}_machine_status before the
>first
>Index: fibonacci_heap.h
>===================================================================
>--- fibonacci_heap.h   (revision 275695)
>+++ fibonacci_heap.h   (working copy)
>@@ -40,6 +40,8 @@
> #ifndef GCC_FIBONACCI_HEAP_H
> #define GCC_FIBONACCI_HEAP_H
> 
>+#include "vec.h"
>+
> /* Forward definition.  */
> 
> template<class K, class V>
>Index: fortran/trans-decl.c
>===================================================================
>--- fortran/trans-decl.c       (revision 275695)
>+++ fortran/trans-decl.c       (working copy)
>@@ -5095,7 +5095,7 @@
> gfc_find_module (const char *name)
> {
>   if (! module_htab)
>-    module_htab = hash_table<module_hasher>::create_ggc (10);
>+    module_htab = hash_table_ggc<module_hasher>::create_ggc (10);
> 
>   module_htab_entry **slot
>= module_htab->find_slot_with_hash (name, htab_hash_string (name),
>INSERT);
>@@ -5104,7 +5104,7 @@
>    module_htab_entry *entry = ggc_cleared_alloc<module_htab_entry> ();
> 
>       entry->name = gfc_get_string ("%s", name);
>-      entry->decls = hash_table<module_decl_hasher>::create_ggc (10);
>+      entry->decls = hash_table_ggc<module_decl_hasher>::create_ggc
>(10);
>       *slot = entry;
>     }
>   return *slot;
>Index: function.c
>===================================================================
>--- function.c (revision 275695)
>+++ function.c (working copy)
>@@ -1237,7 +1237,7 @@
> 
>   /* Set up the table to map addresses to temp slots.  */
>   if (! temp_slot_address_table)
>-    temp_slot_address_table =
>hash_table<temp_address_hasher>::create_ggc (32);
>+    temp_slot_address_table =
>hash_table_ggc<temp_address_hasher>::create_ggc (32);
>   else
>     temp_slot_address_table->empty ();
> }
>@@ -5607,7 +5607,7 @@
>   hash_table<insn_cache_hasher> *hash = *hashp;
> 
>   if (hash == NULL)
>-    *hashp = hash = hash_table<insn_cache_hasher>::create_ggc (17);
>+    *hashp = hash = hash_table_ggc<insn_cache_hasher>::create_ggc
>(17);
> 
>   for (tmp = insns; tmp != end; tmp = NEXT_INSN (tmp))
>     {
>@@ -6285,7 +6285,7 @@
>       e.type = type;
>       if (types_used_by_vars_hash == NULL)
>       types_used_by_vars_hash
>-        = hash_table<used_type_hasher>::create_ggc (37);
>+        = hash_table_ggc<used_type_hasher>::create_ggc (37);
> 
>       slot = types_used_by_vars_hash->find_slot (&e, INSERT);
>       if (*slot == NULL)
>Index: function.h
>===================================================================
>--- function.h (revision 275695)
>+++ function.h (working copy)
>@@ -20,6 +20,7 @@
> #ifndef GCC_FUNCTION_H
> #define GCC_FUNCTION_H
> 
>+#include "vec.h"
> 
> /* Stack of pending (incomplete) sequences saved by `start_sequence'.
>    Each element describes one pending sequence.
>Index: genmatch.c
>===================================================================
>--- genmatch.c (revision 275695)
>+++ genmatch.c (working copy)
>@@ -29,6 +29,7 @@
> #include "hash-table.h"
> #include "hash-set.h"
> #include "is-a.h"
>+#include "vec.h"
> 
> 
>/* Stubs for GGC referenced through instantiations triggered by
>hash-map.  */
>Index: ggc-common.c
>===================================================================
>--- ggc-common.c       (revision 275695)
>+++ ggc-common.c       (working copy)
>@@ -29,6 +29,7 @@
> #include "params.h"
> #include "hosthooks.h"
> #include "plugin.h"
>+#include "vec.h"
> 
> /* When set, ggc_collect will do collection.  */
> bool ggc_force_collect;
>Index: graphds.h
>===================================================================
>--- graphds.h  (revision 275695)
>+++ graphds.h  (working copy)
>@@ -20,6 +20,8 @@
> #ifndef GCC_GRAPHDS_H
> #define GCC_GRAPHDS_H
> 
>+#include "vec.h"
>+
> /* Structure representing edge of a graph.  */
> 
> struct graph_edge
>Index: hash-map-traits.h
>===================================================================
>--- hash-map-traits.h  (revision 275695)
>+++ hash-map-traits.h  (nonexistent)
>@@ -1,188 +0,0 @@
>-/* A hash map traits.
>-   Copyright (C) 2015-2019 Free Software Foundation, Inc.
>-
>-This file is part of GCC.
>-
>-GCC is free software; you can redistribute it and/or modify it under
>-the terms of the GNU General Public License as published by the Free
>-Software Foundation; either version 3, or (at your option) any later
>-version.
>-
>-GCC is distributed in the hope that it will be useful, but WITHOUT ANY
>-WARRANTY; without even the implied warranty of MERCHANTABILITY or
>-FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
>-for more details.
>-
>-You should have received a copy of the GNU General Public License
>-along with GCC; see the file COPYING3.  If not see
>-<http://www.gnu.org/licenses/>.  */
>-
>-#ifndef HASH_MAP_TRAITS_H
>-#define HASH_MAP_TRAITS_H
>-
>-/* Bacause mem-stats.h uses default hashmap traits, we have to
>-   put the class to this separate header file.  */
>-
>-#include "hash-traits.h"
>-
>-/* Implement hash_map traits for a key with hash traits H.  Empty and
>-   deleted map entries are represented as empty and deleted keys.  */
>-
>-template <typename H, typename Value>
>-struct simple_hashmap_traits
>-{
>-  typedef typename H::value_type key_type;
>-  static const bool maybe_mx = true;
>-  static inline hashval_t hash (const key_type &);
>-  static inline bool equal_keys (const key_type &, const key_type &);
>-  template <typename T> static inline void remove (T &);
>-  template <typename T> static inline bool is_empty (const T &);
>-  template <typename T> static inline bool is_deleted (const T &);
>-  template <typename T> static inline void mark_empty (T &);
>-  template <typename T> static inline void mark_deleted (T &);
>-};
>-
>-template <typename H, typename Value>
>-inline hashval_t
>-simple_hashmap_traits <H, Value>::hash (const key_type &h)
>-{
>-  return H::hash (h);
>-}
>-
>-template <typename H, typename Value>
>-inline bool
>-simple_hashmap_traits <H, Value>::equal_keys (const key_type &k1,
>-                                            const key_type &k2)
>-{
>-  return H::equal (k1, k2);
>-}
>-
>-template <typename H, typename Value>
>-template <typename T>
>-inline void
>-simple_hashmap_traits <H, Value>::remove (T &entry)
>-{
>-  H::remove (entry.m_key);
>-  entry.m_value.~Value ();
>-}
>-
>-template <typename H, typename Value>
>-template <typename T>
>-inline bool
>-simple_hashmap_traits <H, Value>::is_empty (const T &entry)
>-{
>-  return H::is_empty (entry.m_key);
>-}
>-
>-template <typename H, typename Value>
>-template <typename T>
>-inline bool
>-simple_hashmap_traits <H, Value>::is_deleted (const T &entry)
>-{
>-  return H::is_deleted (entry.m_key);
>-}
>-
>-template <typename H, typename Value>
>-template <typename T>
>-inline void
>-simple_hashmap_traits <H, Value>::mark_empty (T &entry)
>-{
>-  H::mark_empty (entry.m_key);
>-}
>-
>-template <typename H, typename Value>
>-template <typename T>
>-inline void
>-simple_hashmap_traits <H, Value>::mark_deleted (T &entry)
>-{
>-  H::mark_deleted (entry.m_key);
>-}
>-
>-template <typename H, typename Value>
>-struct simple_cache_map_traits: public simple_hashmap_traits<H,Value>
>-{
>-  static const bool maybe_mx = false;
>-};
>-
>-/* Implement traits for a hash_map with values of type Value for cases
>-   in which the key cannot represent empty and deleted slots.  Instead
>-   record empty and deleted entries in Value.  Derived classes must
>-   implement the hash and equal_keys functions.  */
>-
>-template <typename Value>
>-struct unbounded_hashmap_traits
>-{
>-  template <typename T> static inline void remove (T &);
>-  template <typename T> static inline bool is_empty (const T &);
>-  template <typename T> static inline bool is_deleted (const T &);
>-  template <typename T> static inline void mark_empty (T &);
>-  template <typename T> static inline void mark_deleted (T &);
>-};
>-
>-template <typename Value>
>-template <typename T>
>-inline void
>-unbounded_hashmap_traits <Value>::remove (T &entry)
>-{
>-  default_hash_traits <Value>::remove (entry.m_value);
>-}
>-
>-template <typename Value>
>-template <typename T>
>-inline bool
>-unbounded_hashmap_traits <Value>::is_empty (const T &entry)
>-{
>-  return default_hash_traits <Value>::is_empty (entry.m_value);
>-}
>-
>-template <typename Value>
>-template <typename T>
>-inline bool
>-unbounded_hashmap_traits <Value>::is_deleted (const T &entry)
>-{
>-  return default_hash_traits <Value>::is_deleted (entry.m_value);
>-}
>-
>-template <typename Value>
>-template <typename T>
>-inline void
>-unbounded_hashmap_traits <Value>::mark_empty (T &entry)
>-{
>-  default_hash_traits <Value>::mark_empty (entry.m_value);
>-}
>-
>-template <typename Value>
>-template <typename T>
>-inline void
>-unbounded_hashmap_traits <Value>::mark_deleted (T &entry)
>-{
>-  default_hash_traits <Value>::mark_deleted (entry.m_value);
>-}
>-
>-/* Implement traits for a hash_map from integer type Key to Value in
>-   cases where Key has no spare values for recording empty and deleted
>-   slots.  */
>-
>-template <typename Key, typename Value>
>-struct unbounded_int_hashmap_traits : unbounded_hashmap_traits <Value>
>-{
>-  typedef Key key_type;
>-  static inline hashval_t hash (Key);
>-  static inline bool equal_keys (Key, Key);
>-};
>-
>-template <typename Key, typename Value>
>-inline hashval_t
>-unbounded_int_hashmap_traits <Key, Value>::hash (Key k)
>-{
>-  return k;
>-}
>-
>-template <typename Key, typename Value>
>-inline bool
>-unbounded_int_hashmap_traits <Key, Value>::equal_keys (Key k1, Key k2)
>-{
>-  return k1 == k2;
>-}
>-
>-#endif // HASH_MAP_TRAITS_H
>Index: hash-map.h
>===================================================================
>--- hash-map.h (revision 275695)
>+++ hash-map.h (working copy)
>@@ -21,6 +21,8 @@
> #ifndef hash_map_h
> #define hash_map_h
> 
>+#include "hash-table-ggc.h"
>+
> /* Class hash_map is a hash-value based container mapping objects of
>    KeyId type to those of the Value type.
>    Both KeyId and Value may be non-trivial (non-POD) types provided
>Index: hash-table.h
>===================================================================
>--- hash-table.h       (revision 275695)
>+++ hash-table.h       (nonexistent)
>@@ -1,1231 +0,0 @@
>-/* A type-safe hash table template.
>-   Copyright (C) 2012-2019 Free Software Foundation, Inc.
>-   Contributed by Lawrence Crowl <cr...@google.com>
>-
>-This file is part of GCC.
>-
>-GCC is free software; you can redistribute it and/or modify it under
>-the terms of the GNU General Public License as published by the Free
>-Software Foundation; either version 3, or (at your option) any later
>-version.
>-
>-GCC is distributed in the hope that it will be useful, but WITHOUT ANY
>-WARRANTY; without even the implied warranty of MERCHANTABILITY or
>-FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
>-for more details.
>-
>-You should have received a copy of the GNU General Public License
>-along with GCC; see the file COPYING3.  If not see
>-<http://www.gnu.org/licenses/>.  */
>-
>-
>-/* This file implements a typed hash table.
>-   The implementation borrows from libiberty's htab_t in hashtab.h.
>-
>-
>-   INTRODUCTION TO TYPES
>-
>-   Users of the hash table generally need to be aware of three types.
>-
>-      1. The type being placed into the hash table.  This type is
>called
>-      the value type.
>-
>-      2. The type used to describe how to handle the value type within
>-      the hash table.  This descriptor type provides the hash table
>with
>-      several things.
>-
>-         - A typedef named 'value_type' to the value type (from
>above).
>-       Provided a suitable Descriptor class it may be a user-defined,
>-       non-POD type.
>-
>-         - A static member function named 'hash' that takes a
>value_type
>-         (or 'const value_type &') and returns a hashval_t value.
>-
>-         - A typedef named 'compare_type' that is used to test when a
>value
>-       is found.  This type is the comparison type.  Usually, it will be
>-       the same as value_type and may be a user-defined, non-POD type.
>-       If it is not the same type, you must generally explicitly compute
>-       hash values and pass them to the hash table.
>-
>-         - A static member function named 'equal' that takes a
>value_type
>-         and a compare_type, and returns a bool.  Both arguments can
>be
>-         const references.
>-
>-         - A static function named 'remove' that takes an value_type
>pointer
>-         and frees the memory allocated by it.  This function is used
>when
>-         individual elements of the table need to be disposed of
>(e.g.,
>-         when deleting a hash table, removing elements from the table,
>etc).
>-
>-       - An optional static function named 'keep_cache_entry'.  This
>-       function is provided only for garbage-collected elements that
>-       are not marked by the normal gc mark pass.  It describes what
>-       what should happen to the element at the end of the gc mark phase.
>-       The return value should be:
>-         - 0 if the element should be deleted
>-         - 1 if the element should be kept and needs to be marked
>-         - -1 if the element should be kept and is already marked.
>-       Returning -1 rather than 1 is purely an optimization.
>-
>-      3. The type of the hash table itself.  (More later.)
>-
>-   In very special circumstances, users may need to know about a
>fourth type.
>-
>-      4. The template type used to describe how hash table memory
>-      is allocated.  This type is called the allocator type.  It is
>-      parameterized on the value type.  It provides two functions:
>-
>-         - A static member function named 'data_alloc'.  This function
>-         allocates the data elements in the table.
>-
>-         - A static member function named 'data_free'.  This function
>-         deallocates the data elements in the table.
>-
>-   Hash table are instantiated with two type arguments.
>-
>-      * The descriptor type, (2) above.
>-
>-      * The allocator type, (4) above.  In general, you will not need
>to
>-      provide your own allocator type.  By default, hash tables will
>use
>-      the class template xcallocator, which uses malloc/free for
>allocation.
>-
>-
>-   DEFINING A DESCRIPTOR TYPE
>-
>-   The first task in using the hash table is to describe the element
>type.
>-   We compose this into a few steps.
>-
>-      1. Decide on a removal policy for values stored in the table.
>-         hash-traits.h provides class templates for the four most
>common
>-         policies:
>-
>-         * typed_free_remove implements the static 'remove' member
>function
>-         by calling free().
>-
>-         * typed_noop_remove implements the static 'remove' member
>function
>-         by doing nothing.
>-
>-         * ggc_remove implements the static 'remove' member by doing
>nothing,
>-         but instead provides routines for gc marking and for PCH
>streaming.
>-         Use this for garbage-collected data that needs to be
>preserved across
>-         collections.
>-
>-         * ggc_cache_remove is like ggc_remove, exce

Reply via email to