OSDN Git Service

2012-09-15 Andi Kleen <ak@linux.intel.com>
authorak <ak@138bc75d-0d04-0410-961f-82ee72b054a4>
Sat, 15 Sep 2012 23:03:27 +0000 (23:03 +0000)
committerak <ak@138bc75d-0d04-0410-961f-82ee72b054a4>
Sat, 15 Sep 2012 23:03:27 +0000 (23:03 +0000)
        Backport from mainline
        2012-09-07  Andi Kleen  <ak@linux.intel.com>

        * gcc/lto-streamer.h (res_pair): Add.
        (lto_file_decl_data): Replace resolutions with respairs.
        Add max_index.
        * gcc/lto/lto.c (lto_resolution_read): Remove max_index.  Add
        * rp.
        Initialize respairs.
        (lto_file_finalize): Set up resolutions vector lazily from respairs.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_7-branch@191353 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/lto-streamer.h
gcc/lto/lto.c

index 8c1face..4882eee 100644 (file)
@@ -1,3 +1,15 @@
+2012-09-15  Andi Kleen  <ak@linux.intel.com>
+
+       Backport from mainline
+       2012-09-07  Andi Kleen  <ak@linux.intel.com>
+
+       * gcc/lto-streamer.h (res_pair): Add.
+       (lto_file_decl_data): Replace resolutions with respairs.
+       Add max_index.
+       * gcc/lto/lto.c (lto_resolution_read): Remove max_index.  Add rp.
+       Initialize respairs.
+       (lto_file_finalize): Set up resolutions vector lazily from respairs.
+
 2012-09-14  Walter Lee  <walt@tilera.com>
 
        Backport from mainline.
index 5c2f4ea..cbd8b76 100644 (file)
@@ -535,6 +535,18 @@ typedef struct lto_out_decl_state *lto_out_decl_state_ptr;
 DEF_VEC_P(lto_out_decl_state_ptr);
 DEF_VEC_ALLOC_P(lto_out_decl_state_ptr, heap);
 
+/* Compact representation of a index <-> resolution pair. Unpacked to an 
+   vector later. */
+struct res_pair 
+{
+  ld_plugin_symbol_resolution_t res;
+  unsigned index;
+};
+typedef struct res_pair res_pair;
+
+DEF_VEC_O(res_pair);
+DEF_VEC_ALLOC_O(res_pair, heap);
+
 /* One of these is allocated for each object file that being compiled
    by lto.  This structure contains the tables that are needed by the
    serialized functions and ipa passes to connect themselves to the
@@ -573,7 +585,8 @@ struct GTY(()) lto_file_decl_data
   unsigned HOST_WIDE_INT id;
 
   /* Symbol resolutions for this file */
-  VEC(ld_plugin_symbol_resolution_t,heap) * GTY((skip)) resolutions;
+  VEC(res_pair, heap) * GTY((skip)) respairs;
+  unsigned max_index;
 
   struct gcov_ctr_summary GTY((skip)) profile_info;
 };
index f267d2a..3e7503b 100644 (file)
@@ -994,7 +994,6 @@ lto_resolution_read (splay_tree file_ids, FILE *resolution, lto_file *file)
   unsigned int num_symbols;
   unsigned int i;
   struct lto_file_decl_data *file_data;
-  unsigned max_index = 0;
   splay_tree_node nd = NULL; 
 
   if (!resolution)
@@ -1036,13 +1035,12 @@ lto_resolution_read (splay_tree file_ids, FILE *resolution, lto_file *file)
       unsigned int j;
       unsigned int lto_resolution_str_len =
        sizeof (lto_resolution_str) / sizeof (char *);
+      res_pair rp;
 
       t = fscanf (resolution, "%u " HOST_WIDE_INT_PRINT_HEX_PURE " %26s %*[^\n]\n", 
                  &index, &id, r_str);
       if (t != 3)
         internal_error ("invalid line in the resolution file");
-      if (index > max_index)
-       max_index = index;
 
       for (j = 0; j < lto_resolution_str_len; j++)
        {
@@ -1064,11 +1062,13 @@ lto_resolution_read (splay_tree file_ids, FILE *resolution, lto_file *file)
        }
 
       file_data = (struct lto_file_decl_data *)nd->value;
-      VEC_safe_grow_cleared (ld_plugin_symbol_resolution_t, heap, 
-                            file_data->resolutions,
-                            max_index + 1);
-      VEC_replace (ld_plugin_symbol_resolution_t, 
-                  file_data->resolutions, index, r);
+      /* The indexes are very sparse. To save memory save them in a compact
+         format that is only unpacked later when the subfile is processed. */
+      rp.res = r;
+      rp.index = index;
+      VEC_safe_push (res_pair, heap, file_data->respairs, &rp);
+      if (file_data->max_index < index)
+        file_data->max_index = index;
     }
 }
 
@@ -1148,6 +1148,18 @@ lto_file_finalize (struct lto_file_decl_data *file_data, lto_file *file)
 {
   const char *data;
   size_t len;
+  VEC(ld_plugin_symbol_resolution_t,heap) *resolutions = NULL;
+  int i;
+  res_pair *rp;
+
+  /* Create vector for fast access of resolution. We do this lazily
+     to save memory. */ 
+  VEC_safe_grow_cleared (ld_plugin_symbol_resolution_t, heap, 
+                            resolutions,
+                            file_data->max_index + 1);
+  for (i = 0; VEC_iterate (res_pair, file_data->respairs, i, rp); i++)
+    VEC_replace (ld_plugin_symbol_resolution_t, resolutions, rp->index, rp->res);
+  VEC_free (res_pair, heap, file_data->respairs);
 
   file_data->renaming_hash_table = lto_create_renaming_table ();
   file_data->file_name = file->filename;
@@ -1157,7 +1169,8 @@ lto_file_finalize (struct lto_file_decl_data *file_data, lto_file *file)
       internal_error ("cannot read LTO decls from %s", file_data->file_name);
       return;
     }
-  lto_read_decls (file_data, data, file_data->resolutions);
+  /* Frees resolutions */
+  lto_read_decls (file_data, data, resolutions);
   lto_free_section_data (file_data, LTO_section_decls, NULL, data, len);
 }