Simplify tree streaming.
this patch cleans up tree streaming. The code is prepared to stream nested
trees, but we only handle flat trees. As a result we have quite heavy function
to stream in/out tree reference which is used many times and shows up in
profile.
This patch adds stream_write_tree_ref/stream_read_tree_ref which is used to
stream references to trees that are required to exist in the cache or be
indexable.
The actual implementation is just a first cut. I would like to make it more
compact. We used to stream 2 byte tag (as UHWI) + UHWI representing the index.
Now we stream one UHWI that represent type of reference + index for references
to cache, but still two integers for references to global stream. This is
becaue the abstraction is not very helpful here and I want to clean this up
incrementally.
I would also like to get rid of the ref_p parameters which seems unnecessary for
flat streams.
This reduces around 7% of global stream, 3% when compressed.
More reduction will happen once the format is sanitized a bit.
from
[WPA] read
4597161 unshared trees
[WPA] read
2937414 mergeable SCCs of average size 1.364280
[WPA]
8604617 tree bodies read in total
[WPA] tree SCC table: size 524287, 247507 elements, collision ratio: 0.377468
[WPA] tree SCC max chain length 2 (size 1)
[WPA] Compared
2689907 SCCs, 184 collisions (0.000068)
[WPA] Merged
2689890 SCCs
[WPA] Merged
3722677 tree bodies
[WPA] Merged 632040 types
...
[WPA] Compression:
88124141 input bytes,
234906430 uncompressed bytes (ratio: 2.665631)
[WPA] Size of mmap'd section decls:
88124141 bytes
...
[WPA] Compression:
113758813 input bytes,
316149514 uncompressed bytes (ratio: 2.779121)
[WPA] Size of mmap'd section decls:
88124141 bytes
[WPA] Size of mmap'd section function_body:
14485721 bytes
to
[WPA] read
4597174 unshared trees
[WPA] read
2937413 mergeable SCCs of average size 1.364280
[WPA]
8604629 tree bodies read in total
[WPA] tree SCC table: size 524287, 247509 elements, collision ratio: 0.377458
[WPA] tree SCC max chain length 2 (size 1)
[WPA] Compared
2689904 SCCs, 183 collisions (0.000068)
[WPA] Merged
2689888 SCCs
[WPA] Merged
3722675 tree bodies
[WPA] Merged 632041 types
....
[WPA] Size of mmap'd section decls:
86177293 bytes
[WPA] Compression:
86177293 input bytes,
217625095 uncompressed bytes (ratio: 2.525318)
....
[WPA] Compression:
111682269 input bytes,
297228756 uncompressed bytes (ratio: 2.661378)
[WPA] Size of mmap'd section decls:
86177293 bytes
[WPA] Size of mmap'd section function_body:
14349032 bytes
gcc/ChangeLog:
* lto-streamer-in.c (streamer_read_chain): Move here from
tree-streamer-in.c.
(stream_read_tree_ref): New.
(lto_input_tree_1): Simplify.
* lto-streamer-out.c (stream_write_tree_ref): New.
(lto_write_tree_1): Simplify.
(lto_output_tree_1): Simplify.
(DFS::DFS_write_tree): Simplify.
(streamer_write_chain): Move here from tree-stremaer-out.c.
* lto-streamer.h (lto_output_tree_ref): Update prototype.
(stream_read_tree_ref): Declare
(stream_write_tree_ref): Declare
* tree-streamer-in.c (streamer_read_chain): Update to use
stream_read_tree_ref.
(lto_input_ts_common_tree_pointers): Likewise.
(lto_input_ts_vector_tree_pointers): Likewise.
(lto_input_ts_poly_tree_pointers): Likewise.
(lto_input_ts_complex_tree_pointers): Likewise.
(lto_input_ts_decl_minimal_tree_pointers): Likewise.
(lto_input_ts_decl_common_tree_pointers): Likewise.
(lto_input_ts_decl_with_vis_tree_pointers): Likewise.
(lto_input_ts_field_decl_tree_pointers): Likewise.
(lto_input_ts_function_decl_tree_pointers): Likewise.
(lto_input_ts_type_common_tree_pointers): Likewise.
(lto_input_ts_type_non_common_tree_pointers): Likewise.
(lto_input_ts_list_tree_pointers): Likewise.
(lto_input_ts_vec_tree_pointers): Likewise.
(lto_input_ts_exp_tree_pointers): Likewise.
(lto_input_ts_block_tree_pointers): Likewise.
(lto_input_ts_binfo_tree_pointers): Likewise.
(lto_input_ts_constructor_tree_pointers): Likewise.
(lto_input_ts_omp_clause_tree_pointers): Likewise.
* tree-streamer-out.c (streamer_write_chain): Update to use
stream_write_tree_ref.
(write_ts_common_tree_pointers): Likewise.
(write_ts_vector_tree_pointers): Likewise.
(write_ts_poly_tree_pointers): Likewise.
(write_ts_complex_tree_pointers): Likewise.
(write_ts_decl_minimal_tree_pointers): Likewise.
(write_ts_decl_common_tree_pointers): Likewise.
(write_ts_decl_non_common_tree_pointers): Likewise.
(write_ts_decl_with_vis_tree_pointers): Likewise.
(write_ts_field_decl_tree_pointers): Likewise.
(write_ts_function_decl_tree_pointers): Likewise.
(write_ts_type_common_tree_pointers): Likewise.
(write_ts_type_non_common_tree_pointers): Likewise.
(write_ts_list_tree_pointers): Likewise.
(write_ts_vec_tree_pointers): Likewise.
(write_ts_exp_tree_pointers): Likewise.
(write_ts_block_tree_pointers): Likewise.
(write_ts_binfo_tree_pointers): Likewise.
(write_ts_constructor_tree_pointers): Likewise.
(write_ts_omp_clause_tree_pointers): Likewise.
(streamer_write_tree_body): Likewise.
(streamer_write_integer_cst): Likewise.
* tree-streamer.h (streamer_read_chain):Declare.
(streamer_write_chain):Declare.
(streamer_write_tree_body): Update prototype.
(streamer_write_integer_cst): Update prototype.