aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexandre Oliva <oliva@adacore.com>2022-12-29 14:32:46 -0300
committerAlexandre Oliva <oliva@gnu.org>2022-12-29 14:32:46 -0300
commit26be8b84603be48d1cf35bea3be2bb398f7964b7 (patch)
treeb909a816e129765a46ea1a4b88d0b54b3f87f90f
parentda086e472b61245dedcb2463c53f84072773d1f5 (diff)
downloadgcc-26be8b84603be48d1cf35bea3be2bb398f7964b7.zip
gcc-26be8b84603be48d1cf35bea3be2bb398f7964b7.tar.gz
gcc-26be8b84603be48d1cf35bea3be2bb398f7964b7.tar.bz2
scoped tables: insert before further lookups
Avoid hash table lookups between requesting an insert and storing the inserted value in avail_exprs_stack. Lookups before the insert is completed could fail to find double-hashed elements. for gcc/ChangeLog * tree-ssa-scopedtables.cc (avail_exprs_stack::lookup_avail_expr): Finish hash table insertion before further lookups.
-rw-r--r--gcc/tree-ssa-scopedtables.cc10
1 files changed, 5 insertions, 5 deletions
diff --git a/gcc/tree-ssa-scopedtables.cc b/gcc/tree-ssa-scopedtables.cc
index 6d203ef..3e6e129 100644
--- a/gcc/tree-ssa-scopedtables.cc
+++ b/gcc/tree-ssa-scopedtables.cc
@@ -259,11 +259,6 @@ avail_exprs_stack::lookup_avail_expr (gimple *stmt, bool insert, bool tbaa_p,
}
else if (*slot == NULL)
{
- /* If we did not find the expression in the hash table, we may still
- be able to produce a result for some expressions. */
- tree retval = avail_exprs_stack::simplify_binary_operation (stmt,
- element);
-
/* We have, in effect, allocated *SLOT for ELEMENT at this point.
We must initialize *SLOT to a real entry, even if we found a
way to prove ELEMENT was a constant after not finding ELEMENT
@@ -277,6 +272,11 @@ avail_exprs_stack::lookup_avail_expr (gimple *stmt, bool insert, bool tbaa_p,
class expr_hash_elt *element2 = new expr_hash_elt (element);
*slot = element2;
+ /* If we did not find the expression in the hash table, we may still
+ be able to produce a result for some expressions. */
+ tree retval = avail_exprs_stack::simplify_binary_operation (stmt,
+ element);
+
record_expr (element2, NULL, '2');
return retval;
}