]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Avoid streaming stray references.
authorJan Hubicka <jh@suse.cz>
Fri, 22 May 2020 14:37:06 +0000 (16:37 +0200)
committerJan Hubicka <jh@suse.cz>
Thu, 13 Aug 2020 15:49:07 +0000 (17:49 +0200)
this patch avoids stremaing completely useless stray references to gobal decl
stream.  I am re-testing the patch (rebased to current tree) on x86_64-linux
and intend to commit once testing finishes.

gcc/ChangeLog:

2020-05-22  Jan Hubicka  <hubicka@ucw.cz>

* lto-streamer-out.c (lto_output_tree): Do not stream final ref if
it is not needed.

gcc/lto/ChangeLog:

2020-05-22  Jan Hubicka  <hubicka@ucw.cz>

* lto-common.c (lto_read_decls): Do not skip stray refs.

(cherry picked from commit bcb63eb2cbd3caf212b9cf42d8c218c09dc6ff8b)
(cherry picked from commit 57400cf273f8052c601d90d86a47705faa17aaa9)

gcc/lto-streamer-out.c
gcc/lto/lto-common.c

index 2c3d16799b46a90ab28d2e9d9027303b045dd468..74ea872e5114f152787f0e73574d4f0acfaae630 100644 (file)
@@ -1746,7 +1746,7 @@ lto_output_tree (struct output_block *ob, tree expr,
         it.  */
       if (!existed_p)
        lto_output_tree_1 (ob, expr, 0, ref_p, this_ref_p);
-      else
+      else if (this_ref_p)
        {
          streamer_write_record_start (ob, LTO_tree_pickle_reference);
          streamer_write_uhwi (ob, ix);
index 66858a88157c49bd52cf96900228d569919f10d1..bcc0919dfc6c0462eb0792387f7710be9c1499ad 100644 (file)
@@ -1955,25 +1955,19 @@ lto_read_decls (struct lto_file_decl_data *decl_data, const void *data,
       else
        {
          t = lto_input_tree_1 (&ib_main, data_in, tag, 0);
-         /* We streamed in new tree.  Add it to cache and process dref.  */
-         if (data_in->reader_cache->nodes.length () == from + 1)
+         gcc_assert (data_in->reader_cache->nodes.length () == from + 1);
+         num_unshared_trees_read++;
+         data_in->location_cache.accept_location_cache ();
+         process_dref (data_in, t, from);
+         if (TREE_CODE (t) == IDENTIFIER_NODE
+             || (TREE_CODE (t) == INTEGER_CST
+                 && !TREE_OVERFLOW (t)))
+           ;
+         else
            {
-             num_unshared_trees_read++;
-             data_in->location_cache.accept_location_cache ();
-             process_dref (data_in, t, from);
-             if (TREE_CODE (t) == IDENTIFIER_NODE
-                 || (TREE_CODE (t) == INTEGER_CST
-                     && !TREE_OVERFLOW (t)))
-               ;
-             else
-               {
-                 lto_maybe_register_decl (data_in, t, from);
-                 process_new_tree (t, &hm, from, &total, data_in);
-               }
+             lto_maybe_register_decl (data_in, t, from);
+             process_new_tree (t, &hm, from, &total, data_in);
            }
-         else
-           /* FIXME: It seems useless to pickle stray references.  */
-           gcc_assert (data_in->reader_cache->nodes.length () == from);
        }
     }