diff options
author | matz <matz@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-04-03 11:21:06 +0000 |
---|---|---|
committer | matz <matz@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-04-03 11:21:06 +0000 |
commit | 5cd33168f40b65c96dfa1769c689ba65000f1c1d (patch) | |
tree | 1e63a8bdd37fbff2c65aec3206ef1005c2481cd1 /gcc/lto-streamer.c | |
parent | a464988454e792146712dbdfd91047c94dcc5cca (diff) | |
download | gcc-5cd33168f40b65c96dfa1769c689ba65000f1c1d.tar.gz |
* lto-streamer.h (struct lto_streamer_cache_d): Remove offsets
and next_slot members.
(lto_streamer_cache_insert, lto_streamer_cache_insert_at,
lto_streamer_cache_lookup, lto_streamer_cache_get): Adjust prototypes.
(lto_streamer_cache_append): Declare.
* lto-streamer.c (lto_streamer_cache_add_to_node_array): Use
unsigned index, remove offset parameter, ensure that we append
or update existing entries.
(lto_streamer_cache_insert_1): Use unsigned index, remove offset_p
parameter, update next_slot for append.
(lto_streamer_cache_insert): Use unsigned index, remove offset_p
parameter.
(lto_streamer_cache_insert_at): Likewise.
(lto_streamer_cache_append): New function.
(lto_streamer_cache_lookup): Use unsigned index.
(lto_streamer_cache_get): Likewise.
(lto_record_common_node): Don't test tree_node_can_be_shared.
(preload_common_node): Adjust call to lto_streamer_cache_insert.
(lto_streamer_cache_delete): Don't free offsets member.
* lto-streamer-out.c (eq_string_slot_node): Use memcmp.
(lto_output_string_with_length): Use lto_output_data_stream.
(lto_output_tree_header): Remove ix parameter, don't write it.
(lto_output_builtin_tree): Likewise.
(lto_write_tree): Adjust callers to above, don't track and write
offset, write unsigned index.
(output_unreferenced_globals): Don't emit all global vars.
(write_global_references): Use unsigned indices.
(lto_output_decl_state_refs): Likewise.
(write_symbol): Likewise.
* lto-streamer-in.c (lto_input_chain): Move earlier.
(input_function): Use unsigned index.
(input_alias_pairs): Don't read and then ignore all global vars.
(lto_materialize_tree): Remove ix_p parameter, don't read index,
don't pass it back, use lto_streamer_cache_append.
(lto_register_var_decl_in_symtab): Use unsigned index.
(lto_register_function_decl_in_symtab): Likewise.
(lto_get_pickled_tree): Don't read in or handle offset, read unsigned
index.
(lto_get_builtin_tree): Don't read index, use
lto_streamer_cache_append.
(lto_read_tree): Adjust call to lto_materialize_tree.
* ipa-inline.c (cgraph_edge_badness): Move growth calculaton,
don't use function calls in arguments to MIN.
* varasm.c (decl_binds_to_current_def_p): Don't check TREE_PUBLIC
twice.
* gimple.c (gimple_type_leader_entry): Mark deletable.
lto/
* lto.c (lto_materialize_function): Don't read and then discard
sections in WPA mode.
(lto_read_in_decl_state): Adjust call to lto_streamer_cache_get.
* lto-lang.c (registered_builtin_fndecls): Remove.
(lto_getdecls): Return NULL_TREE.
(lto_builtin_function): Don't remember in registered_builtin_fndecls.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@171906 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/lto-streamer.c')
-rw-r--r-- | gcc/lto-streamer.c | 111 |
1 files changed, 45 insertions, 66 deletions
diff --git a/gcc/lto-streamer.c b/gcc/lto-streamer.c index 67132ef1dff..06afb97f355 100644 --- a/gcc/lto-streamer.c +++ b/gcc/lto-streamer.c @@ -314,29 +314,25 @@ check_handled_ts_structures (void) /* Helper for lto_streamer_cache_insert_1. Add T to CACHE->NODES at - slot IX. Add OFFSET to CACHE->OFFSETS at slot IX. */ + slot IX. */ static void lto_streamer_cache_add_to_node_array (struct lto_streamer_cache_d *cache, - int ix, tree t, unsigned offset) + unsigned ix, tree t) { - gcc_assert (ix >= 0); + /* Make sure we're either replacing an old element or + appending consecutively. */ + gcc_assert (ix <= VEC_length (tree, cache->nodes)); - /* Grow the array of nodes and offsets to accomodate T at IX. */ - if (ix >= (int) VEC_length (tree, cache->nodes)) - { - size_t sz = ix + (20 + ix) / 4; - VEC_safe_grow_cleared (tree, heap, cache->nodes, sz); - VEC_safe_grow_cleared (unsigned, heap, cache->offsets, sz); - } - - VEC_replace (tree, cache->nodes, ix, t); - VEC_replace (unsigned, cache->offsets, ix, offset); + if (ix == VEC_length (tree, cache->nodes)) + VEC_safe_push (tree, heap, cache->nodes, t); + else + VEC_replace (tree, cache->nodes, ix, t); } /* Helper for lto_streamer_cache_insert and lto_streamer_cache_insert_at. - CACHE, T, IX_P and OFFSET_P are as in lto_streamer_cache_insert. + CACHE, T, and IX_P are as in lto_streamer_cache_insert. If INSERT_AT_NEXT_SLOT_P is true, T is inserted at the next available slot in the cache. Otherwise, T is inserted at the position indicated @@ -347,13 +343,12 @@ lto_streamer_cache_add_to_node_array (struct lto_streamer_cache_d *cache, static bool lto_streamer_cache_insert_1 (struct lto_streamer_cache_d *cache, - tree t, int *ix_p, unsigned *offset_p, + tree t, unsigned *ix_p, bool insert_at_next_slot_p) { void **slot; struct tree_int_map d_entry, *entry; - int ix; - unsigned offset; + unsigned ix; bool existed_p; gcc_assert (t); @@ -364,19 +359,16 @@ lto_streamer_cache_insert_1 (struct lto_streamer_cache_d *cache, { /* Determine the next slot to use in the cache. */ if (insert_at_next_slot_p) - ix = cache->next_slot++; + ix = VEC_length (tree, cache->nodes); else ix = *ix_p; entry = (struct tree_int_map *)pool_alloc (cache->node_map_entries); entry->base.from = t; - entry->to = (unsigned) ix; + entry->to = ix; *slot = entry; - /* If no offset was given, store the invalid offset -1. */ - offset = (offset_p) ? *offset_p : (unsigned) -1; - - lto_streamer_cache_add_to_node_array (cache, ix, t, offset); + lto_streamer_cache_add_to_node_array (cache, ix, t); /* Indicate that the item was not present in the cache. */ existed_p = false; @@ -384,8 +376,7 @@ lto_streamer_cache_insert_1 (struct lto_streamer_cache_d *cache, else { entry = (struct tree_int_map *) *slot; - ix = (int) entry->to; - offset = VEC_index (unsigned, cache->offsets, ix); + ix = entry->to; if (!insert_at_next_slot_p && ix != *ix_p) { @@ -404,10 +395,7 @@ lto_streamer_cache_insert_1 (struct lto_streamer_cache_d *cache, gcc_assert (lto_stream_as_builtin_p (t)); ix = *ix_p; - /* Since we are storing a builtin, the offset into the - stream is not necessary as we will not need to read - forward in the stream. */ - lto_streamer_cache_add_to_node_array (cache, ix, t, -1); + lto_streamer_cache_add_to_node_array (cache, ix, t); } /* Indicate that T was already in the cache. */ @@ -417,9 +405,6 @@ lto_streamer_cache_insert_1 (struct lto_streamer_cache_d *cache, if (ix_p) *ix_p = ix; - if (offset_p) - *offset_p = offset; - return existed_p; } @@ -428,21 +413,13 @@ lto_streamer_cache_insert_1 (struct lto_streamer_cache_d *cache, return true. Otherwise, return false. If IX_P is non-null, update it with the index into the cache where - T has been stored. - - *OFFSET_P represents the offset in the stream where T is physically - written out. The first time T is added to the cache, *OFFSET_P is - recorded in the cache together with T. But if T already existed - in the cache, *OFFSET_P is updated with the value that was recorded - the first time T was added to the cache. - - If OFFSET_P is NULL, it is ignored. */ + T has been stored. */ bool lto_streamer_cache_insert (struct lto_streamer_cache_d *cache, tree t, - int *ix_p, unsigned *offset_p) + unsigned *ix_p) { - return lto_streamer_cache_insert_1 (cache, t, ix_p, offset_p, true); + return lto_streamer_cache_insert_1 (cache, t, ix_p, true); } @@ -451,24 +428,33 @@ lto_streamer_cache_insert (struct lto_streamer_cache_d *cache, tree t, bool lto_streamer_cache_insert_at (struct lto_streamer_cache_d *cache, - tree t, int ix) + tree t, unsigned ix) { - return lto_streamer_cache_insert_1 (cache, t, &ix, NULL, false); + return lto_streamer_cache_insert_1 (cache, t, &ix, false); } -/* Return true if tree node T exists in CACHE. If IX_P is +/* Appends tree node T to CACHE, even if T already existed in it. */ + +void +lto_streamer_cache_append (struct lto_streamer_cache_d *cache, tree t) +{ + unsigned ix = VEC_length (tree, cache->nodes); + lto_streamer_cache_insert_1 (cache, t, &ix, false); +} + +/* Return true if tree node T exists in CACHE, otherwise false. If IX_P is not NULL, write to *IX_P the index into the cache where T is stored - (-1 if T is not found). */ + ((unsigned)-1 if T is not found). */ bool lto_streamer_cache_lookup (struct lto_streamer_cache_d *cache, tree t, - int *ix_p) + unsigned *ix_p) { void **slot; struct tree_int_map d_slot; bool retval; - int ix; + unsigned ix; gcc_assert (t); @@ -482,7 +468,7 @@ lto_streamer_cache_lookup (struct lto_streamer_cache_d *cache, tree t, else { retval = true; - ix = (int) ((struct tree_int_map *) *slot)->to; + ix = ((struct tree_int_map *) *slot)->to; } if (ix_p) @@ -495,17 +481,14 @@ lto_streamer_cache_lookup (struct lto_streamer_cache_d *cache, tree t, /* Return the tree node at slot IX in CACHE. */ tree -lto_streamer_cache_get (struct lto_streamer_cache_d *cache, int ix) +lto_streamer_cache_get (struct lto_streamer_cache_d *cache, unsigned ix) { gcc_assert (cache); - /* If the reader is requesting an index beyond the length of the - cache, it will need to read ahead. Return NULL_TREE to indicate - that. */ - if ((unsigned) ix >= VEC_length (tree, cache->nodes)) - return NULL_TREE; + /* Make sure we're not requesting something we don't have. */ + gcc_assert (ix < VEC_length (tree, cache->nodes)); - return VEC_index (tree, cache->nodes, (unsigned) ix); + return VEC_index (tree, cache->nodes, ix); } @@ -538,13 +521,10 @@ lto_record_common_node (tree *nodep, VEC(tree, heap) **common_nodes, VEC_safe_push (tree, heap, *common_nodes, node); - if (tree_node_can_be_shared (node)) - { - if (POINTER_TYPE_P (node) - || TREE_CODE (node) == COMPLEX_TYPE - || TREE_CODE (node) == ARRAY_TYPE) - lto_record_common_node (&TREE_TYPE (node), common_nodes, seen_nodes); - } + if (POINTER_TYPE_P (node) + || TREE_CODE (node) == COMPLEX_TYPE + || TREE_CODE (node) == ARRAY_TYPE) + lto_record_common_node (&TREE_TYPE (node), common_nodes, seen_nodes); } @@ -607,7 +587,7 @@ preload_common_node (struct lto_streamer_cache_d *cache, tree t) { gcc_assert (t); - lto_streamer_cache_insert (cache, t, NULL, NULL); + lto_streamer_cache_insert (cache, t, NULL); /* The FIELD_DECLs of structures should be shared, so that every COMPONENT_REF uses the same tree node when referencing a field. @@ -667,7 +647,6 @@ lto_streamer_cache_delete (struct lto_streamer_cache_d *c) htab_delete (c->node_map); free_alloc_pool (c->node_map_entries); VEC_free (tree, heap, c->nodes); - VEC_free (unsigned, heap, c->offsets); free (c); } |