aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/ChangeLog19
-rw-r--r--gcc/lto-streamer-in.c3
-rw-r--r--gcc/lto-streamer-out.c16
-rw-r--r--gcc/tree-streamer.c31
-rw-r--r--gcc/tree-streamer.h5
5 files changed, 51 insertions, 23 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 99ab7b4..8d0c021 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,24 @@
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.
+
+2014-04-03 Richard Biener <rguenther@suse.de>
+
* tree-streamer-out.c (streamer_write_chain): Do not temporarily
set TREE_CHAIN to NULL_TREE.
diff --git a/gcc/lto-streamer-in.c b/gcc/lto-streamer-in.c
index 3238ab8..e19b115 100644
--- a/gcc/lto-streamer-in.c
+++ b/gcc/lto-streamer-in.c
@@ -1365,8 +1365,7 @@ lto_data_in_create (struct lto_file_decl_data *file_data, const char *strings,
data_in->strings = strings;
data_in->strings_len = len;
data_in->globals_resolution = resolutions;
- data_in->reader_cache = streamer_tree_cache_create (false, false);
-
+ data_in->reader_cache = streamer_tree_cache_create (false, false, true);
return data_in;
}
diff --git a/gcc/lto-streamer-out.c b/gcc/lto-streamer-out.c
index 0f37f1c..69b5a79 100644
--- a/gcc/lto-streamer-out.c
+++ b/gcc/lto-streamer-out.c
@@ -79,7 +79,7 @@ create_output_block (enum lto_section_type section_type)
ob->decl_state = lto_get_out_decl_state ();
ob->main_stream = XCNEW (struct lto_output_stream);
ob->string_stream = XCNEW (struct lto_output_stream);
- ob->writer_cache = streamer_tree_cache_create (!flag_wpa, true);
+ ob->writer_cache = streamer_tree_cache_create (!flag_wpa, true, false);
if (section_type == LTO_section_function_body)
ob->cfg_stream = XCNEW (struct lto_output_stream);
@@ -1277,7 +1277,6 @@ DFS_write_tree (struct output_block *ob, sccs *from_state,
??? We still wrap these in LTO_tree_scc so at the
input side we can properly identify the tree we want
to ultimatively return. */
- size_t old_len = ob->writer_cache->nodes.length ();
if (size == 1)
lto_output_tree_1 (ob, expr, scc_hash, ref_p, this_ref_p);
else
@@ -1315,7 +1314,6 @@ DFS_write_tree (struct output_block *ob, sccs *from_state,
streamer_write_zero (ob);
}
}
- gcc_assert (old_len + size == ob->writer_cache->nodes.length ());
/* Finally truncate the vector. */
sccstack.truncate (first);
@@ -2423,10 +2421,18 @@ produce_asm_for_decls (void)
gcc_assert (!alias_pairs);
- /* Write the global symbols. */
+ /* Get rid of the global decl state hash tables to save some memory. */
out_state = lto_get_out_decl_state ();
- num_fns = lto_function_decl_states.length ();
+ for (int i = 0; i < LTO_N_DECL_STREAMS; i++)
+ if (out_state->streams[i].tree_hash_table)
+ {
+ delete out_state->streams[i].tree_hash_table;
+ out_state->streams[i].tree_hash_table = NULL;
+ }
+
+ /* Write the global symbols. */
lto_output_decl_state_streams (ob, out_state);
+ num_fns = lto_function_decl_states.length ();
for (idx = 0; idx < num_fns; idx++)
{
fn_out_state =
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);
diff --git a/gcc/tree-streamer.h b/gcc/tree-streamer.h
index 2aca29a..20dbba0 100644
--- a/gcc/tree-streamer.h
+++ b/gcc/tree-streamer.h
@@ -52,6 +52,9 @@ struct streamer_tree_cache_d
vec<tree> nodes;
/* The node hashes (if available). */
vec<hashval_t> hashes;
+
+ /* Next index to assign. */
+ unsigned next_idx;
};
/* Return true if tree node EXPR should be streamed as a builtin. For
@@ -97,7 +100,7 @@ void streamer_tree_cache_append (struct streamer_tree_cache_d *, tree,
hashval_t);
bool streamer_tree_cache_lookup (struct streamer_tree_cache_d *, tree,
unsigned *);
-struct streamer_tree_cache_d *streamer_tree_cache_create (bool, bool);
+struct streamer_tree_cache_d *streamer_tree_cache_create (bool, bool, bool);
void streamer_tree_cache_delete (struct streamer_tree_cache_d *);
/* Return the tree node at slot IX in CACHE. */