aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2010-04-28 19:01:00 +0000
committerEric Botcazou <ebotcazou@gcc.gnu.org>2010-04-28 19:01:00 +0000
commit331c7fcdd09ca68e53bd5e64cd4b1cdc04416aa2 (patch)
tree731d3ebc836e47abbec16c06098076ee6a609f8e /gcc
parent34f97b9407c6a39f133b3446e8c788d19a9f9e34 (diff)
downloadgcc-331c7fcdd09ca68e53bd5e64cd4b1cdc04416aa2.zip
gcc-331c7fcdd09ca68e53bd5e64cd4b1cdc04416aa2.tar.gz
gcc-331c7fcdd09ca68e53bd5e64cd4b1cdc04416aa2.tar.bz2
lto-streamer.c [...] (tree_htab, [...]): New tree hash table.
* lto-streamer.c [LTO_STREAMER_DEBUG] (tree_htab, tree_hash_entry, hash_tree, eq_tree): New tree hash table. (lto_streamer_init) [LTO_STREAMER_DEBUG]: Initialize it. [LTO_STREAMER_DEBUG] (lto_orig_address_map, lto_orig_address_get, lto_orig_address_remove): Reimplement. From-SVN: r158836
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog8
-rw-r--r--gcc/lto-streamer.c61
2 files changed, 63 insertions, 6 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index c84d857..0dbca97 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,11 @@
+2010-04-28 Eric Botcazou <ebotcazou@adacore.com>
+
+ * lto-streamer.c [LTO_STREAMER_DEBUG] (tree_htab, tree_hash_entry,
+ hash_tree, eq_tree): New tree hash table.
+ (lto_streamer_init) [LTO_STREAMER_DEBUG]: Initialize it.
+ [LTO_STREAMER_DEBUG] (lto_orig_address_map, lto_orig_address_get,
+ lto_orig_address_remove): Reimplement.
+
2010-04-28 Xinliang David Li <davidxl@google.com>
PR c/42643
diff --git a/gcc/lto-streamer.c b/gcc/lto-streamer.c
index 46d6154..84baeac 100644
--- a/gcc/lto-streamer.c
+++ b/gcc/lto-streamer.c
@@ -785,6 +785,31 @@ lto_streamer_cache_delete (struct lto_streamer_cache_d *c)
}
+#ifdef LTO_STREAMER_DEBUG
+static htab_t tree_htab;
+
+struct tree_hash_entry
+{
+ tree key;
+ intptr_t value;
+};
+
+static hashval_t
+hash_tree (const void *p)
+{
+ const struct tree_hash_entry *e = (const struct tree_hash_entry *) p;
+ return htab_hash_pointer (e->key);
+}
+
+static int
+eq_tree (const void *p1, const void *p2)
+{
+ const struct tree_hash_entry *e1 = (const struct tree_hash_entry *) p1;
+ const struct tree_hash_entry *e2 = (const struct tree_hash_entry *) p2;
+ return (e1->key == e2->key);
+}
+#endif
+
/* Initialization common to the LTO reader and writer. */
void
@@ -795,6 +820,10 @@ lto_streamer_init (void)
new TS_* astructure is added, the streamer should be updated to
handle it. */
check_handled_ts_structures ();
+
+#ifdef LTO_STREAMER_DEBUG
+ tree_htab = htab_create (31, hash_tree, eq_tree, NULL);
+#endif
}
@@ -823,10 +852,16 @@ gate_lto_out (void)
void
lto_orig_address_map (tree t, intptr_t orig_t)
{
- /* FIXME lto. Using the annotation field is quite hacky as it relies
- on the GC not running while T is being rematerialized. It would
- be cleaner to use a hash table here. */
- t->base.ann = (union tree_ann_d *) orig_t;
+ struct tree_hash_entry ent;
+ struct tree_hash_entry **slot;
+
+ ent.key = t;
+ ent.value = orig_t;
+ slot
+ = (struct tree_hash_entry **) htab_find_slot (tree_htab, &ent, INSERT);
+ gcc_assert (!*slot);
+ *slot = XNEW (struct tree_hash_entry);
+ **slot = ent;
}
@@ -836,7 +871,13 @@ lto_orig_address_map (tree t, intptr_t orig_t)
intptr_t
lto_orig_address_get (tree t)
{
- return (intptr_t) t->base.ann;
+ struct tree_hash_entry ent;
+ struct tree_hash_entry **slot;
+
+ ent.key = t;
+ slot
+ = (struct tree_hash_entry **) htab_find_slot (tree_htab, &ent, NO_INSERT);
+ return (slot ? (*slot)->value : 0);
}
@@ -845,7 +886,15 @@ lto_orig_address_get (tree t)
void
lto_orig_address_remove (tree t)
{
- t->base.ann = NULL;
+ struct tree_hash_entry ent;
+ struct tree_hash_entry **slot;
+
+ ent.key = t;
+ slot
+ = (struct tree_hash_entry **) htab_find_slot (tree_htab, &ent, NO_INSERT);
+ gcc_assert (slot);
+ free (*slot);
+ htab_clear_slot (tree_htab, (PTR *)slot);
}
#endif