From: Richard Biener Date: Thu, 3 Apr 2014 14:27:02 +0000 (+0000) Subject: tree-streamer.h (struct streamer_tree_cache_d): Add next_idx member. X-Git-Tag: basepoints/gcc-5~90 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bdc67fd6a4576a1867bb0af8cd47aa819da6e2b3;p=thirdparty%2Fgcc.git tree-streamer.h (struct streamer_tree_cache_d): Add next_idx member. 2014-04-03 Richard Biener * 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 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 99ab7b45441c..8d0c02162eda 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,22 @@ +2014-04-03 Richard Biener + + * 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 * tree-streamer-out.c (streamer_write_chain): Do not temporarily diff --git a/gcc/lto-streamer-in.c b/gcc/lto-streamer-in.c index 3238ab8109cf..e19b11558d9d 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 0f37f1c24228..69b5a79e5395 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 af9461e77106..517bf77f66ba 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; - 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 2aca29a12b96..20dbba024f00 100644 --- a/gcc/tree-streamer.h +++ b/gcc/tree-streamer.h @@ -52,6 +52,9 @@ struct streamer_tree_cache_d vec nodes; /* The node hashes (if available). */ vec 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. */