diff options
author | Richard Biener <rguenther@suse.de> | 2013-06-17 15:08:24 +0000 |
---|---|---|
committer | Richard Biener <rguenth@gcc.gnu.org> | 2013-06-17 15:08:24 +0000 |
commit | ee03e71d472a3f73cbc1a132a284309f36565972 (patch) | |
tree | 37057cc11efb7f662edca2c35160d9fcf3e20d36 /gcc/tree-streamer.c | |
parent | a0e33cbcd8966627b6a9d88b14e4ad9efccc97b4 (diff) | |
download | gcc-ee03e71d472a3f73cbc1a132a284309f36565972.zip gcc-ee03e71d472a3f73cbc1a132a284309f36565972.tar.gz gcc-ee03e71d472a3f73cbc1a132a284309f36565972.tar.bz2 |
lto-streamer.h (enum LTO_tags): Add LTO_tree_scc.
2013-06-17 Richard Biener <rguenther@suse.de>
* lto-streamer.h (enum LTO_tags): Add LTO_tree_scc.
(lto_input_scc): Declare.
(lto_input_tree_1): Likewise.
(struct lto_stats_d): Add num_tree_bodies_output and
num_pickle_refs_output.
* lto-streamer-in.c (lto_read_body): Use streamer_tree_cache_get_tree.
(lto_read_tree_1): Split out from ...
(lto_read_tree): ... this.
(lto_input_scc): New function.
(lto_input_tree_1): Split out from ...
(lto_input_tree): ... this. Handle LTO_tree_scc.
(lto_data_in_create): Create the streamer cache without hashes.
* lto-streamer-out.c (create_output_block): Create the streamer
cache with hashes when not doing WPA.
(lto_write_tree_1): Split out from ...
(lto_write_tree): ... this.
(get_symbol_initial_value): New function.
(lto_output_tree_1): Split out from ...
(lto_output_tree): ... this. Write trees as series of SCCs
using a DFS walk via DFS_write_tree.
(struct sccs, struct scc_entry): New types.
(next_dfs_num, sccstack, sccstate, sccstate_obstack): New globals.
(DFS_write_tree_body): New function.
(DFS_write_tree): Likewise.
(hash_tree): Likewise.
(scc_entry_compare): Likewise.
(hash_scc): Likewise.
(tree_is_indexable): DEBUG_EXPR_DECLs are local entities.
* tree-streamer-in.c (lto_input_ts_list_tree_pointers): Stream
TREE_CHAIN as regular reference.
(streamer_read_integer_cst): Remove.
(streamer_get_pickled_tree): Adjust.
* tree-streamer-out.c (streamer_write_chain): Disable streaming
of DECL_EXTERNALs in BLOCK_VARS for now.
(write_ts_list_tree_pointers): Stream TREE_CHAIN as regular
reference.
* tree-streamer.c (streamer_tree_cache_add_to_node_array):
Add hash value argument and record that if hashes are recorded
in the cache.
(streamer_tree_cache_insert_1): Adjust.
(streamer_tree_cache_insert): Likewise.
(streamer_tree_cache_insert_at): Rename to ...
(streamer_tree_cache_replace_tree): ... this and adjust.
(streamer_tree_cache_append): Adjust.
(record_common_node): Likewise.
(streamer_tree_cache_create): Add argument whether to
record hash values together with trees.
(streamer_tree_cache_delete): Adjust.
* tree-streamer.h (struct streamer_tree_cache_d): Add
vector of hashes.
(streamer_read_integer_cst): Remove.
(streamer_tree_cache_insert): Adjust.
(streamer_tree_cache_append): Likewise.
(streamer_tree_cache_insert_at): Rename to ...
(streamer_tree_cache_replace_tree): ... this and adjust.
(streamer_tree_cache_create): Add argument whether to record hashes.
(streamer_tree_cache_get): Rename to ...
(streamer_tree_cache_get_tree): ... this.
(streamer_tree_cache_get_hash): New function.
* tree.c (cache_integer_cst): New function.
* tree.h (cache_integer_cst): Declare.
(ANON_AGGRNAME_FORMAT, ANON_AGGRNAME_P): Move here from cp/cp-tree.h.
* lto-symtab.c (lto_varpool_replace_node): Only release
DECL_INITIAL of non-prevailing decls.
* varpool.c (varpool_remove_initializer): Do not release
DECL_INITIAL when we are still in CGRAPH_LTO_STREAMING.
cp/
* cp-tree.h (ANON_AGGRNAME_FORMAT, ANON_AGGRNAME_P): Move to tree.h.
lto/
* Make-lang.in (lto.o): Add $(DATA_STREAMER_H) dependency.
* lto.c: Include data-streamer.h.
(lto_read_in_decl_state): Use streamer_tree_cache_get_tree.
(gimple_type_leader_entry_s, gimple_type_leader,
gimple_lookup_type_leader): Remove.
(gtc_visit): Simplify.
(gimple_types_compatible_p): Likewise.
(gimple_register_type_1): Likewise. Merge into ...
(gimple_register_type): ... this. Keep it as legacy for
statistics purposes for now.
(fixup_integer_cst): Remove.
(LTO_FIXUP_TREE, lto_fixup_types, lto_ft_*): Simplify and
rename to ...
(MAYBE_REMEMBER_WITH_VARS, maybe_remember_with_vars,
maybe_remember_with_vars_*): ... these.
(uniquify_nodes): Remove.
(lto_fixup_prevailing_type): New function.
(struct tree_scc, struct tree_scc_hasher): New type and hasher.
(tree_scc_hash, tree_scc_hash_obstack): New globals.
(num_merged_types, num_prevailing_types, num_not_merged_types,
num_not_merged_types_in_same_scc, total_scc_size, num_sccs_read,
total_scc_size_merged, num_sccs_merged, num_scc_compares,
num_scc_compare_collisions): New global counters.
(compare_tree_sccs_1): New function.
(compare_tree_sccs): Likewise.
(unify_scc): Likewise.
(lto_read_decls): Stream in tree SCCs and unify them on the
way in. Finalize prevailing SCC tree members.
(read_cgraph_and_symbols): Do not initialize or free gimple_type_leader.
Allocate and free tree_scc_hash_obstack and tree_scc_hash, do not bother
to ggc-collect during merging.
(print_lto_report_1): Adjust for new merging code.
From-SVN: r200151
Diffstat (limited to 'gcc/tree-streamer.c')
-rw-r--r-- | gcc/tree-streamer.c | 54 |
1 files changed, 36 insertions, 18 deletions
diff --git a/gcc/tree-streamer.c b/gcc/tree-streamer.c index e4d948b..fcdf432 100644 --- a/gcc/tree-streamer.c +++ b/gcc/tree-streamer.c @@ -92,16 +92,24 @@ streamer_check_handled_ts_structures (void) static void streamer_tree_cache_add_to_node_array (struct streamer_tree_cache_d *cache, - unsigned ix, tree t) + 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 ()) - cache->nodes.safe_push (t); + { + cache->nodes.safe_push (t); + if (cache->hashes.exists ()) + cache->hashes.safe_push (hash); + } else - cache->nodes[ix] = t; + { + cache->nodes[ix] = t; + if (cache->hashes.exists ()) + cache->hashes[ix] = hash; + } } @@ -117,7 +125,7 @@ streamer_tree_cache_add_to_node_array (struct streamer_tree_cache_d *cache, static bool streamer_tree_cache_insert_1 (struct streamer_tree_cache_d *cache, - tree t, unsigned *ix_p, + tree t, hashval_t hash, unsigned *ix_p, bool insert_at_next_slot_p) { void **slot; @@ -136,7 +144,7 @@ streamer_tree_cache_insert_1 (struct streamer_tree_cache_d *cache, ix = *ix_p; *slot = (void *)(size_t) (ix + 1); - streamer_tree_cache_add_to_node_array (cache, ix, t); + streamer_tree_cache_add_to_node_array (cache, ix, t, hash); /* Indicate that the item was not present in the cache. */ existed_p = false; @@ -151,7 +159,7 @@ streamer_tree_cache_insert_1 (struct streamer_tree_cache_d *cache, location, and ENTRY->TO does not match *IX_P, add T to the requested location slot. */ ix = *ix_p; - streamer_tree_cache_add_to_node_array (cache, ix, t); + streamer_tree_cache_add_to_node_array (cache, ix, t, hash); *slot = (void *)(size_t) (ix + 1); } @@ -174,30 +182,33 @@ streamer_tree_cache_insert_1 (struct streamer_tree_cache_d *cache, bool streamer_tree_cache_insert (struct streamer_tree_cache_d *cache, tree t, - unsigned *ix_p) + hashval_t hash, unsigned *ix_p) { - return streamer_tree_cache_insert_1 (cache, t, ix_p, true); + return streamer_tree_cache_insert_1 (cache, t, hash, ix_p, true); } -/* Insert tree node T in CACHE at slot IX. If T already - existed in the cache return true. Otherwise, return false. */ +/* Replace the tree node with T in CACHE at slot IX. */ -bool -streamer_tree_cache_insert_at (struct streamer_tree_cache_d *cache, - tree t, unsigned ix) +void +streamer_tree_cache_replace_tree (struct streamer_tree_cache_d *cache, + tree t, unsigned ix) { - return streamer_tree_cache_insert_1 (cache, t, &ix, false); + hashval_t hash = 0; + if (cache->hashes.exists ()) + hash = streamer_tree_cache_get_hash (cache, ix); + streamer_tree_cache_insert_1 (cache, t, hash, &ix, false); } /* Appends tree node T to CACHE, even if T already existed in it. */ void -streamer_tree_cache_append (struct streamer_tree_cache_d *cache, tree t) +streamer_tree_cache_append (struct streamer_tree_cache_d *cache, + tree t, hashval_t hash) { unsigned ix = cache->nodes.length (); - streamer_tree_cache_insert_1 (cache, t, &ix, false); + streamer_tree_cache_insert_1 (cache, t, hash, &ix, false); } /* Return true if tree node T exists in CACHE, otherwise false. If IX_P is @@ -257,7 +268,10 @@ record_common_node (struct streamer_tree_cache_d *cache, tree node) if (!node) node = error_mark_node; - streamer_tree_cache_append (cache, node); + /* ??? FIXME, devise a better hash value. But the hash needs to be equal + for all frontend and lto1 invocations. So just use the position + in the cache as hash value. */ + streamer_tree_cache_append (cache, node, cache->nodes.length ()); if (POINTER_TYPE_P (node) || TREE_CODE (node) == COMPLEX_TYPE @@ -305,13 +319,16 @@ preload_common_nodes (struct streamer_tree_cache_d *cache) /* Create a cache of pickled nodes. */ struct streamer_tree_cache_d * -streamer_tree_cache_create (void) +streamer_tree_cache_create (bool with_hashes) { struct streamer_tree_cache_d *cache; cache = XCNEW (struct streamer_tree_cache_d); cache->node_map = pointer_map_create (); + cache->nodes.create (165); + if (with_hashes) + cache->hashes.create (165); /* Load all the well-known tree nodes that are always created by the compiler on startup. This prevents writing them out @@ -332,5 +349,6 @@ streamer_tree_cache_delete (struct streamer_tree_cache_d *c) pointer_map_destroy (c->node_map); c->nodes.release (); + c->hashes.release (); free (c); } |