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.
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;
}
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);
??? 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
streamer_write_zero (ob);
}
}
- gcc_assert (old_len + size == ob->writer_cache->nodes.length ());
/* Finally truncate the vector. */
sccstack.truncate (first);
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 =
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;
}
}
{
/* 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;
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
/* 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;
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);
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
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. */