aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-streamer.c
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2014-04-03 14:27:02 +0000
committerRichard Biener <rguenth@gcc.gnu.org>2014-04-03 14:27:02 +0000
commitbdc67fd6a4576a1867bb0af8cd47aa819da6e2b3 (patch)
tree4b026a1f81d4c8c69be6f59244a2cbe97a3763e6 /gcc/tree-streamer.c
parenta0daf6598ad37ed021d6bc5d4bcbdd0a068b6719 (diff)
downloadgcc-bdc67fd6a4576a1867bb0af8cd47aa819da6e2b3.zip
gcc-bdc67fd6a4576a1867bb0af8cd47aa819da6e2b3.tar.gz
gcc-bdc67fd6a4576a1867bb0af8cd47aa819da6e2b3.tar.bz2
tree-streamer.h (struct streamer_tree_cache_d): Add next_idx member.
2014-04-03 Richard Biener <rguenther@suse.de> * tree-streamer.h (struct streamer_tree_cache_d): Add next_idx member. (streamer_tree_cache_create): Adjust. * tree-streamer.c (streamer_tree_cache_add_to_node_array): Adjust to allow optional nodes array. (streamer_tree_cache_insert_1): Use next_idx to assign idx. (streamer_tree_cache_append): Likewise. (streamer_tree_cache_create): Create nodes array optionally as specified by parameter. * lto-streamer-out.c (create_output_block): Avoid maintaining the node array in the writer cache. (DFS_write_tree): Remove assertion. (produce_asm_for_decls): Free the out decl state hash table early. * lto-streamer-in.c (lto_data_in_create): Adjust for streamer_tree_cache_create prototype change. From-SVN: r209059
Diffstat (limited to 'gcc/tree-streamer.c')
-rw-r--r--gcc/tree-streamer.c31
1 files changed, 16 insertions, 15 deletions
diff --git a/gcc/tree-streamer.c b/gcc/tree-streamer.c
index af9461e..517bf77 100644
--- a/gcc/tree-streamer.c
+++ b/gcc/tree-streamer.c
@@ -101,20 +101,19 @@ static void
streamer_tree_cache_add_to_node_array (struct streamer_tree_cache_d *cache,
unsigned ix, tree t, hashval_t hash)
{
- /* Make sure we're either replacing an old element or
- appending consecutively. */
- gcc_assert (ix <= cache->nodes.length ());
-
- if (ix == cache->nodes.length ())
+ /* We're either replacing an old element or appending consecutively. */
+ if (cache->nodes.exists ())
{
- cache->nodes.safe_push (t);
- if (cache->hashes.exists ())
- cache->hashes.safe_push (hash);
+ if (cache->nodes.length () == ix)
+ cache->nodes.safe_push (t);
+ else
+ cache->nodes[ix] = t;
}
- else
+ if (cache->hashes.exists ())
{
- cache->nodes[ix] = t;
- if (cache->hashes.exists ())
+ if (cache->hashes.length () == ix)
+ cache->hashes.safe_push (hash);
+ else
cache->hashes[ix] = hash;
}
}
@@ -146,7 +145,7 @@ streamer_tree_cache_insert_1 (struct streamer_tree_cache_d *cache,
{
/* Determine the next slot to use in the cache. */
if (insert_at_next_slot_p)
- ix = cache->nodes.length ();
+ ix = cache->next_idx++;
else
ix = *ix_p;
*slot = ix;
@@ -211,7 +210,7 @@ void
streamer_tree_cache_append (struct streamer_tree_cache_d *cache,
tree t, hashval_t hash)
{
- unsigned ix = cache->nodes.length ();
+ unsigned ix = cache->next_idx++;
if (!cache->node_map)
streamer_tree_cache_add_to_node_array (cache, ix, t, hash);
else
@@ -326,7 +325,7 @@ preload_common_nodes (struct streamer_tree_cache_d *cache)
/* Create a cache of pickled nodes. */
struct streamer_tree_cache_d *
-streamer_tree_cache_create (bool with_hashes, bool with_map)
+streamer_tree_cache_create (bool with_hashes, bool with_map, bool with_vec)
{
struct streamer_tree_cache_d *cache;
@@ -334,7 +333,9 @@ streamer_tree_cache_create (bool with_hashes, bool with_map)
if (with_map)
cache->node_map = new pointer_map<unsigned>;
- cache->nodes.create (165);
+ cache->next_idx = 0;
+ if (with_vec)
+ cache->nodes.create (165);
if (with_hashes)
cache->hashes.create (165);