use vec in lto_tree_ref_table
authorTrevor Saunders <tsaunders@mozilla.com>
Thu, 20 Nov 2014 15:10:42 +0000 (15:10 +0000)
committerTrevor Saunders <tbsaunde@gcc.gnu.org>
Thu, 20 Nov 2014 15:10:42 +0000 (15:10 +0000)
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

gcc/ChangeLog
gcc/lto-section-in.c
gcc/lto-streamer-out.c
gcc/lto-streamer.h
gcc/lto/ChangeLog
gcc/lto/lto.c

index 57dfc167760a803ed2521f5ddfb69e154c2347e9..c99757b1eccdc3a56775d34b319d4e9982002ee4 100644 (file)
@@ -1,3 +1,13 @@
+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.
index d54ca0f8b06be898678ae0c7ce4918e9b45fbb12..d0bb4bdd9de8be9b0c04c594caf29f4042fa76c0 100644 (file)
@@ -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);
 }
 
index be041e9c8115c1b06e76228bcd903b36f69ed83b..19f59a0ecf84804bda55f0dab83130e0cbe45a25 100644 (file)
@@ -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,
index 000c147dc5894f80995878db3e70cd8b8bedbc2e..8129171a6f3ade121d7a76f94274542e0eac6197 100644 (file)
@@ -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. */
index 50d32f5948b750629e5c34b611a08c188fef2175..329da66a56d0ce205a6327af80876d47b0e401e6 100644 (file)
@@ -1,3 +1,8 @@
+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.
index a1f109cdea682fd2bb708eed7b9e7e86e44d7758..4cb99f1f7007944c8fb869593a5e62759c943698 100644 (file)
@@ -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);
        }
     }
 }