Richard Sandiford <richard.sandif...@arm.com> writes:
> Rainer Orth <r...@cebitec.uni-bielefeld.de> writes:
>> Richard Sandiford <richard.sandif...@arm.com> writes:
>>
>>> Rainer Orth <r...@cebitec.uni-bielefeld.de> writes:
>>>> Jeff Law <l...@redhat.com> writes:
>>>>
>>>>> On 06/23/2015 08:57 AM, Richard Sandiford wrote:
>>>>>> At this point all hash_map traits know what kind of key they're
>>>>>> dealing with, so we can make that a traits typedef, like it is for
>>>>>> hash_table traits.  Then, if we make the default hash traits for
>>>>>> T be T, we can use hash_table-style traits as the first template
>>>>>> parameter to hash_map, without the need for a third.  That is, if
>>>>>> foo_hash hashes elements of type foo_type:
>>>>>>
>>>>>>    typedef simple_hashmap_traits <foo_hash> foo_traits;
>>>>>>    hash_map <foo_type, value_type, foo_traits> x;
>>>>>>
>>>>>> becomes just:
>>>>>>
>>>>>>    hash_map <foo_hash, value_type> x;
>>>>>>
>>>>>> just like a hash_table of foo_types would be:
>>>>>>
>>>>>>    hash_table <foo_hash> y;
>>>>>>
>>>>>> This patch makes that simplification.
>>>>>>
>>>>>>
>>>>>> gcc/
>>>>>>  * hash-map-traits.h (simple_hashmap_traits::key_type): New typedef.
>>>>>>  (unbounded_int_hashmap_traits::key_type): Likewise.
>>>>>>  * hash-map.h (hash_map): Get the key type from the traits.
>>>>>>  * hash-traits.h (default_hash_traits): By default, inherit from the
>>>>>>  template parameter.
>>>>>>  * alias.c (alias_set_traits): Delete.
>>>>>>  (alias_set_entry_d::children): Use alias_set_hash as the first
>>>>>>  template parameter.
>>>>>>  (record_alias_subset): Update accordingly.
>>>>>>  * except.c (tree_hash_traits): Delete.
>>>>>>  (type_to_runtime_map): Use tree_hash as the first template parameter.
>>>>>>  (init_eh): Update accordingly.
>>>>>>  * genmatch.c (capture_id_map_hasher): Delete.
>>>>>>  (cid_map_t): Use nofree_string_hash as first template parameter.
>>>>>>  * ipa-icf.h (symbol_compare_hashmap_traits): Delete.
>>>>>>  * ipa-icf.c (sem_item_optimizer::subdivide_classes_by_sensitive_refs):
>>>>>>  Use symbol_compare_hash as the first template parameter in
>>>>>>  subdivide_hash_map.
>>>>>>  * mem-stats.h (mem_usage_pair::mem_alloc_hashmap_traits): Delete.
>>>>>>  (mem_usage_pair::mem_map_t): Use mem_location_hash as the first
>>>>>>  template parameter.
>>>>>>  * passes.c (pass_registry_hasher): Delete.
>>>>>>  (name_to_pass_map): Use nofree_string_hash as the first template
>>>>>>  parameter.
>>>>>>  (register_pass_name): Update accordingly.
>>>>>>  * sanopt.c (sanopt_tree_map_traits): Delete.
>>>>>>  (sanopt_tree_triplet_map_traits): Delete.
>>>>>>  (sanopt_ctx::asan_check_map): Use tree_operand_hash as the first
>>>>>>  template parameter.
>>>>>>  (sanopt_ctx::vptr_check_map): Use sanopt_tree_triplet_hash as
>>>>>>  the first template parameter.
>>>>>>  * sese.c (rename_map_hasher): Delete.
>>>>>>  (rename_map_type): Use tree_ssa_name_hash as the first template
>>>>>>  parameter.
>>>>>>  * symbol-summary.h (function_summary::summary_hashmap_traits): Delete.
>>>>>>  (function_summary::m_map): Use map_hash as the first template
>>>>>>  parameter.
>>>>>>  (function_summary::release): Update accordingly.
>>>>>>  * tree-if-conv.c (phi_args_hash_traits): Delete.
>>>>>>  (predicate_scalar_phi): Use tree_operand_hash as the first template
>>>>>>  parameter to phi_arg_map.
>>>>>>  * tree-inline.h (dependence_hasher): Delete.
>>>>>>  (copy_body_data::dependence_map): Use dependence_hash as the first
>>>>>>  template parameter.
>>>>>>  * tree-inline.c (remap_dependence_clique): Update accordingly.
>>>>>>  * tree-ssa-strlen.c (stridxlist_hash_traits): Delete.
>>>>>>  (decl_to_stridxlist_htab): Use tree_decl_hash as the first template
>>>>>>  parameter.
>>>>>>  (addr_stridxptr): Update accordingly.
>>>>>>  * value-prof.c (profile_id_traits): Delete.
>>>>>>  (cgraph_node_map): Use profile_id_hash as the first template
>>>>>>  parameter.
>>>>>>  (init_node_map): Update accordingly.
>>>>>>  * config/alpha/alpha.c (string_traits): Delete.
>>>>>>  (machine_function::links): Use nofree_string_hash as the first
>>>>>>  template parameter.
>>>>>>  (alpha_use_linkage, alpha_write_linkage): Update accordingly.
>>>>>>  * config/m32c/m32c.c (pragma_traits): Delete.
>>>>>>  (pragma_htab): Use nofree_string_hash as the first template parameter.
>>>>>>  (m32c_note_pragma_address): Update accordingly.
>>>>>>  * config/mep/mep.c (pragma_traits): Delete.
>>>>>>  (pragma_htab): Use nofree_string_hash as the first template parameter.
>>>>>>  (mep_note_pragma_flag): Update accordingly.
>>>>>>  * config/mips/mips.c (mips16_flip_traits): Delete.
>>>>>>  (mflip_mips16_htab): Use nofree_string_hash as the first template
>>>>>>  parameter.
>>>>>>  (mflip_mips16_use_mips16_p): Update accordingly.
>>>>>>  (local_alias_traits): Delete.
>>>>>>  (mips16_local_aliases): Use nofree_string_hash as the first template
>>>>>>  parameter.
>>>>>>  (mips16_local_alias): Update accordingly.
>>>>> Phew.  OK.
>>>>
>>>> According to a reghunt, this patch broke bootstrap (at least with g++
>>>> 4.7 as bootstrap compiler):
>>>
>>> Which target are you using?  I just tried with a gcc 4.7 host compiler
>>> on x86_64-linux-gnu and it seemed to work.
>>
>> I see it on i386-pc-solaris2.1[01] and sparc-sun-solaris2.1[01].
>>
>> gcc 4.9 works there, though.
>
> OK, I can reproduce it with 4.7.2 but it seems to be fixed in 4.7.4.
> Trying to find out what changed as well as find a workaround.

This seems to work for me.

Thanks,
Richard


gcc/
        * hash-map.h (hash_map::traverse): Use the definition of the
        Key typedef rather than the typedef itself.

Index: gcc/hash-map.h
===================================================================
--- gcc/hash-map.h      2015-06-25 18:17:12.360905717 +0100
+++ gcc/hash-map.h      2015-06-26 17:36:36.187837149 +0100
@@ -169,7 +169,8 @@ class GTY((user)) hash_map
   /* Call the call back on each pair of key and value with the passed in
      arg.  */
 
-  template<typename Arg, bool (*f)(const Key &, const Value &, Arg)>
+  template<typename Arg, bool (*f)(const typename Traits::key_type &,
+                                  const Value &, Arg)>
   void traverse (Arg a) const
     {
       for (typename hash_table<hash_entry>::iterator iter = m_table.begin ();
@@ -177,7 +178,8 @@ class GTY((user)) hash_map
        f ((*iter).m_key, (*iter).m_value, a);
     }
 
-  template<typename Arg, bool (*f)(const Key &, Value *, Arg)>
+  template<typename Arg, bool (*f)(const typename Traits::key_type &,
+                                  Value *, Arg)>
   void traverse (Arg a) const
     {
       for (typename hash_table<hash_entry>::iterator iter = m_table.begin ();

Reply via email to