public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Jiu Fu Guo <guojiufu@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc(refs/users/guojiufu/heads/guojiufu-branch)] Simplify streaming of tree references
Date: Wed, 10 Jun 2020 03:25:34 +0000 (GMT)	[thread overview]
Message-ID: <20200610032534.3C452388C035@sourceware.org> (raw)

https://gcc.gnu.org/g:34e5efa10a7b514238ed9a914b802898d2d8cb36

commit 34e5efa10a7b514238ed9a914b802898d2d8cb36
Author: Jan Hubicka <jh@suse.cz>
Date:   Tue Jun 2 17:39:58 2020 +0200

    Simplify streaming of tree references
    
            * lto-streamer-in.c (stream_read_tree_ref): Simplify streaming of
            references.
            * lto-streamer-out.c (stream_write_tree_ref): Likewise.

Diff:
---
 gcc/lto-streamer-in.c  | 24 +++++++++++++-----------
 gcc/lto-streamer-out.c | 10 +++++++---
 2 files changed, 20 insertions(+), 14 deletions(-)

diff --git a/gcc/lto-streamer-in.c b/gcc/lto-streamer-in.c
index 5eaba7d16d4..15bfb614163 100644
--- a/gcc/lto-streamer-in.c
+++ b/gcc/lto-streamer-in.c
@@ -1501,20 +1501,22 @@ lto_input_scc (class lto_input_block *ib, class data_in *data_in,
 tree
 stream_read_tree_ref (lto_input_block *ib, data_in *data_in)
 {
-  unsigned ix = streamer_read_uhwi (ib);
-  tree ret;
+  int ix = streamer_read_hwi (ib);
   if (!ix)
     return NULL_TREE;
-  else if (ix < LTO_NUM_TAGS)
-    ret = lto_input_tree_ref (ib, data_in, cfun, (LTO_tags)ix);
+  if (ix > 0)
+    return streamer_tree_cache_get_tree (data_in->reader_cache, ix - 1);
+
+  ix = -ix - 1;
+  int id = ix & 1;
+  ix /= 2;
+
+  tree ret;
+  if (!id)
+    ret = (*data_in->file_data->current_decl_state
+	   ->streams[LTO_DECL_STREAM])[ix];
   else
-    ret = streamer_tree_cache_get_tree (data_in->reader_cache,
-					ix - LTO_NUM_TAGS);
-  if (ret && streamer_debugging)
-    {
-      enum tree_code c = (enum tree_code)streamer_read_uhwi (ib);
-      gcc_assert (c == TREE_CODE (ret));
-    }
+    ret = (*SSANAMES (cfun))[ix];
   return ret;
 }
 
diff --git a/gcc/lto-streamer-out.c b/gcc/lto-streamer-out.c
index dfc4603d7ae..f71d3f81662 100644
--- a/gcc/lto-streamer-out.c
+++ b/gcc/lto-streamer-out.c
@@ -400,15 +400,19 @@ stream_write_tree_ref (struct output_block *ob, tree t)
       unsigned int ix;
       bool existed_p = streamer_tree_cache_lookup (ob->writer_cache, t, &ix);
       if (existed_p)
-	streamer_write_uhwi (ob, ix + LTO_NUM_TAGS);
+	streamer_write_hwi (ob, ix + 1);
       else
 	{
 	  enum LTO_tags tag;
 	  unsigned ix;
+	  int id = 0;
 
 	  lto_indexable_tree_ref (ob, t, &tag, &ix);
-	  streamer_write_uhwi (ob, tag);
-	  streamer_write_uhwi (ob, ix);
+	  if (tag == LTO_ssa_name_ref)
+	    id = 1;
+	  else
+	    gcc_checking_assert (tag == LTO_global_stream_ref);
+	  streamer_write_hwi (ob, -(int)(ix * 2 + id + 1));
 	}
       if (streamer_debugging)
 	streamer_write_uhwi (ob, TREE_CODE (t));


                 reply	other threads:[~2020-06-10  3:25 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200610032534.3C452388C035@sourceware.org \
    --to=guojiufu@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).