Commit bdc67fd6 by Richard Biener Committed by Richard Biener

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
parent a0daf659
2014-04-03 Richard Biener <rguenther@suse.de> 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 * tree-streamer-out.c (streamer_write_chain): Do not temporarily
set TREE_CHAIN to NULL_TREE. set TREE_CHAIN to NULL_TREE.
......
...@@ -1365,8 +1365,7 @@ lto_data_in_create (struct lto_file_decl_data *file_data, const char *strings, ...@@ -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 = strings;
data_in->strings_len = len; data_in->strings_len = len;
data_in->globals_resolution = resolutions; 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; return data_in;
} }
......
...@@ -79,7 +79,7 @@ create_output_block (enum lto_section_type section_type) ...@@ -79,7 +79,7 @@ create_output_block (enum lto_section_type section_type)
ob->decl_state = lto_get_out_decl_state (); ob->decl_state = lto_get_out_decl_state ();
ob->main_stream = XCNEW (struct lto_output_stream); ob->main_stream = XCNEW (struct lto_output_stream);
ob->string_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) if (section_type == LTO_section_function_body)
ob->cfg_stream = XCNEW (struct lto_output_stream); ob->cfg_stream = XCNEW (struct lto_output_stream);
...@@ -1277,7 +1277,6 @@ DFS_write_tree (struct output_block *ob, sccs *from_state, ...@@ -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 ??? We still wrap these in LTO_tree_scc so at the
input side we can properly identify the tree we want input side we can properly identify the tree we want
to ultimatively return. */ to ultimatively return. */
size_t old_len = ob->writer_cache->nodes.length ();
if (size == 1) if (size == 1)
lto_output_tree_1 (ob, expr, scc_hash, ref_p, this_ref_p); lto_output_tree_1 (ob, expr, scc_hash, ref_p, this_ref_p);
else else
...@@ -1315,7 +1314,6 @@ DFS_write_tree (struct output_block *ob, sccs *from_state, ...@@ -1315,7 +1314,6 @@ DFS_write_tree (struct output_block *ob, sccs *from_state,
streamer_write_zero (ob); streamer_write_zero (ob);
} }
} }
gcc_assert (old_len + size == ob->writer_cache->nodes.length ());
/* Finally truncate the vector. */ /* Finally truncate the vector. */
sccstack.truncate (first); sccstack.truncate (first);
...@@ -2423,10 +2421,18 @@ produce_asm_for_decls (void) ...@@ -2423,10 +2421,18 @@ produce_asm_for_decls (void)
gcc_assert (!alias_pairs); 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 (); 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); lto_output_decl_state_streams (ob, out_state);
num_fns = lto_function_decl_states.length ();
for (idx = 0; idx < num_fns; idx++) for (idx = 0; idx < num_fns; idx++)
{ {
fn_out_state = fn_out_state =
......
...@@ -101,20 +101,19 @@ static void ...@@ -101,20 +101,19 @@ static void
streamer_tree_cache_add_to_node_array (struct streamer_tree_cache_d *cache, streamer_tree_cache_add_to_node_array (struct streamer_tree_cache_d *cache,
unsigned ix, tree t, hashval_t hash) unsigned ix, tree t, hashval_t hash)
{ {
/* Make sure we're either replacing an old element or /* We're either replacing an old element or appending consecutively. */
appending consecutively. */ if (cache->nodes.exists ())
gcc_assert (ix <= cache->nodes.length ());
if (ix == cache->nodes.length ())
{ {
cache->nodes.safe_push (t); if (cache->nodes.length () == ix)
if (cache->hashes.exists ()) cache->nodes.safe_push (t);
cache->hashes.safe_push (hash); else
cache->nodes[ix] = t;
} }
else if (cache->hashes.exists ())
{ {
cache->nodes[ix] = t; if (cache->hashes.length () == ix)
if (cache->hashes.exists ()) cache->hashes.safe_push (hash);
else
cache->hashes[ix] = hash; cache->hashes[ix] = hash;
} }
} }
...@@ -146,7 +145,7 @@ streamer_tree_cache_insert_1 (struct streamer_tree_cache_d *cache, ...@@ -146,7 +145,7 @@ streamer_tree_cache_insert_1 (struct streamer_tree_cache_d *cache,
{ {
/* Determine the next slot to use in the cache. */ /* Determine the next slot to use in the cache. */
if (insert_at_next_slot_p) if (insert_at_next_slot_p)
ix = cache->nodes.length (); ix = cache->next_idx++;
else else
ix = *ix_p; ix = *ix_p;
*slot = ix; *slot = ix;
...@@ -211,7 +210,7 @@ void ...@@ -211,7 +210,7 @@ void
streamer_tree_cache_append (struct streamer_tree_cache_d *cache, streamer_tree_cache_append (struct streamer_tree_cache_d *cache,
tree t, hashval_t hash) tree t, hashval_t hash)
{ {
unsigned ix = cache->nodes.length (); unsigned ix = cache->next_idx++;
if (!cache->node_map) if (!cache->node_map)
streamer_tree_cache_add_to_node_array (cache, ix, t, hash); streamer_tree_cache_add_to_node_array (cache, ix, t, hash);
else else
...@@ -326,7 +325,7 @@ preload_common_nodes (struct streamer_tree_cache_d *cache) ...@@ -326,7 +325,7 @@ preload_common_nodes (struct streamer_tree_cache_d *cache)
/* Create a cache of pickled nodes. */ /* Create a cache of pickled nodes. */
struct streamer_tree_cache_d * 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; struct streamer_tree_cache_d *cache;
...@@ -334,7 +333,9 @@ streamer_tree_cache_create (bool with_hashes, bool with_map) ...@@ -334,7 +333,9 @@ streamer_tree_cache_create (bool with_hashes, bool with_map)
if (with_map) if (with_map)
cache->node_map = new pointer_map<unsigned>; 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) if (with_hashes)
cache->hashes.create (165); cache->hashes.create (165);
......
...@@ -52,6 +52,9 @@ struct streamer_tree_cache_d ...@@ -52,6 +52,9 @@ struct streamer_tree_cache_d
vec<tree> nodes; vec<tree> nodes;
/* The node hashes (if available). */ /* The node hashes (if available). */
vec<hashval_t> hashes; vec<hashval_t> hashes;
/* Next index to assign. */
unsigned next_idx;
}; };
/* Return true if tree node EXPR should be streamed as a builtin. For /* 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, ...@@ -97,7 +100,7 @@ void streamer_tree_cache_append (struct streamer_tree_cache_d *, tree,
hashval_t); hashval_t);
bool streamer_tree_cache_lookup (struct streamer_tree_cache_d *, tree, bool streamer_tree_cache_lookup (struct streamer_tree_cache_d *, tree,
unsigned *); 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 *); void streamer_tree_cache_delete (struct streamer_tree_cache_d *);
/* Return the tree node at slot IX in CACHE. */ /* Return the tree node at slot IX in CACHE. */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment