[Bug other/100463] many errors using GTY and hash_map
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100463 --- Comment #1 from Martin Sebor --- Adding the two missing function like below fixes the errors. diff --git a/gcc/except.c b/gcc/except.c index a7902bbd555..913632f5199 100644 --- a/gcc/except.c +++ b/gcc/except.c @@ -149,6 +149,21 @@ static GTY(()) int call_site_base; static GTY(()) hash_map *type_to_runtime_map; +typedef int_hash test_int_hash_t; +typedef hash_map test_int_hash_map_t; +static GTY(()) test_int_hash_map_t *test_int_hash_map; + +inline void +gt_ggc_mx (test_int_hash_t *) +{ +} + +inline void +gt_pch_nx (test_int_hash_t *) +{ +} + + static GTY(()) tree setjmp_fn; /* Describe the SjLj_Function_Context structure. */
[Bug other/100463] many errors using GTY and hash_map
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100463 --- Comment #2 from Martin Sebor --- But suppose I change my mind and want to define a map from HWI_INT to int: diff --git a/gcc/except.c b/gcc/except.c index a7902bbd555..a47841cf395 100644 --- a/gcc/except.c +++ b/gcc/except.c @@ -149,6 +149,21 @@ static GTY(()) int call_site_base; static GTY(()) hash_map *type_to_runtime_map; +typedef int_hash test_int_hash_t; +typedef hash_map test_int_hash_map_t; +static GTY(()) test_int_hash_map_t *test_int_hash_map; + +inline void +gt_ggc_mx (test_int_hash_t *) +{ +} + +inline void +gt_pch_nx (test_int_hash_t *) +{ +} + + static GTY(()) tree setjmp_fn; /* Describe the SjLj_Function_Context structure. */ I now get another series of errors: In file included from /ssd/src/gcc/trunk/gcc/hash-table.h:595, from /ssd/src/gcc/trunk/gcc/coretypes.h:480, from /ssd/src/gcc/trunk/gcc/except.c:114: /ssd/src/gcc/trunk/gcc/hash-map.h: In instantiation of ‘static void hash_map< , , >::hash_entry::pch_nx(hash_map< , , >::hash_entry&) [with KeyId = int_hash; Value = int; Traits = simple_hashmap_traits >, int>]’: /ssd/src/gcc/trunk/gcc/hash-table.h:1198:17: required from ‘void gt_pch_nx(hash_table*) [with D = hash_map, int>::hash_entry]’ /ssd/src/gcc/trunk/gcc/hash-map.h:314:13: required from ‘void gt_pch_nx(hash_map*) [with K = int_hash; V = int; H = simple_hashmap_traits >, int>]’ ./gt-except.h:97:19: required from here /ssd/src/gcc/trunk/gcc/hash-map.h:87:12: error: call of overloaded ‘gt_pch_nx(hash_map, int>::Key&)’ is ambiguous gt_pch_nx (e.m_key); ~~^ In file included from /ssd/src/gcc/trunk/gcc/hash-table.h:247, from /ssd/src/gcc/trunk/gcc/coretypes.h:480, from /ssd/src/gcc/trunk/gcc/except.c:114: /ssd/src/gcc/trunk/gcc/ggc.h:341:1: note: candidate: ‘void gt_pch_nx(int)’ gt_pch_nx (int) ^ /ssd/src/gcc/trunk/gcc/ggc.h:346:1: note: candidate: ‘void gt_pch_nx(unsigned int)’ gt_pch_nx (unsigned int) ^ In file included from /ssd/src/gcc/trunk/gcc/hash-table.h:595, from /ssd/src/gcc/trunk/gcc/coretypes.h:480, from /ssd/src/gcc/trunk/gcc/except.c:114: /ssd/src/gcc/trunk/gcc/hash-map.h: In instantiation of ‘static void hash_map< , , >::hash_entry::pch_nx_helper(T&, gt_pointer_operator, void*) [with T = long int; KeyId = int_hash; Value = int; Traits = simple_hashmap_traits >, int>; gt_pointer_operator = void (*)(void*, void*)]’: /ssd/src/gcc/trunk/gcc/hash-map.h:93:16: required from ‘static void hash_map< , , >::hash_entry::pch_nx(hash_map< , , >::hash_entry&, gt_pointer_operator, void*) [with KeyId = int_hash; Value = int; Traits = simple_hashmap_traits >, int>; gt_pointer_operator = void (*)(void*, void*)]’ /ssd/src/gcc/trunk/gcc/hash-table.h:1181:17: required from ‘void hashtab_entry_note_pointers(void*, void*, gt_pointer_operator, void*) [with D = hash_map, int>::hash_entry; gt_pointer_operator = void (*)(void*, void*)]’ /ssd/src/gcc/trunk/gcc/hash-table.h:1190:26: required from ‘void gt_pch_nx(hash_table*) [with D = hash_map, int>::hash_entry]’ /ssd/src/gcc/trunk/gcc/hash-map.h:314:13: required from ‘void gt_pch_nx(hash_map*) [with K = int_hash; V = int; H = simple_hashmap_traits >, int>]’ ./gt-except.h:97:19: required from here /ssd/src/gcc/trunk/gcc/hash-map.h:107:14: error: no matching function for call to ‘gt_pch_nx(long int*, void (*&)(void*, void*), void*&)’ gt_pch_nx (&x, op, cookie); ~~^~~~ In file included from /ssd/src/gcc/trunk/gcc/coretypes.h:454, from /ssd/src/gcc/trunk/gcc/except.c:114: /ssd/src/gcc/trunk/gcc/wide-int.h:3335:1: note: candidate: ‘template void gt_pch_nx(generic_wide_int*)’ gt_pch_nx (generic_wide_int *) ^ /ssd/src/gcc/trunk/gcc/wide-int.h:3335:1: note: template argument deduction/substitution failed: In file included from /ssd/src/gcc/trunk/gcc/hash-table.h:595, from /ssd/src/gcc/trunk/gcc/coretypes.h:480, from /ssd/src/gcc/trunk/gcc/except.c:114: /ssd/src/gcc/trunk/gcc/hash-map.h:107:14: note: mismatched types ‘generic_wide_int’ and ‘long int’ gt_pch_nx (&x, op, cookie); ~~^~~~ In file included from /ssd/src/gcc/trunk/gcc/coretypes.h:454, from /ssd/src/gcc/trunk/gcc/except.c:114: /ssd/src/gcc/trunk/gcc/wide-int.h:3341:1: note: candidate: ‘template void gt_pch_nx(generic_wide_int*, void (*)(void*, void*), void*)’ gt_pch_nx (generic_wide_int *, void (*) (void *, void *), void *) ^ /ssd/src/gcc/trunk/gcc/wide-int.h:3341:1: note: template argument deduction/substitution failed: In file included from /ssd/src/gcc/trunk/gcc/hash-table.h:595, from /ssd/src/gcc/trunk/gcc/coretypes.h:480, from /ssd/src/gcc/trunk/gcc/except.c:114: /ssd/src/gcc/trunk/gcc/hash-map.h:107:14: note: mismatched types ‘generic_wide_int’ and ‘long int’ gt_pch_nx (&x, op,
[Bug other/100463] many errors using GTY and hash_map
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100463 --- Comment #3 from Martin Sebor --- As it turns out, the hash_map primary template is incomplete. Defining the following member fixes that error only to expose another: index 0779c930f0a..c07bd04704f 100644 --- a/gcc/hash-map.h +++ b/gcc/hash-map.h @@ -114,6 +114,11 @@ class GTY((user)) hash_map static void pch_nx_helper (unsigned int, gt_pointer_operator, void *) + { + } + +static void + pch_nx_helper (long int, gt_pointer_operator, void *) { } In file included from /ssd/src/gcc/trunk/gcc/hash-table.h:595, from /ssd/src/gcc/trunk/gcc/coretypes.h:480, from /ssd/src/gcc/trunk/gcc/except.c:114: /ssd/src/gcc/trunk/gcc/hash-map.h: In instantiation of ‘static void hash_map< , , >::hash_entry::pch_nx(hash_map< , , >::hash_entry&) [with KeyId = int_hash; Value = int; Traits = simple_hashmap_traits >, int>]’: /ssd/src/gcc/trunk/gcc/hash-table.h:1198:17: required from ‘void gt_pch_nx(hash_table*) [with D = hash_map, int>::hash_entry]’ /ssd/src/gcc/trunk/gcc/hash-map.h:319:13: required from ‘void gt_pch_nx(hash_map*) [with K = int_hash; V = int; H = simple_hashmap_traits >, int>]’ ./gt-except.h:97:19: required from here /ssd/src/gcc/trunk/gcc/hash-map.h:87:12: error: call of overloaded ‘gt_pch_nx(hash_map, int>::Key&)’ is ambiguous gt_pch_nx (e.m_key); ~~^ In file included from /ssd/src/gcc/trunk/gcc/hash-table.h:247, from /ssd/src/gcc/trunk/gcc/coretypes.h:480, from /ssd/src/gcc/trunk/gcc/except.c:114: /ssd/src/gcc/trunk/gcc/ggc.h:341:1: note: candidate: ‘void gt_pch_nx(int)’ gt_pch_nx (int) ^ /ssd/src/gcc/trunk/gcc/ggc.h:346:1: note: candidate: ‘void gt_pch_nx(unsigned int)’ gt_pch_nx (unsigned int) ^
[Bug other/100463] many errors using GTY and hash_map
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100463 --- Comment #4 from Martin Sebor --- So besides the hash_map GTY support being incomplete it also seems like ggc.h support is missing something. The following change to the header lets the whole patch below compile: diff --git a/gcc/ggc.h b/gcc/ggc.h index 65f6cb4d19d..9feeffc0f06 100644 --- a/gcc/ggc.h +++ b/gcc/ggc.h @@ -347,4 +347,9 @@ gt_pch_nx (unsigned int) { } +inline void +gt_pch_nx (long int) +{ +} + #endif So to use a hash_map from HWI to int the following appears necessary. But if I need unsigned HWI I have to repeat the whole exercise yet again. diff --git a/gcc/except.c b/gcc/except.c index a7902bbd555..a47841cf395 100644 --- a/gcc/except.c +++ b/gcc/except.c @@ -149,6 +149,21 @@ static GTY(()) int call_site_base; static GTY(()) hash_map *type_to_runtime_map; +typedef int_hash test_int_hash_t; +typedef hash_map test_int_hash_map_t; +static GTY(()) test_int_hash_map_t *test_int_hash_map; + +inline void +gt_ggc_mx (test_int_hash_t *) +{ +} + +inline void +gt_pch_nx (test_int_hash_t *) +{ +} + + static GTY(()) tree setjmp_fn; /* Describe the SjLj_Function_Context structure. */ diff --git a/gcc/ggc.h b/gcc/ggc.h index 65f6cb4d19d..9feeffc0f06 100644 --- a/gcc/ggc.h +++ b/gcc/ggc.h @@ -347,4 +347,9 @@ gt_pch_nx (unsigned int) { } +inline void +gt_pch_nx (long int) +{ +} + #endif diff --git a/gcc/hash-map.h b/gcc/hash-map.h index 0779c930f0a..c07bd04704f 100644 --- a/gcc/hash-map.h +++ b/gcc/hash-map.h @@ -114,6 +114,11 @@ class GTY((user)) hash_map static void pch_nx_helper (unsigned int, gt_pointer_operator, void *) + { + } + +static void + pch_nx_helper (long int, gt_pointer_operator, void *) { }
[Bug other/100463] many errors using GTY and hash_map
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100463 --- Comment #5 from Martin Sebor --- Created attachment 50770 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=50770&action=edit Patch to complete GTY support for hash_map. Patch to add support for GTY hash_map for all integer types.
[Bug other/100463] many errors using GTY and hash_map
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100463 --- Comment #6 from Richard Biener --- Why would you want to have a hash_map GTY(())ed at all? For PCH?!
[Bug other/100463] many errors using GTY and hash_map
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100463 Martin Sebor changed: What|Removed |Added Last reconfirmed||2021-05-21 Status|UNCONFIRMED |ASSIGNED Ever confirmed|0 |1 Assignee|unassigned at gcc dot gnu.org |msebor at gcc dot gnu.org
[Bug other/100463] many errors using GTY and hash_map
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100463 --- Comment #7 from CVS Commits --- The master branch has been updated by Martin Sebor : https://gcc.gnu.org/g:5d05e83e243931c291409d4771f31747b6c04eb0 commit r12-1096-g5d05e83e243931c291409d4771f31747b6c04eb0 Author: Martin Sebor Date: Thu May 27 13:37:43 2021 -0600 PR other/100463 - many errors using GTY and hash_map gcc/ChangeLog: * ggc.h (gt_ggc_mx): Add overloads for all integers. (gt_pch_nx): Same. * hash-map.h (class hash_map): Add pch_nx_helper overloads for all integers. (hash_map::operator==): New function.
[Bug other/100463] many errors using GTY and hash_map
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100463 Martin Sebor changed: What|Removed |Added Target Milestone|--- |12.0 Keywords||build Resolution|--- |FIXED Status|ASSIGNED|RESOLVED Known to fail||10.3.0, 11.1.0, 9.3.0 --- Comment #8 from Martin Sebor --- Fixed for GCC 12.