aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/decl.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/ada/decl.c')
-rw-r--r--gcc/ada/decl.c33
1 files changed, 30 insertions, 3 deletions
diff --git a/gcc/ada/decl.c b/gcc/ada/decl.c
index a7ee5ce..af0e392 100644
--- a/gcc/ada/decl.c
+++ b/gcc/ada/decl.c
@@ -50,6 +50,7 @@
#include "fe.h"
#include "sinfo.h"
#include "einfo.h"
+#include "hashtab.h"
#include "ada-tree.h"
#include "gigi.h"
@@ -80,6 +81,10 @@ static struct incomplete
static int defer_debug_level = 0;
static tree defer_debug_incomplete_list;
+/* A hash table used as to cache the result of annotate_value. */
+static GTY ((if_marked ("tree_int_map_marked_p"), param_is (struct tree_int_map)))
+ htab_t annotate_value_cache;
+
static void copy_alias_set (tree, tree);
static tree substitution_list (Entity_Id, Entity_Id, tree, bool);
static bool allocatable_size_p (tree, bool);
@@ -5876,10 +5881,22 @@ annotate_value (tree gnu_size)
Node_Ref_Or_Val ops[3], ret;
int i;
int size;
+ struct tree_int_map **h = NULL;
/* See if we've already saved the value for this node. */
- if (EXPR_P (gnu_size) && TREE_COMPLEXITY (gnu_size))
- return (Node_Ref_Or_Val) TREE_COMPLEXITY (gnu_size);
+ if (EXPR_P (gnu_size))
+ {
+ struct tree_int_map in;
+ if (!annotate_value_cache)
+ annotate_value_cache = htab_create_ggc (512, tree_int_map_hash,
+ tree_int_map_eq, 0);
+ in.from = gnu_size;
+ h = (struct tree_int_map **)
+ htab_find_slot (annotate_value_cache, &in, INSERT);
+
+ if (*h)
+ return (Node_Ref_Or_Val) (*h)->to;
+ }
/* 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
@@ -5994,7 +6011,15 @@ annotate_value (tree gnu_size)
}
ret = Create_Node (tcode, ops[0], ops[1], ops[2]);
- TREE_COMPLEXITY (gnu_size) = ret;
+
+ /* Save the result in the cache. */
+ if (h)
+ {
+ *h = ggc_alloc (sizeof (struct tree_int_map));
+ (*h)->from = gnu_size;
+ (*h)->to = ret;
+ }
+
return ret;
}
@@ -6847,3 +6872,5 @@ concat_id_with_name (tree gnu_id, const char *suffix)
strcpy (Name_Buffer + len, suffix);
return get_identifier (Name_Buffer);
}
+
+#include "gt-ada-decl.h"