This moves TRANSLATION_UNIT_LANGUAGE to the bitpack section. LTO bootstrapped and tested on x86_64-unknown-linux-gnu.
Richard. 2012-10-15 Richard Biener <rguent...@suse.de> * data-streamer.h (bp_pack_string_with_length): New function. (bp_pack_string): Likewise. (bp_unpack_indexed_string): Likewise. (bp_unpack_string): Likewise. * data-streamer-out.c (bp_pack_string_with_length): Likewise. (bp_pack_string): Likewise. * data-streamer-in.c (bp_unpack_indexed_string): Likewise. (bp_unpack_string): Likewise. * tree-streamer-out.c (pack_ts_translation_unit_decl_value_fields): Pack TRANSLATION_UNIT_LANGUAGE here, not ... (write_ts_translation_unit_decl_tree_pointers): ... here. Remove. (streamer_pack_tree_bitfields): Adjust. (streamer_write_tree_body): Likewise. * tree-streamer-in.c (unpack_ts_translation_unit_decl_value_fields): Unpack TRANSLATION_UNIT_LANGUAGE here, not ... (lto_input_ts_translation_unit_decl_tree_pointers): ... here. Remove. (unpack_value_fields): Adjust. (streamer_read_tree_body): Likewise. Index: gcc/data-streamer.h =================================================================== *** gcc/data-streamer.h (revision 192451) --- gcc/data-streamer.h (working copy) *************** unsigned streamer_string_index (struct o *** 72,77 **** --- 72,81 ---- void streamer_write_string_with_length (struct output_block *, struct lto_output_stream *, const char *, unsigned int, bool); + void bp_pack_string_with_length (struct output_block *, struct bitpack_d *, + const char *, unsigned int, bool); + void bp_pack_string (struct output_block *, struct bitpack_d *, + const char *, bool); void streamer_write_uhwi_stream (struct lto_output_stream *, unsigned HOST_WIDE_INT); void streamer_write_hwi_stream (struct lto_output_stream *, HOST_WIDE_INT); *************** const char *streamer_read_string (struct *** 82,87 **** --- 86,94 ---- const char *streamer_read_indexed_string (struct data_in *, struct lto_input_block *, unsigned int *); + const char *bp_unpack_indexed_string (struct data_in *, struct bitpack_d *, + unsigned int *); + const char *bp_unpack_string (struct data_in *, struct bitpack_d *); unsigned HOST_WIDE_INT streamer_read_uhwi (struct lto_input_block *); HOST_WIDE_INT streamer_read_hwi (struct lto_input_block *); Index: gcc/data-streamer-out.c =================================================================== *** gcc/data-streamer-out.c (revision 192451) --- gcc/data-streamer-out.c (working copy) *************** streamer_write_string (struct output_blo *** 115,120 **** --- 115,153 ---- } + /* Output STRING of LEN characters to the string table in OB. Then + put the index into BP. + When PERSISTENT is set, the string S is supposed to not change during + duration of the OB and thus OB can keep pointer into it. */ + + void + bp_pack_string_with_length (struct output_block *ob, struct bitpack_d *bp, + const char *s, unsigned int len, bool persistent) + { + unsigned index = 0; + if (s) + index = streamer_string_index (ob, s, len, persistent); + bp_pack_var_len_unsigned (bp, index); + } + + + /* Output the '\0' terminated STRING to the string + table in OB. Then put the index onto the bitpack BP. + When PERSISTENT is set, the string S is supposed to not change during + duration of the OB and thus OB can keep pointer into it. */ + + void + bp_pack_string (struct output_block *ob, struct bitpack_d *bp, + const char *s, bool persistent) + { + unsigned index = 0; + if (s) + index = streamer_string_index (ob, s, strlen (s) + 1, persistent); + bp_pack_var_len_unsigned (bp, index); + } + + + /* Write a zero to the output stream. */ void Index: gcc/data-streamer-in.c =================================================================== *** gcc/data-streamer-in.c (revision 192451) --- gcc/data-streamer-in.c (working copy) *************** streamer_read_string (struct data_in *da *** 86,91 **** --- 86,120 ---- } + /* Read a string from the string table in DATA_IN using the bitpack BP. + Write the length to RLEN. */ + + const char * + bp_unpack_indexed_string (struct data_in *data_in, + struct bitpack_d *bp, unsigned int *rlen) + { + return string_for_index (data_in, bp_unpack_var_len_unsigned (bp), rlen); + } + + + /* Read a NULL terminated string from the string table in DATA_IN. */ + + const char * + bp_unpack_string (struct data_in *data_in, struct bitpack_d *bp) + { + unsigned int len; + const char *ptr; + + ptr = bp_unpack_indexed_string (data_in, bp, &len); + if (!ptr) + return NULL; + if (ptr[len - 1] != '\0') + internal_error ("bytecode stream: found non-null terminated string"); + + return ptr; + } + + /* Read an unsigned HOST_WIDE_INT number from IB. */ unsigned HOST_WIDE_INT Index: gcc/tree-streamer-out.c =================================================================== *** gcc/tree-streamer-out.c (revision 192451) --- gcc/tree-streamer-out.c (working copy) *************** pack_ts_block_value_fields (struct outpu *** 316,323 **** of expression EXPR into bitpack BP. */ static void ! pack_ts_translation_unit_decl_value_fields (struct bitpack_d *bp ATTRIBUTE_UNUSED, tree expr ATTRIBUTE_UNUSED) { } /* Pack a TS_TARGET_OPTION tree in EXPR to BP. */ --- 316,325 ---- of expression EXPR into bitpack BP. */ static void ! pack_ts_translation_unit_decl_value_fields (struct output_block *ob, ! struct bitpack_d *bp, tree expr) { + bp_pack_string (ob, bp, TRANSLATION_UNIT_LANGUAGE (expr), true); } /* Pack a TS_TARGET_OPTION tree in EXPR to BP. */ *************** streamer_pack_tree_bitfields (struct out *** 402,408 **** pack_ts_block_value_fields (ob, bp, expr); if (CODE_CONTAINS_STRUCT (code, TS_TRANSLATION_UNIT_DECL)) ! pack_ts_translation_unit_decl_value_fields (bp, expr); if (CODE_CONTAINS_STRUCT (code, TS_TARGET_OPTION)) pack_ts_target_option (bp, expr); --- 404,410 ---- pack_ts_block_value_fields (ob, bp, expr); if (CODE_CONTAINS_STRUCT (code, TS_TRANSLATION_UNIT_DECL)) ! pack_ts_translation_unit_decl_value_fields (ob, bp, expr); if (CODE_CONTAINS_STRUCT (code, TS_TARGET_OPTION)) pack_ts_target_option (bp, expr); *************** write_ts_constructor_tree_pointers (stru *** 819,834 **** } } - /* Write a TS_TRANSLATION_UNIT_DECL tree in EXPR to OB. */ - - static void - write_ts_translation_unit_decl_tree_pointers (struct output_block *ob, - tree expr) - { - streamer_write_string (ob, ob->main_stream, - TRANSLATION_UNIT_LANGUAGE (expr), true); - } - /* Write all pointer fields in EXPR to output block OB. If REF_P is true, the leaves of EXPR are emitted as references. */ --- 821,826 ---- *************** streamer_write_tree_body (struct output_ *** 889,897 **** if (CODE_CONTAINS_STRUCT (code, TS_CONSTRUCTOR)) write_ts_constructor_tree_pointers (ob, expr, ref_p); - - if (CODE_CONTAINS_STRUCT (code, TS_TRANSLATION_UNIT_DECL)) - write_ts_translation_unit_decl_tree_pointers (ob, expr); } --- 881,886 ---- Index: gcc/tree-streamer-in.c =================================================================== *** gcc/tree-streamer-in.c (revision 192451) --- gcc/tree-streamer-in.c (working copy) *************** unpack_ts_block_value_fields (struct dat *** 365,372 **** structure of expression EXPR from bitpack BP. */ static void ! unpack_ts_translation_unit_decl_value_fields (struct bitpack_d *bp ATTRIBUTE_UNUSED, tree expr ATTRIBUTE_UNUSED) { } /* Unpack a TS_TARGET_OPTION tree from BP into EXPR. */ --- 365,375 ---- structure of expression EXPR from bitpack BP. */ static void ! unpack_ts_translation_unit_decl_value_fields (struct data_in *data_in, ! struct bitpack_d *bp, tree expr) { + TRANSLATION_UNIT_LANGUAGE (expr) = xstrdup (bp_unpack_string (data_in, bp)); + VEC_safe_push (tree, gc, all_translation_units, expr); } /* Unpack a TS_TARGET_OPTION tree from BP into EXPR. */ *************** unpack_value_fields (struct data_in *dat *** 444,450 **** unpack_ts_block_value_fields (data_in, bp, expr); if (CODE_CONTAINS_STRUCT (code, TS_TRANSLATION_UNIT_DECL)) ! unpack_ts_translation_unit_decl_value_fields (bp, expr); if (CODE_CONTAINS_STRUCT (code, TS_TARGET_OPTION)) unpack_ts_target_option (bp, expr); --- 447,453 ---- unpack_ts_block_value_fields (data_in, bp, expr); if (CODE_CONTAINS_STRUCT (code, TS_TRANSLATION_UNIT_DECL)) ! unpack_ts_translation_unit_decl_value_fields (data_in, bp, expr); if (CODE_CONTAINS_STRUCT (code, TS_TARGET_OPTION)) unpack_ts_target_option (bp, expr); *************** lto_input_ts_constructor_tree_pointers ( *** 942,958 **** } - /* Input a TS_TRANSLATION_UNIT_DECL tree from IB and DATA_IN into EXPR. */ - - static void - lto_input_ts_translation_unit_decl_tree_pointers (struct lto_input_block *ib, - struct data_in *data_in, - tree expr) - { - TRANSLATION_UNIT_LANGUAGE (expr) = xstrdup (streamer_read_string (data_in, ib)); - VEC_safe_push (tree, gc, all_translation_units, expr); - } - /* Read all pointer fields in EXPR from input block IB. DATA_IN contains tables and descriptors for the file being read. */ --- 945,950 ---- *************** streamer_read_tree_body (struct lto_inpu *** 1014,1022 **** if (CODE_CONTAINS_STRUCT (code, TS_CONSTRUCTOR)) lto_input_ts_constructor_tree_pointers (ib, data_in, expr); - - if (CODE_CONTAINS_STRUCT (code, TS_TRANSLATION_UNIT_DECL)) - lto_input_ts_translation_unit_decl_tree_pointers (ib, data_in, expr); } --- 1006,1011 ----