aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/gcc-interface
diff options
context:
space:
mode:
authorAlexandre Oliva <aoliva@redhat.com>2011-09-19 12:32:02 +0000
committerAlexandre Oliva <aoliva@gcc.gnu.org>2011-09-19 12:32:02 +0000
commit0e871c15e0beddce2226f3bf8fb96f2fb214b28e (patch)
tree99cb6bf3fbc52e9fc6f48689942e35dabe8c77dc /gcc/ada/gcc-interface
parent12bfa8bd29310b40e114f4965d9139e1015ae1df (diff)
downloadgcc-0e871c15e0beddce2226f3bf8fb96f2fb214b28e.zip
gcc-0e871c15e0beddce2226f3bf8fb96f2fb214b28e.tar.gz
gcc-0e871c15e0beddce2226f3bf8fb96f2fb214b28e.tar.bz2
decl.c (annotate_value): Look up expression for insertion in the cache at the end.
* gcc-interface/decl.c (annotate_value): Look up expression for insertion in the cache at the end. From-SVN: r178970
Diffstat (limited to 'gcc/ada/gcc-interface')
-rw-r--r--gcc/ada/gcc-interface/decl.c26
1 files changed, 19 insertions, 7 deletions
diff --git a/gcc/ada/gcc-interface/decl.c b/gcc/ada/gcc-interface/decl.c
index 0854d5d..a6bfd37 100644
--- a/gcc/ada/gcc-interface/decl.c
+++ b/gcc/ada/gcc-interface/decl.c
@@ -7471,23 +7471,26 @@ annotate_value (tree gnu_size)
{
TCode tcode;
Node_Ref_Or_Val ops[3], ret;
- struct tree_int_map **h = NULL;
+ struct tree_int_map in;
int i;
/* See if we've already saved the value for this node. */
if (EXPR_P (gnu_size))
{
- struct tree_int_map in;
+ struct tree_int_map *e;
+
if (!annotate_value_cache)
annotate_value_cache = htab_create_ggc (512, tree_int_map_hash,
tree_int_map_eq, 0);
in.base.from = gnu_size;
- h = (struct tree_int_map **)
- htab_find_slot (annotate_value_cache, &in, INSERT);
+ e = (struct tree_int_map *)
+ htab_find (annotate_value_cache, &in);
- if (*h)
- return (Node_Ref_Or_Val) (*h)->to;
+ if (e)
+ return (Node_Ref_Or_Val) e->to;
}
+ else
+ in.base.from = NULL_TREE;
/* If we do not return inside this switch, TCODE will be set to the
code to use for a Create_Node operand and LEN (set above) will be
@@ -7588,8 +7591,17 @@ annotate_value (tree gnu_size)
ret = Create_Node (tcode, ops[0], ops[1], ops[2]);
/* Save the result in the cache. */
- if (h)
+ if (in.base.from)
{
+ struct tree_int_map **h;
+ /* We can't assume the hash table data hasn't moved since the
+ initial look up, so we have to search again. Allocating and
+ inserting an entry at that point would be an alternative, but
+ then we'd better discard the entry if we decided not to cache
+ it. */
+ h = (struct tree_int_map **)
+ htab_find_slot (annotate_value_cache, &in, INSERT);
+ gcc_assert (!*h);
*h = ggc_alloc_tree_int_map ();
(*h)->base.from = gnu_size;
(*h)->to = ret;