[PATCH 5/5] use vec in lto_tree_ref_table
Richard Biener
richard.guenther@gmail.com
Fri Nov 14 10:44:00 GMT 2014
On Thu, Nov 13, 2014 at 6:55 AM, <tsaunders@mozilla.com> wrote:
> From: Trevor Saunders <tsaunders@mozilla.com>
>
> Hi,
>
> gengtype fails to create valid user marking functions for this type, which is
> fixed by using vec here (which seems cleaner anyway).
>
> bootstrapped + regtested powerpc64-linux (gcc 110 since gcc20 died) ok?
Ok.
Thanks,
Richard.
> Trev
>
>
> gcc/ChangeLog:
>
> 2014-11-13 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-13 Trevor Saunders <tsaunders@mozilla.com>
>
> * lto.c (lto_read_in_decl_state): Adjust.
> (lto_fixup_state): Likewise.
>
>
> diff --git a/gcc/lto-section-in.c b/gcc/lto-section-in.c
> index 042dd99..75f394d 100644
> --- a/gcc/lto-section-in.c
> +++ b/gcc/lto-section-in.c
> @@ -379,8 +379,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);
> }
>
> @@ -429,7 +428,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);
> }
>
> diff --git a/gcc/lto-streamer-out.c b/gcc/lto-streamer-out.c
> index dc406da..bc18a9c 100644
> --- a/gcc/lto-streamer-out.c
> +++ b/gcc/lto-streamer-out.c
> @@ -2186,8 +2186,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.
> @@ -2196,7 +2196,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,
> diff --git a/gcc/lto-streamer.h b/gcc/lto-streamer.h
> index 4b875a2..9d6d7a0 100644
> --- a/gcc/lto-streamer.h
> +++ b/gcc/lto-streamer.h
> @@ -274,15 +274,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]); \
> }
>
>
> @@ -420,18 +419,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
> @@ -445,7 +432,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. */
> diff --git a/gcc/lto/lto.c b/gcc/lto/lto.c
> index d8519d9..cdd2331 100644
> --- a/gcc/lto/lto.c
> +++ b/gcc/lto/lto.c
> @@ -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;
> }
>
> @@ -2806,20 +2808,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);
> }
> }
> }
> --
> 2.1.3
>
More information about the Gcc-patches
mailing list