aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree.h
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2020-09-03 21:53:40 +0200
committerJakub Jelinek <jakub@redhat.com>2020-09-03 21:53:40 +0200
commitba6730bd18371a3dff1e37d2c2ee27233285b597 (patch)
tree985096f9cfe0601047e7c8ed4578069d8e1ecda5 /gcc/tree.h
parent8eeeecbcc17041fdfd3ccc928161ae86e7f9b456 (diff)
downloadgcc-ba6730bd18371a3dff1e37d2c2ee27233285b597.zip
gcc-ba6730bd18371a3dff1e37d2c2ee27233285b597.tar.gz
gcc-ba6730bd18371a3dff1e37d2c2ee27233285b597.tar.bz2
c++: Fix another PCH hash_map issue [PR96901]
The recent libstdc++ changes caused lots of libstdc++-v3 tests FAILs on i686-linux, all of them in the same spot during constexpr evaluation of a recursive _S_gcd call. The problem is yet another hash_map that used the default hasing of tree keys through pointer hashing which is preserved across PCH write/read. During PCH handling, the addresses of GC objects are changed, which means that the hash values of the keys in such hash tables change without those hash tables being rehashed. Which in the fundef_copies_table case usually means we just don't find a copy of a FUNCTION_DECL body for recursive uses and start from scratch. But when the hash table keeps growing, the "dead" elements in the hash table can sometimes reappear and break things. In particular what I saw under the debugger is when the fundef_copies_table hash map has been used on the outer _S_gcd call, it didn't find an entry for it, so returned a slot with *slot == NULL, which is treated as that the function itself is used directly (i.e. no recursion), but that addition of a hash table slot caused the recursive _S_gcd call to actually find something in the hash table, unfortunately not the new *slot == NULL spot, but a different one from the pre-PCH streaming which contained the returned toplevel (non-recursive) call entry for it, which means that for the recursive _S_gcd call we actually used the same trees as for the outer ones rather than a copy of those, which breaks constexpr evaluation. 2020-09-03 Jakub Jelinek <jakub@redhat.com> PR c++/96901 * tree.h (struct decl_tree_traits): New type. (decl_tree_map): New typedef. * constexpr.c (fundef_copies_table): Change type from hash_map<tree, tree> * to decl_tree_map *.
Diffstat (limited to 'gcc/tree.h')
-rw-r--r--gcc/tree.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/gcc/tree.h b/gcc/tree.h
index b0ef14b..9ec24a3 100644
--- a/gcc/tree.h
+++ b/gcc/tree.h
@@ -5453,6 +5453,11 @@ struct type_tree_cache_traits
: simple_cache_map_traits<tree_type_hash, tree> { };
typedef hash_map<tree,tree,type_tree_cache_traits> type_tree_cache_map;
+/* Similarly to decl_tree_cache_map, but without caching. */
+struct decl_tree_traits
+ : simple_hashmap_traits<tree_decl_hash, tree> { };
+typedef hash_map<tree,tree,decl_tree_traits> decl_tree_map;
+
/* Initialize the abstract argument list iterator object ITER with the
arguments from CALL_EXPR node EXP. */
static inline void