]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR lto/54790 (Missing optimization with LTO)
authorJan Hubicka <jh@suse.cz>
Sat, 6 Oct 2012 13:59:55 +0000 (15:59 +0200)
committerJan Hubicka <hubicka@gcc.gnu.org>
Sat, 6 Oct 2012 13:59:55 +0000 (13:59 +0000)
PR lto/54790
* lto.c (resolution_map): New static var.
(register_resolution): New function.
(lto_register_var_decl_in_symtab): Use it.
(read_cgraph_and_symbols): Copy resolutions into the symtab.
* lto-streamer.h (lto_symtab_register_decl, lto_symtab_get_resolution,
lto_mark_nothrow_fndecl, lto_fixup_nothrow_decls): Remove.
* lto-symtab.c (lto_symtab_register_decl): Remove.

From-SVN: r192159

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

index b44a1fe5c9274b1571c0d534d182f52b41a642c4..74b3f0ea2172759ca689d1e9d6d71f9eefaafebc 100644 (file)
@@ -1,3 +1,10 @@
+2012-10-06  Jan Hubicka  <jh@suse.cz>
+
+       PR lto/54790 
+       * lto-streamer.h (lto_symtab_register_decl, lto_symtab_get_resolution,
+       lto_mark_nothrow_fndecl, lto_fixup_nothrow_decls): Remove.
+       * lto-symtab.c (lto_symtab_register_decl): Remove.
+
 2012-10-06  Andreas Schwab  <schwab@linux-m68k.org>
 
        PR rtl-optimization/54739
index 059959e737ff32999571b61db0b88baa11d7e1a6..6625b741bebc3bf28c0b6628b7137efc65318950 100644 (file)
@@ -860,12 +860,9 @@ lto_symtab_encoder_t compute_ltrans_boundary (lto_symtab_encoder_t encoder);
 
 
 /* In lto-symtab.c.  */
-extern void lto_symtab_register_decl (tree, ld_plugin_symbol_resolution_t,
-                                     struct lto_file_decl_data *);
 extern void lto_symtab_merge_decls (void);
 extern void lto_symtab_merge_cgraph_nodes (void);
 extern tree lto_symtab_prevailing_decl (tree decl);
-extern enum ld_plugin_symbol_resolution lto_symtab_get_resolution (tree decl);
 extern GTY(()) VEC(tree,gc) *lto_global_var_decls;
 
 
@@ -873,11 +870,6 @@ extern GTY(()) VEC(tree,gc) *lto_global_var_decls;
 extern void lto_write_options (void);
 
 
-/* In lto-wpa-fixup.c  */
-void lto_mark_nothrow_fndecl (tree);
-void lto_fixup_nothrow_decls (void);
-
-
 /* Statistics gathered during LTO, WPA and LTRANS.  */
 extern struct lto_stats_d lto_stats;
 
index cd8ca67b0c0a549c614f545c5b11a3a1a946d05d..25c0b22dc485784ef3879ba9c5ca1260f4b39545 100644 (file)
@@ -32,40 +32,6 @@ along with GCC; see the file COPYING3.  If not see
 /* Vector to keep track of external variables we've seen so far.  */
 VEC(tree,gc) *lto_global_var_decls;
 
-/* Registers DECL with the LTO symbol table as having resolution RESOLUTION
-   and read from FILE_DATA. */
-
-void
-lto_symtab_register_decl (tree decl,
-                         ld_plugin_symbol_resolution_t resolution,
-                         struct lto_file_decl_data *file_data)
-{
-  symtab_node node;
-
-  /* Check that declarations reaching this function do not have
-     properties inconsistent with having external linkage.  If any of
-     these asertions fail, then the object file reader has failed to
-     detect these cases and issue appropriate error messages.  */
-  gcc_assert (decl
-             && TREE_PUBLIC (decl)
-             && (TREE_CODE (decl) == VAR_DECL
-                 || TREE_CODE (decl) == FUNCTION_DECL)
-             && DECL_ASSEMBLER_NAME_SET_P (decl));
-  if (TREE_CODE (decl) == VAR_DECL
-      && DECL_INITIAL (decl))
-    gcc_assert (!DECL_EXTERNAL (decl)
-               || (TREE_STATIC (decl) && TREE_READONLY (decl)));
-  if (TREE_CODE (decl) == FUNCTION_DECL)
-    gcc_assert (!DECL_ABSTRACT (decl));
-
-  node = symtab_get_node (decl);
-  if (node)
-    {
-      node->symbol.resolution = resolution;
-      gcc_assert (node->symbol.lto_file_data == file_data);
-    }
-}
-
 /* Replace the cgraph node NODE with PREVAILING_NODE in the cgraph, merging
    all edges and removing the old node.  */
 
index 7c437d6c9e55ac66e057959668852a7ab9ffe27d..86acc2417d275cc91b0ac933521ce4f756ea53ce 100644 (file)
@@ -1,3 +1,11 @@
+2012-10-06  Jan Hubicka  <jh@suse.cz>
+
+       PR lto/54790 
+       * lto.c (resolution_map): New static var.
+       (register_resolution): New function.
+       (lto_register_var_decl_in_symtab): Use it.
+       (read_cgraph_and_symbols): Copy resolutions into the symtab.
+
 2012-09-20  Martin Jambor  <mjambor@suse.cz>
 
        * lto.c (lto_materialize_function): Call push_struct_function and
index 44718537b3c2b41c71974a3d2bb5019240a43f8f..c6b882d6941696af4f8fa21f0e3b43bf6a1f2609 100644 (file)
@@ -1692,6 +1692,19 @@ get_resolution (struct data_in *data_in, unsigned index)
     return LDPR_UNKNOWN;
 }
 
+/* Map assigning declarations their resolutions.  */
+static pointer_map_t *resolution_map;
+
+/* We need to record resolutions until symbol table is read.  */
+static void
+register_resolution (tree decl, enum ld_plugin_symbol_resolution resolution)
+{
+  if (resolution == LDPR_UNKNOWN)
+    return;
+  if (!resolution_map)
+    resolution_map = pointer_map_create ();
+  *pointer_map_insert (resolution_map, decl) = (void *)(size_t)resolution;
+}
 
 /* Register DECL with the global symbol table and change its
    name if necessary to avoid name clashes for static globals across
@@ -1730,8 +1743,7 @@ lto_register_var_decl_in_symtab (struct data_in *data_in, tree decl)
       unsigned ix;
       if (!streamer_tree_cache_lookup (data_in->reader_cache, decl, &ix))
        gcc_unreachable ();
-      lto_symtab_register_decl (decl, get_resolution (data_in, ix),
-                               data_in->file_data);
+      register_resolution (decl, get_resolution (data_in, ix));
     }
 }
 
@@ -1789,8 +1801,7 @@ lto_register_function_decl_in_symtab (struct data_in *data_in, tree decl)
       unsigned ix;
       if (!streamer_tree_cache_lookup (data_in->reader_cache, decl, &ix))
        gcc_unreachable ();
-      lto_symtab_register_decl (decl, get_resolution (data_in, ix),
-                               data_in->file_data);
+      register_resolution (decl, get_resolution (data_in, ix));
     }
 }
 
@@ -2946,6 +2957,24 @@ read_cgraph_and_symbols (unsigned nfiles, const char **fnames)
   timevar_push (TV_IPA_LTO_CGRAPH_IO);
   /* Read the symtab.  */
   input_symtab ();
+
+  /* Store resolutions into the symbol table.  */
+  if (resolution_map)
+    {
+      void **res;
+      symtab_node snode;
+
+      FOR_EACH_SYMBOL (snode)
+       if (symtab_real_symbol_p (snode)
+           && (res = pointer_map_contains (resolution_map,
+                                           snode->symbol.decl)))
+         snode->symbol.resolution
+           = (enum ld_plugin_symbol_resolution)(size_t)*res;
+
+      pointer_map_destroy (resolution_map);
+      resolution_map = NULL;
+    }
+  
   timevar_pop (TV_IPA_LTO_CGRAPH_IO);
 
   if (!quiet_flag)
index 57580b571b88a3c3811e42189cfad98e1d9555c2..793549bb297a694cb4c32264ab169d2a68d0fa48 100644 (file)
@@ -1,3 +1,7 @@
+2012-10-06  Jan Hubicka  <jh@suse.cz>
+
+       * gcc.dg/lto/resolutions_0.c: New testcase.
+
 2012-10-06  Janus Weil  <janus@gcc.gnu.org>
 
        PR fortran/45521