]> gcc.gnu.org Git - gcc.git/commitdiff
Cleanup LTO tag streaming.
authorJan Hubicka <jh@suse.cz>
Wed, 3 Jun 2020 10:03:40 +0000 (12:03 +0200)
committerJan Hubicka <jh@suse.cz>
Wed, 3 Jun 2020 10:10:22 +0000 (12:10 +0200)
this patch cleanups a bit the way LTO tags are assigned (so we do not use magic
numbers of 2) and reorders them approximately by their frequency so the stream
gets little bit smaller because of uleb coding.

From:

[WPA] Compression: 111213968 input bytes, 293801489 uncompressed bytes (ratio: 2.641768)
[WPA] Size of mmap'd section decls: 85983129 bytes
[WPA] Size of mmap'd section function_body: 14058627 bytes

to:

[WPA] Compression: 110593119 input bytes, 287696614 uncompressed bytes (ratio: 2.601397)
[WPA] Size of mmap'd section decls: 85628556 bytes
[WPA] Size of mmap'd section function_body: 13842928 bytes

lto-bootstrapped/regtested x86_64-linux, will commit it shortly.

* lto-streamer.h (LTO_tags): Reorder so frequent tags has small indexes;
add LTO_first_tree_tag and LTO_first_gimple_tag.
(lto_tag_is_tree_code_p): Update.
(lto_tag_is_gimple_code_p): Update.
(lto_gimple_code_to_tag): Update.
(lto_tag_to_gimple_code): Update.
(lto_tree_code_to_tag): Update.
(lto_tag_to_tree_code): Update.

gcc/lto-streamer.h

index 241a46d4f316264437543d601dac6dd659db3481..9e0031e5ba3f1a35b8a62f3c76013e3c0dc8b900 100644 (file)
@@ -137,29 +137,43 @@ enum LTO_tags
 {
   LTO_null = 0,
 
-  /* Special for streamer.  Reference to previously-streamed node.  */
+  /* Reference to previously-streamed node.  */
   LTO_tree_pickle_reference,
 
-  /* Reserve enough entries to fit all the tree and gimple codes handled
-     by the streamer.  This guarantees that:
+  /* References to indexable tree nodes.  These objects are stored in
+     tables that are written separately from the function bodies
+     and variable constructors that reference them.  This way they can be
+     instantiated even when the referencing functions aren't (e.g., during WPA)
+     and it also allows functions to be copied from one file to another without
+     having to unpickle the body first (the references are location
+     independent).  */
+  LTO_global_stream_ref,
 
-     1- Given a tree code C:
-               enum LTO_tags tag == C + 1
+  LTO_ssa_name_ref,
 
-     2- Given a gimple code C:
-               enum LTO_tags tag == C + NUM_TREE_CODES + 1
+  /* Special for global streamer.  A blob of unnamed tree nodes.  */
+  LTO_tree_scc,
 
-     Conversely, to map between LTO tags and tree/gimple codes, the
-     reverse operation must be applied.  */
-  LTO_bb0 = 1 + MAX_TREE_CODES + LAST_AND_UNUSED_GIMPLE_CODE,
+  /* Sequence of trees.  */
+  LTO_trees,
+
+  /* Shared INTEGER_CST node.  */
+  LTO_integer_cst,
+
+  /* Tags of trees are encoded as
+     LTO_first_tree_tag + TREE_CODE.  */
+  LTO_first_tree_tag,
+  /* Tags of gimple typles are encoded as
+     LTO_first_gimple_tag + gimple_code.  */
+  LTO_first_gimple_tag = LTO_first_tree_tag + MAX_TREE_CODES,
+
+  /* Entry and exit basic blocks.  */
+  LTO_bb0 = LTO_first_gimple_tag + LAST_AND_UNUSED_GIMPLE_CODE,
   LTO_bb1,
 
   /* EH region holding the previous statement.  */
   LTO_eh_region,
 
-  /* Shared INTEGER_CST node.  */
-  LTO_integer_cst,
-
   /* Function body.  */
   LTO_function,
 
@@ -178,23 +192,6 @@ enum LTO_tags
   /* EH try/catch node.  */
   LTO_eh_catch,
 
-  /* Special for global streamer.  A blob of unnamed tree nodes.  */
-  LTO_tree_scc,
-
-  /* Sequence of trees.  */
-  LTO_trees,
-
-  /* References to indexable tree nodes.  These objects are stored in
-     tables that are written separately from the function bodies
-     and variable constructors that reference them.  This way they can be
-     instantiated even when the referencing functions aren't (e.g., during WPA)
-     and it also allows functions to be copied from one file to another without
-     having to unpickle the body first (the references are location
-     independent).  */
-  LTO_global_stream_ref,
-
-  LTO_ssa_name_ref,
-
   /* This tag must always be last.  */
   LTO_NUM_TAGS
 };
@@ -953,7 +950,7 @@ extern vec<lto_out_decl_state_ptr> lto_function_decl_states;
 static inline bool
 lto_tag_is_tree_code_p (enum LTO_tags tag)
 {
-  return tag > LTO_tree_pickle_reference && (unsigned) tag <= MAX_TREE_CODES;
+  return tag > LTO_first_tree_tag && (unsigned) tag <= MAX_TREE_CODES;
 }
 
 
@@ -961,8 +958,9 @@ lto_tag_is_tree_code_p (enum LTO_tags tag)
 static inline bool
 lto_tag_is_gimple_code_p (enum LTO_tags tag)
 {
-  return (unsigned) tag >= NUM_TREE_CODES + 2
-        && (unsigned) tag < 2 + NUM_TREE_CODES + LAST_AND_UNUSED_GIMPLE_CODE;
+  return (unsigned) tag >= LTO_first_gimple_tag
+        && (unsigned) tag
+           < LTO_first_gimple_tag + LAST_AND_UNUSED_GIMPLE_CODE;
 }
 
 
@@ -971,7 +969,7 @@ lto_tag_is_gimple_code_p (enum LTO_tags tag)
 static inline enum LTO_tags
 lto_gimple_code_to_tag (enum gimple_code code)
 {
-  return (enum LTO_tags) ((unsigned) code + NUM_TREE_CODES + 2);
+  return (enum LTO_tags) ((unsigned) code + LTO_first_gimple_tag);
 }
 
 
@@ -981,7 +979,7 @@ static inline enum gimple_code
 lto_tag_to_gimple_code (enum LTO_tags tag)
 {
   gcc_assert (lto_tag_is_gimple_code_p (tag));
-  return (enum gimple_code) ((unsigned) tag - NUM_TREE_CODES - 2);
+  return (enum gimple_code) ((unsigned) tag - LTO_first_gimple_tag);
 }
 
 
@@ -990,7 +988,7 @@ lto_tag_to_gimple_code (enum LTO_tags tag)
 static inline enum LTO_tags
 lto_tree_code_to_tag (enum tree_code code)
 {
-  return (enum LTO_tags) ((unsigned) code + 2);
+  return (enum LTO_tags) ((unsigned) code + LTO_first_tree_tag);
 }
 
 
@@ -1000,7 +998,7 @@ static inline enum tree_code
 lto_tag_to_tree_code (enum LTO_tags tag)
 {
   gcc_assert (lto_tag_is_tree_code_p (tag));
-  return (enum tree_code) ((unsigned) tag - 2);
+  return (enum tree_code) ((unsigned) tag - LTO_first_tree_tag);
 }
 
 /* Check that tag ACTUAL == EXPECTED.  */
This page took 0.070383 seconds and 5 git commands to generate.