Commit 9c71e9df by Trevor Saunders Committed by Trevor Saunders

use vec in lto_tree_ref_table

gcc/ChangeLog:

2014-11-20  Trevor Saunders  <tsaunders@mozilla.com>

	* lto-section-in.c (lto_delete_in_decl_state): Adjust.
	(lto_free_function_in_decl_state): Likewise.
	* lto-streamer-out.c (copy_function_or_variable): Likewise.
	* lto-streamer.h (lto_file_decl_data_get_ ## name): Likewise.
	(lto_file_decl_data_num_ ## name ## s): Likewise.
	(struct lto_tree_ref_table): Remove.
	(struct lto_in_decl_state): Replace lto_tree_ref_table with vec<tree>.

gcc/lto/ChangeLog:

2014-11-20  Trevor Saunders  <tsaunders@mozilla.com>

	* lto.c (lto_read_in_decl_state): Adjust.
	(lto_fixup_state): Likewise.

From-SVN: r217870
parent de144fb2
2014-11-20 Trevor Saunders <tsaunders@mozilla.com>
* lto-section-in.c (lto_delete_in_decl_state): Adjust.
(lto_free_function_in_decl_state): Likewise.
* lto-streamer-out.c (copy_function_or_variable): Likewise.
* lto-streamer.h (lto_file_decl_data_get_ ## name): Likewise.
(lto_file_decl_data_num_ ## name ## s): Likewise.
(struct lto_tree_ref_table): Remove.
(struct lto_in_decl_state): Replace lto_tree_ref_table with vec<tree>.
2014-11-20 Trevor Saunders <tsaunders@mozilla.com>
* hash-map.h (hash_map::iterator): New class.
(hash_map::begin): New method.
(hash_map::end): Likewise.
......@@ -380,8 +380,7 @@ lto_delete_in_decl_state (struct lto_in_decl_state *state)
int i;
for (i = 0; i < LTO_N_DECL_STREAMS; i++)
if (state->streams[i].trees)
ggc_free (state->streams[i].trees);
vec_free (state->streams[i]);
ggc_free (state);
}
......@@ -430,7 +429,7 @@ lto_free_function_in_decl_state (struct lto_in_decl_state *state)
{
int i;
for (i = 0; i < LTO_N_DECL_STREAMS; i++)
ggc_free (state->streams[i].trees);
vec_free (state->streams[i]);
ggc_free (state);
}
......
......@@ -2187,8 +2187,8 @@ copy_function_or_variable (struct symtab_node *node)
for (i = 0; i < LTO_N_DECL_STREAMS; i++)
{
size_t n = in_state->streams[i].size;
tree *trees = in_state->streams[i].trees;
size_t n = vec_safe_length (in_state->streams[i]);
vec<tree, va_gc> *trees = in_state->streams[i];
struct lto_tree_ref_encoder *encoder = &(out_state->streams[i]);
/* The out state must have the same indices and the in state.
......@@ -2197,7 +2197,7 @@ copy_function_or_variable (struct symtab_node *node)
gcc_assert (lto_tree_ref_encoder_size (encoder) == 0);
encoder->trees.reserve_exact (n);
for (j = 0; j < n; j++)
encoder->trees.safe_push (trees[j]);
encoder->trees.safe_push ((*trees)[j]);
}
lto_free_section_data (file_data, LTO_section_function_body, name,
......
......@@ -275,15 +275,14 @@ lto_file_decl_data_get_ ## name (struct lto_file_decl_data *data, \
unsigned int idx) \
{ \
struct lto_in_decl_state *state = data->current_decl_state; \
gcc_assert (idx < state->streams[LTO_DECL_STREAM_## UPPER_NAME].size); \
return state->streams[LTO_DECL_STREAM_## UPPER_NAME].trees[idx]; \
return (*state->streams[LTO_DECL_STREAM_## UPPER_NAME])[idx]; \
} \
\
static inline unsigned int \
lto_file_decl_data_num_ ## name ## s (struct lto_file_decl_data *data) \
{ \
struct lto_in_decl_state *state = data->current_decl_state; \
return state->streams[LTO_DECL_STREAM_## UPPER_NAME].size; \
return vec_safe_length (state->streams[LTO_DECL_STREAM_## UPPER_NAME]); \
}
......@@ -421,18 +420,6 @@ struct lto_symtab_encoder_iterator
/* Mapping from indices to trees. */
struct GTY(()) lto_tree_ref_table
{
/* Array of referenced trees . */
tree * GTY((length ("%h.size"))) trees;
/* Size of array. */
unsigned int size;
};
/* The lto_tree_ref_encoder struct is used to encode trees into indices. */
struct lto_tree_ref_encoder
......@@ -446,7 +433,7 @@ struct lto_tree_ref_encoder
struct GTY(()) lto_in_decl_state
{
/* Array of lto_in_decl_buffers to store type and decls streams. */
struct lto_tree_ref_table streams[LTO_N_DECL_STREAMS];
vec<tree, va_gc> *streams[LTO_N_DECL_STREAMS];
/* If this in-decl state is associated with a function. FN_DECL
point to the FUNCTION_DECL. */
......
2014-11-20 Trevor Saunders <tsaunders@mozilla.com>
* lto.c (lto_read_in_decl_state): Adjust.
(lto_fixup_state): Likewise.
2014-11-17 Jan Hubicka <hubicka@ucw.cz>
* lto.c (lto_read_decls): Do not rebuild DECL_FUNCTION_SPECIFIC_TARGET.
......
......@@ -260,13 +260,15 @@ lto_read_in_decl_state (struct data_in *data_in, const uint32_t *data,
for (i = 0; i < LTO_N_DECL_STREAMS; i++)
{
uint32_t size = *data++;
tree *decls = ggc_vec_alloc<tree> (size);
vec<tree, va_gc> *decls = NULL;
vec_alloc (decls, size);
for (j = 0; j < size; j++)
decls[j] = streamer_tree_cache_get_tree (data_in->reader_cache, data[j]);
vec_safe_push (decls,
streamer_tree_cache_get_tree (data_in->reader_cache,
data[j]));
state->streams[i].size = size;
state->streams[i].trees = decls;
state->streams[i] = decls;
data += size;
}
......@@ -2798,20 +2800,19 @@ static void
lto_fixup_state (struct lto_in_decl_state *state)
{
unsigned i, si;
struct lto_tree_ref_table *table;
/* Although we only want to replace FUNCTION_DECLs and VAR_DECLs,
we still need to walk from all DECLs to find the reachable
FUNCTION_DECLs and VAR_DECLs. */
for (si = 0; si < LTO_N_DECL_STREAMS; si++)
{
table = &state->streams[si];
for (i = 0; i < table->size; i++)
vec<tree, va_gc> *trees = state->streams[si];
for (i = 0; i < vec_safe_length (trees); i++)
{
tree *tp = table->trees + i;
if (VAR_OR_FUNCTION_DECL_P (*tp)
&& (TREE_PUBLIC (*tp) || DECL_EXTERNAL (*tp)))
*tp = lto_symtab_prevailing_decl (*tp);
tree t = (*trees)[i];
if (VAR_OR_FUNCTION_DECL_P (t)
&& (TREE_PUBLIC (t) || DECL_EXTERNAL (t)))
(*trees)[i] = lto_symtab_prevailing_decl (t);
}
}
}
......
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