diff options
author | Trevor Saunders <tsaunders@mozilla.com> | 2014-10-12 22:22:53 +0000 |
---|---|---|
committer | Trevor Saunders <tbsaunde@gcc.gnu.org> | 2014-10-12 22:22:53 +0000 |
commit | 2a22f99cb12d82712dd93cfef808b1cef543601b (patch) | |
tree | c828063f153ceb609ce5c7d44ea9f00391b32950 /gcc/dwarf2out.c | |
parent | 7b262a51ea2310bdb6cc901de00f04b0e7be0a4e (diff) | |
download | gcc-2a22f99cb12d82712dd93cfef808b1cef543601b.zip gcc-2a22f99cb12d82712dd93cfef808b1cef543601b.tar.gz gcc-2a22f99cb12d82712dd93cfef808b1cef543601b.tar.bz2 |
move many gc hashtab to hash_table
gcc/
* asan.c, cfgloop.c, cfgloop.h, cgraph.c, cgraph.h,
config/darwin.c, config/m32c/m32c.c, config/mep/mep.c,
config/mips/mips.c, config/rs6000/rs6000.c, dwarf2out.c,
function.c, function.h, gimple-ssa.h, libfuncs.h, optabs.c,
output.h, rtl.h, sese.c, symtab.c, tree-cfg.c, tree-dfa.c,
tree-ssa.c, varasm.c: Use hash-table instead of hashtab.
* doc/gty.texi (for_user): Document new option.
* gengtype.c (create_user_defined_type): Don't try to get a struct for
char.
(walk_type): Don't error out on for_user option.
(write_func_for_structure): Emit user marking routines if requested by
for_user option.
(write_local_func_for_structure): Likewise.
(main): Mark types with for_user option as used.
* ggc.h (gt_pch_nx): Add overload for unsigned int.
* hash-map.h (hash_map::hash_entry::pch_nx_helper): AddOverloads.
* hash-table.h (ggc_hasher): New struct.
(hash_table::create_ggc): New function.
(gt_pch_nx): New overload for hash_table.
java/
* class.c, decl.c, except.c, expr.c, java-tree.h, lang.c: Use
hash_table instead of hashtab.
objc/
* objc-act.c: use hash_table instead of hashtab.
cp/
* cp-gimplify.c, cp-tree.h, decl.c, mangle.c, name-lookup.c,
pt.c, semantics.c, tree.c, typeck2.c: Use hash_table instead of
hashtab.
fortran/
* trans-decl.c, trans.c, trans.h: Use hash_table instead of hashtab.
c-family/
* c-common.c: Use hash_table instead of hashtab.
From-SVN: r216127
Diffstat (limited to 'gcc/dwarf2out.c')
-rw-r--r-- | gcc/dwarf2out.c | 393 |
1 files changed, 200 insertions, 193 deletions
diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c index 66cdc96..00eba78 100644 --- a/gcc/dwarf2out.c +++ b/gcc/dwarf2out.c @@ -205,7 +205,7 @@ static GTY(()) section *debug_frame_section; static GTY(()) vec<dw_fde_ref, va_gc> *fde_vec; -struct GTY(()) indirect_string_node { +struct GTY((for_user)) indirect_string_node { const char *str; unsigned int refcount; enum dwarf_form form; @@ -213,7 +213,15 @@ struct GTY(()) indirect_string_node { unsigned int index; }; -static GTY ((param_is (struct indirect_string_node))) htab_t debug_str_hash; +struct indirect_string_hasher : ggc_hasher<indirect_string_node *> +{ + typedef const char *compare_type; + + static hashval_t hash (indirect_string_node *); + static bool equal (indirect_string_node *, const char *); +}; + +static GTY (()) hash_table<indirect_string_hasher> *debug_str_hash; /* With split_debug_info, both the comp_dir and dwo_name go in the main object file, rather than the dwo, similar to the force_direct @@ -234,8 +242,7 @@ static GTY ((param_is (struct indirect_string_node))) htab_t debug_str_hash; main object file. This limits the complexity to just the places that need it. */ -static GTY ((param_is (struct indirect_string_node))) - htab_t skeleton_debug_str_hash; +static GTY (()) hash_table<indirect_string_hasher> *skeleton_debug_str_hash; static GTY(()) int dw2_string_counter; @@ -1235,7 +1242,7 @@ dwarf2out_switch_text_section (void) for emitting location expressions. */ /* Data about a single source file. */ -struct GTY(()) dwarf_file_data { +struct GTY((for_user)) dwarf_file_data { const char * filename; int emitted_number; }; @@ -1258,7 +1265,7 @@ enum ate_kind { ate_kind_label }; -typedef struct GTY(()) addr_table_entry_struct { +typedef struct GTY((for_user)) addr_table_entry_struct { enum ate_kind kind; unsigned int refcount; unsigned int index; @@ -2417,7 +2424,6 @@ build_cfa_aligned_loc (dw_cfa_location *cfa, /* And now, the support for symbolic debugging information. */ /* .debug_str support. */ -static int output_indirect_string (void **, void *); static void dwarf2out_init (const char *); static void dwarf2out_finish (const char *); @@ -2589,7 +2595,7 @@ dw_attr_node; The children of each node form a circular list linked by die_sib. die_child points to the node *before* the "first" child node. */ -typedef struct GTY((chain_circular ("%h.die_sib"))) die_struct { +typedef struct GTY((chain_circular ("%h.die_sib"), for_user)) die_struct { union die_symbol_or_type_node { const char * GTY ((tag ("0"))) die_symbol; @@ -2775,16 +2781,37 @@ static GTY(()) limbo_die_node *limbo_die_list; DW_AT_{,MIPS_}linkage_name once their DECL_ASSEMBLER_NAMEs are set. */ static GTY(()) limbo_die_node *deferred_asm_name; +struct dwarf_file_hasher : ggc_hasher<dwarf_file_data *> +{ + typedef const char *compare_type; + + static hashval_t hash (dwarf_file_data *); + static bool equal (dwarf_file_data *, const char *); +}; + /* Filenames referenced by this compilation unit. */ -static GTY((param_is (struct dwarf_file_data))) htab_t file_table; +static GTY(()) hash_table<dwarf_file_hasher> *file_table; +struct decl_die_hasher : ggc_hasher<die_node *> +{ + typedef tree compare_type; + + static hashval_t hash (die_node *); + static bool equal (die_node *, tree); +}; /* A hash table of references to DIE's that describe declarations. The key is a DECL_UID() which is a unique number identifying each decl. */ -static GTY ((param_is (struct die_struct))) htab_t decl_die_table; +static GTY (()) hash_table<decl_die_hasher> *decl_die_table; + +struct block_die_hasher : ggc_hasher<die_struct *> +{ + static hashval_t hash (die_struct *); + static bool equal (die_struct *, die_struct *); +}; /* A hash table of references to DIE's that describe COMMON blocks. The key is DECL_UID() ^ die_parent. */ -static GTY ((param_is (struct die_struct))) htab_t common_block_die_table; +static GTY (()) hash_table<block_die_hasher> *common_block_die_table; typedef struct GTY(()) die_arg_entry_struct { dw_die_ref die; @@ -2808,7 +2835,7 @@ struct GTY ((chain_next ("%h.next"))) var_loc_node { }; /* Variable location list. */ -struct GTY (()) var_loc_list_def { +struct GTY ((for_user)) var_loc_list_def { struct var_loc_node * GTY (()) first; /* Pointer to the last but one or last element of the @@ -2840,8 +2867,16 @@ struct GTY ((chain_next ("%h.next"))) call_arg_loc_node { }; +struct decl_loc_hasher : ggc_hasher<var_loc_list *> +{ + typedef const_tree compare_type; + + static hashval_t hash (var_loc_list *); + static bool equal (var_loc_list *, const_tree); +}; + /* Table of decl location linked lists. */ -static GTY ((param_is (var_loc_list))) htab_t decl_loc_table; +static GTY (()) hash_table<decl_loc_hasher> *decl_loc_table; /* Head and tail of call_arg_loc chain. */ static GTY (()) struct call_arg_loc_node *call_arg_locations; @@ -2857,7 +2892,7 @@ static int tail_call_site_count = -1; static vec<dw_die_ref> block_map; /* A cached location list. */ -struct GTY (()) cached_dw_loc_list_def { +struct GTY ((for_user)) cached_dw_loc_list_def { /* The DECL_UID of the decl that this entry describes. */ unsigned int decl_id; @@ -2866,8 +2901,17 @@ struct GTY (()) cached_dw_loc_list_def { }; typedef struct cached_dw_loc_list_def cached_dw_loc_list; +struct dw_loc_list_hasher : ggc_hasher<cached_dw_loc_list *> +{ + + typedef const_tree compare_type; + + static hashval_t hash (cached_dw_loc_list *); + static bool equal (cached_dw_loc_list *, const_tree); +}; + /* Table of cached location lists. */ -static GTY ((param_is (cached_dw_loc_list))) htab_t cached_dw_loc_list_table; +static GTY (()) hash_table<dw_loc_list_hasher> *cached_dw_loc_list_table; /* A pointer to the base of a list of references to DIE's that are uniquely identified by their tag, presence/absence of @@ -3002,8 +3046,6 @@ static void add_AT_double (dw_die_ref, enum dwarf_attribute, static inline void add_AT_vec (dw_die_ref, enum dwarf_attribute, unsigned int, unsigned int, unsigned char *); static void add_AT_data8 (dw_die_ref, enum dwarf_attribute, unsigned char *); -static hashval_t debug_str_do_hash (const void *); -static int debug_str_eq (const void *, const void *); static void add_AT_string (dw_die_ref, enum dwarf_attribute, const char *); static inline const char *AT_string (dw_attr_ref); static enum dwarf_form AT_string_form (dw_attr_ref); @@ -3048,13 +3090,7 @@ static dw_die_ref lookup_type_die (tree); static dw_die_ref strip_naming_typedef (tree, dw_die_ref); static dw_die_ref lookup_type_die_strip_naming_typedef (tree); static void equate_type_number_to_die (tree, dw_die_ref); -static hashval_t decl_die_table_hash (const void *); -static int decl_die_table_eq (const void *, const void *); static dw_die_ref lookup_decl_die (tree); -static hashval_t common_block_die_table_hash (const void *); -static int common_block_die_table_eq (const void *, const void *); -static hashval_t decl_loc_table_hash (const void *); -static int decl_loc_table_eq (const void *, const void *); static var_loc_list *lookup_decl_loc (const_tree); static void equate_decl_number_to_die (tree, dw_die_ref); static struct var_loc_node *add_var_loc_to_decl (tree, rtx, const char *); @@ -3908,29 +3944,28 @@ add_AT_low_high_pc (dw_die_ref die, const char *lbl_low, const char *lbl_high, /* Hash and equality functions for debug_str_hash. */ -static hashval_t -debug_str_do_hash (const void *x) +hashval_t +indirect_string_hasher::hash (indirect_string_node *x) { - return htab_hash_string (((const struct indirect_string_node *)x)->str); + return htab_hash_string (x->str); } -static int -debug_str_eq (const void *x1, const void *x2) +bool +indirect_string_hasher::equal (indirect_string_node *x1, const char *x2) { - return strcmp ((((const struct indirect_string_node *)x1)->str), - (const char *)x2) == 0; + return strcmp (x1->str, x2) == 0; } /* Add STR to the given string hash table. */ static struct indirect_string_node * -find_AT_string_in_table (const char *str, htab_t table) +find_AT_string_in_table (const char *str, + hash_table<indirect_string_hasher> *table) { struct indirect_string_node *node; - void **slot; - slot = htab_find_slot_with_hash (table, str, - htab_hash_string (str), INSERT); + indirect_string_node **slot + = table->find_slot_with_hash (str, htab_hash_string (str), INSERT); if (*slot == NULL) { node = ggc_cleared_alloc<indirect_string_node> (); @@ -3938,7 +3973,7 @@ find_AT_string_in_table (const char *str, htab_t table) *slot = node; } else - node = (struct indirect_string_node *) *slot; + node = *slot; node->refcount++; return node; @@ -3950,8 +3985,7 @@ static struct indirect_string_node * find_AT_string (const char *str) { if (! debug_str_hash) - debug_str_hash = htab_create_ggc (10, debug_str_do_hash, - debug_str_eq, NULL); + debug_str_hash = hash_table<indirect_string_hasher>::create_ggc (10); return find_AT_string_in_table (str, debug_str_hash); } @@ -4180,16 +4214,21 @@ AT_loc_list_ptr (dw_attr_ref a) return &a->dw_attr_val.v.val_loc_list; } +struct addr_hasher : ggc_hasher<addr_table_entry *> +{ + static hashval_t hash (addr_table_entry *); + static bool equal (addr_table_entry *, addr_table_entry *); +}; + /* Table of entries into the .debug_addr section. */ -static GTY ((param_is (addr_table_entry))) htab_t addr_index_table; +static GTY (()) hash_table<addr_hasher> *addr_index_table; /* Hash an address_table_entry. */ -static hashval_t -addr_table_entry_do_hash (const void *x) +hashval_t +addr_hasher::hash (addr_table_entry *a) { - const addr_table_entry *a = (const addr_table_entry *) x; inchash::hash hstate; switch (a->kind) { @@ -4210,12 +4249,9 @@ addr_table_entry_do_hash (const void *x) /* Determine equality for two address_table_entries. */ -static int -addr_table_entry_eq (const void *x1, const void *x2) +bool +addr_hasher::equal (addr_table_entry *a1, addr_table_entry *a2) { - const addr_table_entry *a1 = (const addr_table_entry *) x1; - const addr_table_entry *a2 = (const addr_table_entry *) x2; - if (a1->kind != a2->kind) return 0; switch (a1->kind) @@ -4258,14 +4294,12 @@ add_addr_table_entry (void *addr, enum ate_kind kind) { addr_table_entry *node; addr_table_entry finder; - void **slot; gcc_assert (dwarf_split_debug_info); if (! addr_index_table) - addr_index_table = htab_create_ggc (10, addr_table_entry_do_hash, - addr_table_entry_eq, NULL); + addr_index_table = hash_table<addr_hasher>::create_ggc (10); init_addr_table_entry (&finder, kind, addr); - slot = htab_find_slot (addr_index_table, &finder, INSERT); + addr_table_entry **slot = addr_index_table->find_slot (&finder, INSERT); if (*slot == HTAB_EMPTY_ENTRY) { @@ -4274,7 +4308,7 @@ add_addr_table_entry (void *addr, enum ate_kind kind) *slot = node; } else - node = (addr_table_entry *) *slot; + node = *slot; node->refcount++; return node; @@ -4314,11 +4348,10 @@ remove_loc_list_addr_table_entries (dw_loc_descr_ref descr) because the indexing code relies on htab_traverse to traverse nodes in the same order for each run. */ -static int -index_addr_table_entry (void **h, void *v) +int +index_addr_table_entry (addr_table_entry **h, unsigned int *index) { - addr_table_entry *node = (addr_table_entry *) *h; - unsigned int *index = (unsigned int *) v; + addr_table_entry *node = *h; /* Don't index unreferenced nodes. */ if (node->refcount == 0) @@ -4913,18 +4946,18 @@ equate_type_number_to_die (tree type, dw_die_ref type_die) /* Returns a hash value for X (which really is a die_struct). */ -static hashval_t -decl_die_table_hash (const void *x) +inline hashval_t +decl_die_hasher::hash (die_node *x) { - return (hashval_t) ((const_dw_die_ref) x)->decl_id; + return (hashval_t) x->decl_id; } /* Return nonzero if decl_id of die_struct X is the same as UID of decl *Y. */ -static int -decl_die_table_eq (const void *x, const void *y) +inline bool +decl_die_hasher::equal (die_node *x, tree y) { - return (((const_dw_die_ref) x)->decl_id == DECL_UID ((const_tree) y)); + return (x->decl_id == DECL_UID (y)); } /* Return the DIE associated with a given declaration. */ @@ -4932,24 +4965,24 @@ decl_die_table_eq (const void *x, const void *y) static inline dw_die_ref lookup_decl_die (tree decl) { - return (dw_die_ref) htab_find_with_hash (decl_die_table, decl, DECL_UID (decl)); + return decl_die_table->find_with_hash (decl, DECL_UID (decl)); } /* Returns a hash value for X (which really is a var_loc_list). */ -static hashval_t -decl_loc_table_hash (const void *x) +inline hashval_t +decl_loc_hasher::hash (var_loc_list *x) { - return (hashval_t) ((const var_loc_list *) x)->decl_id; + return (hashval_t) x->decl_id; } /* Return nonzero if decl_id of var_loc_list X is the same as UID of decl *Y. */ -static int -decl_loc_table_eq (const void *x, const void *y) +inline bool +decl_loc_hasher::equal (var_loc_list *x, const_tree y) { - return (((const var_loc_list *) x)->decl_id == DECL_UID ((const_tree) y)); + return (x->decl_id == DECL_UID (y)); } /* Return the var_loc list associated with a given declaration. */ @@ -4959,26 +4992,24 @@ lookup_decl_loc (const_tree decl) { if (!decl_loc_table) return NULL; - return (var_loc_list *) - htab_find_with_hash (decl_loc_table, decl, DECL_UID (decl)); + return decl_loc_table->find_with_hash (decl, DECL_UID (decl)); } /* Returns a hash value for X (which really is a cached_dw_loc_list_list). */ -static hashval_t -cached_dw_loc_list_table_hash (const void *x) +inline hashval_t +dw_loc_list_hasher::hash (cached_dw_loc_list *x) { - return (hashval_t) ((const cached_dw_loc_list *) x)->decl_id; + return (hashval_t) x->decl_id; } /* Return nonzero if decl_id of cached_dw_loc_list X is the same as UID of decl *Y. */ -static int -cached_dw_loc_list_table_eq (const void *x, const void *y) +inline bool +dw_loc_list_hasher::equal (cached_dw_loc_list *x, const_tree y) { - return (((const cached_dw_loc_list *) x)->decl_id - == DECL_UID ((const_tree) y)); + return (x->decl_id == DECL_UID (y)); } /* Equate a DIE to a particular declaration. */ @@ -4987,10 +5018,8 @@ static void equate_decl_number_to_die (tree decl, dw_die_ref decl_die) { unsigned int decl_id = DECL_UID (decl); - void **slot; - slot = htab_find_slot_with_hash (decl_die_table, decl, decl_id, INSERT); - *slot = decl_die; + *decl_die_table->find_slot_with_hash (decl, decl_id, INSERT) = decl_die; decl_die->decl_id = decl_id; } @@ -5138,7 +5167,6 @@ add_var_loc_to_decl (tree decl, rtx loc_note, const char *label) { unsigned int decl_id; var_loc_list *temp; - void **slot; struct var_loc_node *loc = NULL; HOST_WIDE_INT bitsize = -1, bitpos = -1; @@ -5166,7 +5194,8 @@ add_var_loc_to_decl (tree decl, rtx loc_note, const char *label) } decl_id = DECL_UID (decl); - slot = htab_find_slot_with_hash (decl_loc_table, decl, decl_id, INSERT); + var_loc_list **slot + = decl_loc_table->find_slot_with_hash (decl, decl_id, INSERT); if (*slot == NULL) { temp = ggc_cleared_alloc<var_loc_list> (); @@ -5174,7 +5203,7 @@ add_var_loc_to_decl (tree decl, rtx loc_note, const char *label) *slot = temp; } else - temp = (var_loc_list *) *slot; + temp = *slot; /* For PARM_DECLs try to keep around the original incoming value, even if that means we'll emit a zero-range .debug_loc entry. */ @@ -9037,8 +9066,8 @@ add_skeleton_AT_string (dw_die_ref die, enum dwarf_attribute attr_kind, struct indirect_string_node *node; if (! skeleton_debug_str_hash) - skeleton_debug_str_hash = htab_create_ggc (10, debug_str_do_hash, - debug_str_eq, NULL); + skeleton_debug_str_hash + = hash_table<indirect_string_hasher>::create_ggc (10); node = find_AT_string_in_table (str, skeleton_debug_str_hash); find_string_form (node); @@ -9739,11 +9768,10 @@ struct file_name_acquire_data /* Traversal function for the hash table. */ -static int -file_name_acquire (void ** slot, void *data) +int +file_name_acquire (dwarf_file_data **slot, file_name_acquire_data *fnad) { - struct file_name_acquire_data *fnad = (struct file_name_acquire_data *) data; - struct dwarf_file_data *d = (struct dwarf_file_data *) *slot; + struct dwarf_file_data *d = *slot; struct file_info *fi; const char *f; @@ -9818,7 +9846,7 @@ output_file_names (void) fnad.files = files; fnad.used_files = 0; fnad.max_files = numfiles; - htab_traverse (file_table, file_name_acquire, &fnad); + file_table->traverse<file_name_acquire_data *, file_name_acquire> (&fnad); gcc_assert (fnad.used_files == fnad.max_files); qsort (files, numfiles, sizeof (files[0]), file_info_cmp); @@ -15812,7 +15840,6 @@ add_location_or_const_value_attribute (dw_die_ref die, tree decl, bool cache_p, dw_loc_list_ref list; var_loc_list *loc_list; cached_dw_loc_list *cache; - void **slot; if (TREE_CODE (decl) == ERROR_MARK) return false; @@ -15856,8 +15883,7 @@ add_location_or_const_value_attribute (dw_die_ref die, tree decl, bool cache_p, cache_p = false; if (cache_p) { - cache = (cached_dw_loc_list *) - htab_find_with_hash (cached_dw_loc_list_table, decl, DECL_UID (decl)); + cache = cached_dw_loc_list_table->find_with_hash (decl, DECL_UID (decl)); if (cache) list = cache->loc_list; } @@ -15868,8 +15894,10 @@ add_location_or_const_value_attribute (dw_die_ref die, tree decl, bool cache_p, BLOCK_NONLOCALIZED_VARS and if the list has at least two elements. */ if (cache_p && list && list->dw_loc_next) { - slot = htab_find_slot_with_hash (cached_dw_loc_list_table, decl, - DECL_UID (decl), INSERT); + cached_dw_loc_list **slot + = cached_dw_loc_list_table->find_slot_with_hash (decl, + DECL_UID (decl), + INSERT); cache = ggc_cleared_alloc<cached_dw_loc_list> (); cache->decl_id = DECL_UID (decl); cache->loc_list = list; @@ -17991,8 +18019,8 @@ dwarf2out_abstract_function (tree decl) tree save_fn; tree context; int was_abstract; - htab_t old_decl_loc_table; - htab_t old_cached_dw_loc_list_table; + hash_table<decl_loc_hasher> *old_decl_loc_table; + hash_table<dw_loc_list_hasher> *old_cached_dw_loc_list_table; int old_call_site_count, old_tail_call_site_count; struct call_arg_loc_node *old_call_arg_locations; @@ -18070,9 +18098,9 @@ premark_used_types_helper (tree const &type, void *) marked as unused by prune_unused_types. The DIE of the type is marked only if the global variable using the type will actually be emitted. */ -static int -premark_types_used_by_global_vars_helper (void **slot, - void *data ATTRIBUTE_UNUSED) +int +premark_types_used_by_global_vars_helper (types_used_by_vars_entry **slot, + void *) { struct types_used_by_vars_entry *entry; dw_die_ref die; @@ -18112,8 +18140,8 @@ static void premark_types_used_by_global_vars (void) { if (types_used_by_vars_hash) - htab_traverse (types_used_by_vars_hash, - premark_types_used_by_global_vars_helper, NULL); + types_used_by_vars_hash + ->traverse<void *, premark_types_used_by_global_vars_helper> (NULL); } /* Generate a DW_TAG_GNU_call_site DIE in function DECL under SUBR_DIE @@ -18782,22 +18810,19 @@ gen_subprogram_die (tree decl, dw_die_ref context_die) /* Returns a hash value for X (which really is a die_struct). */ -static hashval_t -common_block_die_table_hash (const void *x) +hashval_t +block_die_hasher::hash (die_struct *d) { - const_dw_die_ref d = (const_dw_die_ref) x; return (hashval_t) d->decl_id ^ htab_hash_pointer (d->die_parent); } /* Return nonzero if decl_id and die_parent of die_struct X is the same as decl_id and die_parent of die_struct Y. */ -static int -common_block_die_table_eq (const void *x, const void *y) +bool +block_die_hasher::equal (die_struct *x, die_struct *y) { - const_dw_die_ref d = (const_dw_die_ref) x; - const_dw_die_ref e = (const_dw_die_ref) y; - return d->decl_id == e->decl_id && d->die_parent == e->die_parent; + return x->decl_id == y->decl_id && x->die_parent == y->die_parent; } /* Generate a DIE to represent a declared data object. @@ -18862,19 +18887,17 @@ gen_variable_die (tree decl, tree origin, dw_die_ref context_die) } if (common_block_die_table == NULL) - common_block_die_table - = htab_create_ggc (10, common_block_die_table_hash, - common_block_die_table_eq, NULL); + common_block_die_table = hash_table<block_die_hasher>::create_ggc (10); com_die_arg.decl_id = DECL_UID (com_decl); com_die_arg.die_parent = context_die; - com_die = (dw_die_ref) htab_find (common_block_die_table, &com_die_arg); + com_die = common_block_die_table->find (&com_die_arg); loc = loc_list_from_tree (com_decl, 2); if (com_die == NULL) { const char *cnam = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (com_decl)); - void **slot; + die_node **slot; com_die = new_die (DW_TAG_common_block, context_die, decl); add_name_and_src_coords_attributes (com_die, com_decl); @@ -18890,8 +18913,8 @@ gen_variable_die (tree decl, tree origin, dw_die_ref context_die) if (want_pubnames ()) add_pubname_string (cnam, com_die); /* ??? needed? */ com_die->decl_id = DECL_UID (com_decl); - slot = htab_find_slot (common_block_die_table, com_die, INSERT); - *slot = (void *) com_die; + slot = common_block_die_table->find_slot (com_die, INSERT); + *slot = com_die; } else if (get_AT (com_die, DW_AT_location) == NULL && loc) { @@ -21066,8 +21089,8 @@ dwarf2out_function_decl (tree decl) call_site_count = -1; tail_call_site_count = -1; block_map.release (); - htab_empty (decl_loc_table); - htab_empty (cached_dw_loc_list_table); + decl_loc_table->empty (); + cached_dw_loc_list_table->empty (); } /* Output a marker (i.e. a label) for the beginning of the generated code for @@ -21121,19 +21144,15 @@ dwarf2out_ignore_block (const_tree block) /* Hash table routines for file_hash. */ -static int -file_table_eq (const void *p1_p, const void *p2_p) +bool +dwarf_file_hasher::equal (dwarf_file_data *p1, const char *p2) { - const struct dwarf_file_data *const p1 = - (const struct dwarf_file_data *) p1_p; - const char *const p2 = (const char *) p2_p; return filename_cmp (p1->filename, p2) == 0; } -static hashval_t -file_table_hash (const void *p_p) +hashval_t +dwarf_file_hasher::hash (dwarf_file_data *p) { - const struct dwarf_file_data *const p = (const struct dwarf_file_data *) p_p; return htab_hash_string (p->filename); } @@ -21151,7 +21170,6 @@ file_table_hash (const void *p_p) static struct dwarf_file_data * lookup_filename (const char *file_name) { - void ** slot; struct dwarf_file_data * created; /* Check to see if the file name that was searched on the previous @@ -21162,10 +21180,11 @@ lookup_filename (const char *file_name) return file_table_last_lookup; /* Didn't match the previous lookup, search the table. */ - slot = htab_find_slot_with_hash (file_table, file_name, - htab_hash_string (file_name), INSERT); + dwarf_file_data **slot + = file_table->find_slot_with_hash (file_name, htab_hash_string (file_name), + INSERT); if (*slot) - return (struct dwarf_file_data *) *slot; + return *slot; created = ggc_alloc<dwarf_file_data> (); created->filename = file_name; @@ -21525,10 +21544,10 @@ dwarf2out_var_location (rtx_insn *loc_note) /* Note in one location list that text section has changed. */ -static int -var_location_switch_text_section_1 (void **slot, void *data ATTRIBUTE_UNUSED) +int +var_location_switch_text_section_1 (var_loc_list **slot, void *) { - var_loc_list *list = (var_loc_list *) *slot; + var_loc_list *list = *slot; if (list->first) list->last_before_switch = list->last->next ? list->last->next : list->last; @@ -21543,7 +21562,7 @@ var_location_switch_text_section (void) if (decl_loc_table == NULL) return; - htab_traverse (decl_loc_table, var_location_switch_text_section_1, NULL); + decl_loc_table->traverse<void *, var_location_switch_text_section_1> (NULL); } /* Create a new line number table. */ @@ -21652,13 +21671,12 @@ dwarf2out_begin_function (tree fun) Set have_multiple_function_sections to true in that case and terminate htab traversal. */ -static int -find_empty_loc_ranges_at_text_label (void **slot, void *) +int +find_empty_loc_ranges_at_text_label (var_loc_list **slot, int) { - var_loc_list *entry; + var_loc_list *entry = *slot; struct var_loc_node *node; - entry = (var_loc_list *) *slot; node = entry->first; if (node && node->next && node->next->label) { @@ -21689,8 +21707,7 @@ dwarf2out_end_function (unsigned int) && !have_multiple_function_sections && first_loclabel_num_not_at_text_label && decl_loc_table) - htab_traverse (decl_loc_table, find_empty_loc_ranges_at_text_label, - NULL); + decl_loc_table->traverse<int, find_empty_loc_ranges_at_text_label> (0); in_first_function_p = false; maybe_at_text_label_p = false; } @@ -22303,21 +22320,16 @@ static void dwarf2out_init (const char *filename ATTRIBUTE_UNUSED) { /* Allocate the file_table. */ - file_table = htab_create_ggc (50, file_table_hash, - file_table_eq, NULL); + file_table = hash_table<dwarf_file_hasher>::create_ggc (50); /* Allocate the decl_die_table. */ - decl_die_table = htab_create_ggc (10, decl_die_table_hash, - decl_die_table_eq, NULL); + decl_die_table = hash_table<decl_die_hasher>::create_ggc (10); /* Allocate the decl_loc_table. */ - decl_loc_table = htab_create_ggc (10, decl_loc_table_hash, - decl_loc_table_eq, NULL); + decl_loc_table = hash_table<decl_loc_hasher>::create_ggc (10); /* Allocate the cached_dw_loc_list_table. */ - cached_dw_loc_list_table - = htab_create_ggc (10, cached_dw_loc_list_table_hash, - cached_dw_loc_list_table_eq, NULL); + cached_dw_loc_list_table = hash_table<dw_loc_list_hasher>::create_ggc (10); /* Allocate the initial hunk of the decl_scope_table. */ vec_alloc (decl_scope_table, 256); @@ -22450,11 +22462,10 @@ dwarf2out_assembly_start (void) because the indexing code relies on htab_traverse to traverse nodes in the same order for each run. */ -static int -index_string (void **h, void *v) +int +index_string (indirect_string_node **h, unsigned int *index) { - struct indirect_string_node *node = (struct indirect_string_node *) *h; - unsigned int *index = (unsigned int *) v; + indirect_string_node *node = *h; find_string_form (node); if (node->form == DW_FORM_GNU_str_index && node->refcount > 0) @@ -22470,11 +22481,10 @@ index_string (void **h, void *v) htab_traverse. Output the offset to a string and update the current offset. */ -static int -output_index_string_offset (void **h, void *v) +int +output_index_string_offset (indirect_string_node **h, unsigned int *offset) { - struct indirect_string_node *node = (struct indirect_string_node *) *h; - unsigned int *offset = (unsigned int *) v; + indirect_string_node *node = *h; if (node->form == DW_FORM_GNU_str_index && node->refcount > 0) { @@ -22491,11 +22501,10 @@ output_index_string_offset (void **h, void *v) /* A helper function for dwarf2out_finish called through htab_traverse. Output the indexed string. */ -static int -output_index_string (void **h, void *v) +int +output_index_string (indirect_string_node **h, unsigned int *cur_idx) { - struct indirect_string_node *node = (struct indirect_string_node *) *h; - unsigned int *cur_idx = (unsigned int *) v; + struct indirect_string_node *node = *h; if (node->form == DW_FORM_GNU_str_index && node->refcount > 0) { @@ -22511,10 +22520,10 @@ output_index_string (void **h, void *v) /* A helper function for dwarf2out_finish called through htab_traverse. Emit one queued .debug_str string. */ -static int -output_indirect_string (void **h, void *v ATTRIBUTE_UNUSED) +int +output_indirect_string (indirect_string_node **h, void *) { - struct indirect_string_node *node = (struct indirect_string_node *) *h; + struct indirect_string_node *node = *h; node->form = find_string_form (node); if (node->form == DW_FORM_strp && node->refcount > 0) @@ -22533,33 +22542,30 @@ output_indirect_strings (void) { switch_to_section (debug_str_section); if (!dwarf_split_debug_info) - htab_traverse (debug_str_hash, output_indirect_string, NULL); + debug_str_hash->traverse<void *, output_indirect_string> (NULL); else { unsigned int offset = 0; unsigned int cur_idx = 0; - htab_traverse (skeleton_debug_str_hash, output_indirect_string, NULL); + skeleton_debug_str_hash->traverse<void *, output_indirect_string> (NULL); switch_to_section (debug_str_offsets_section); - htab_traverse_noresize (debug_str_hash, - output_index_string_offset, - &offset); + debug_str_hash->traverse_noresize + <unsigned int *, output_index_string_offset> (&offset); switch_to_section (debug_str_dwo_section); - htab_traverse_noresize (debug_str_hash, - output_index_string, - &cur_idx); + debug_str_hash->traverse_noresize<unsigned int *, output_index_string> + (&cur_idx); } } /* Callback for htab_traverse to assign an index to an entry in the table, and to write that entry to the .debug_addr section. */ -static int -output_addr_table_entry (void **slot, void *data) +int +output_addr_table_entry (addr_table_entry **slot, unsigned int *cur_index) { - addr_table_entry *entry = (addr_table_entry *) *slot; - unsigned int *cur_index = (unsigned int *)data; + addr_table_entry *entry = *slot; if (entry->refcount == 0) { @@ -22600,11 +22606,12 @@ static void output_addr_table (void) { unsigned int index = 0; - if (addr_index_table == NULL || htab_size (addr_index_table) == 0) + if (addr_index_table == NULL || addr_index_table->size () == 0) return; switch_to_section (debug_addr_section); - htab_traverse_noresize (addr_index_table, output_addr_table_entry, &index); + addr_index_table + ->traverse_noresize<unsigned int *, output_addr_table_entry> (&index); } #if ENABLE_ASSERT_CHECKING @@ -22859,10 +22866,10 @@ prune_unused_types_update_strings (dw_die_ref die) if (s->refcount == ((DEBUG_STR_SECTION_FLAGS & SECTION_MERGE) ? 1 : 2)) { - void ** slot; - slot = htab_find_slot_with_hash (debug_str_hash, s->str, - htab_hash_string (s->str), - INSERT); + indirect_string_node **slot + = debug_str_hash->find_slot_with_hash (s->str, + htab_hash_string (s->str), + INSERT); gcc_assert (*slot == NULL); *slot = s; } @@ -22950,9 +22957,9 @@ prune_unused_types (void) prune_unused_types_mark (base_type, 1); if (debug_str_hash) - htab_empty (debug_str_hash); + debug_str_hash->empty (); if (skeleton_debug_str_hash) - htab_empty (skeleton_debug_str_hash); + skeleton_debug_str_hash->empty (); prune_unused_types_prune (comp_unit_die ()); for (node = limbo_die_list; node; node = node->next) prune_unused_types_prune (node->die); @@ -22969,11 +22976,10 @@ prune_unused_types (void) /* Set the parameter to true if there are any relative pathnames in the file table. */ -static int -file_table_relative_p (void ** slot, void *param) +int +file_table_relative_p (dwarf_file_data **slot, bool *p) { - bool *p = (bool *) param; - struct dwarf_file_data *d = (struct dwarf_file_data *) *slot; + struct dwarf_file_data *d = *slot; if (!IS_ABSOLUTE_PATH (d->filename)) { *p = true; @@ -24222,7 +24228,7 @@ dwarf2out_finish (const char *filename) else if (get_AT (comp_unit_die (), DW_AT_comp_dir) == NULL) { bool p = false; - htab_traverse (file_table, file_table_relative_p, &p); + file_table->traverse<bool *, file_table_relative_p> (&p); if (p) add_comp_dir_attribute (comp_unit_die ()); } @@ -24444,8 +24450,9 @@ dwarf2out_finish (const char *filename) if (addr_index_table != NULL) { unsigned int index = 0; - htab_traverse_noresize (addr_index_table, - index_addr_table_entry, &index); + addr_index_table + ->traverse_noresize<unsigned int *, index_addr_table_entry> + (&index); } } @@ -24464,7 +24471,7 @@ dwarf2out_finish (const char *filename) skeleton die attrs are added when the skeleton type unit is created, so ensure it is created by this point. */ add_top_level_skeleton_die_attrs (main_comp_unit_die); - htab_traverse_noresize (debug_str_hash, index_string, &index); + debug_str_hash->traverse_noresize<unsigned int *, index_string> (&index); } /* Output all of the compilation units. We put the main one last so that |