From 9c71e9df38dc3260fc21d8e8024b53d6dd3f7ac3 Mon Sep 17 00:00:00 2001 From: Trevor Saunders Date: Thu, 20 Nov 2014 15:10:42 +0000 Subject: [PATCH] use vec in lto_tree_ref_table gcc/ChangeLog: 2014-11-20 Trevor Saunders * 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. gcc/lto/ChangeLog: 2014-11-20 Trevor Saunders * lto.c (lto_read_in_decl_state): Adjust. (lto_fixup_state): Likewise. From-SVN: r217870 --- gcc/ChangeLog | 10 ++++++++++ gcc/lto-section-in.c | 5 ++--- gcc/lto-streamer-out.c | 6 +++--- gcc/lto-streamer.h | 19 +++---------------- gcc/lto/ChangeLog | 5 +++++ gcc/lto/lto.c | 23 ++++++++++++----------- 6 files changed, 35 insertions(+), 33 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 57dfc167760..c99757b1ecc 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,13 @@ +2014-11-20 Trevor Saunders + + * 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. + 2014-11-20 Trevor Saunders * hash-map.h (hash_map::iterator): New class. diff --git a/gcc/lto-section-in.c b/gcc/lto-section-in.c index d54ca0f8b06..d0bb4bdd9de 100644 --- a/gcc/lto-section-in.c +++ b/gcc/lto-section-in.c @@ -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); } diff --git a/gcc/lto-streamer-out.c b/gcc/lto-streamer-out.c index be041e9c811..19f59a0ecf8 100644 --- a/gcc/lto-streamer-out.c +++ b/gcc/lto-streamer-out.c @@ -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 *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, diff --git a/gcc/lto-streamer.h b/gcc/lto-streamer.h index 000c147dc58..8129171a6f3 100644 --- a/gcc/lto-streamer.h +++ b/gcc/lto-streamer.h @@ -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 *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/ChangeLog b/gcc/lto/ChangeLog index 50d32f5948b..329da66a56d 100644 --- a/gcc/lto/ChangeLog +++ b/gcc/lto/ChangeLog @@ -1,3 +1,8 @@ +2014-11-20 Trevor Saunders + + * lto.c (lto_read_in_decl_state): Adjust. + (lto_fixup_state): Likewise. + 2014-11-17 Jan Hubicka * lto.c (lto_read_decls): Do not rebuild DECL_FUNCTION_SPECIFIC_TARGET. diff --git a/gcc/lto/lto.c b/gcc/lto/lto.c index a1f109cdea6..4cb99f1f700 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 (size); + vec *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 *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.30.2