This prepares for the LTO type merging re-org by pushing bugfixes I noticed when implementing the rewrite to trunk. It also adds counting of the number of merged types so we can easily compare the results.
LTO bootstrapped and tested on x86_64-unknown-linux-gnu, applied. Richard. 2013-06-05 Richard Biener <rguent...@suse.de> * tree-streamer.c (streamer_tree_cache_insert_1): Update the index associated with the tree we are supposed to replace. * tree-streamer-out.c (pack_ts_base_value_fields): Output TREE_ASM_WRITTEN as zero for everything but SSA names. lto/ * lto.c (num_merged_types): New global variable. (uniquify_nodes): Increase num_merged_types when merging a type. (print_lto_report_1): Output the number of merged types. Index: gcc/tree-streamer.c =================================================================== *** gcc/tree-streamer.c (revision 199650) --- gcc/tree-streamer.c (working copy) *************** streamer_tree_cache_insert_1 (struct str *** 152,157 **** --- 152,158 ---- the requested location slot. */ ix = *ix_p; streamer_tree_cache_add_to_node_array (cache, ix, t); + *slot = (void *)(size_t) (ix + 1); } /* Indicate that T was already in the cache. */ Index: gcc/tree-streamer-out.c =================================================================== *** gcc/tree-streamer-out.c (revision 199650) --- gcc/tree-streamer-out.c (working copy) *************** pack_ts_base_value_fields (struct bitpac *** 87,94 **** bp_pack_value (bp, TYPE_UNSIGNED (expr), 1); else bp_pack_value (bp, 0, 1); ! /* We write debug info two times, do not confuse the second one. */ ! bp_pack_value (bp, ((TYPE_P (expr) || TREE_CODE (expr) == TYPE_DECL) ? 0 : TREE_ASM_WRITTEN (expr)), 1); if (TYPE_P (expr)) bp_pack_value (bp, TYPE_ARTIFICIAL (expr), 1); --- 87,95 ---- bp_pack_value (bp, TYPE_UNSIGNED (expr), 1); else bp_pack_value (bp, 0, 1); ! /* We write debug info two times, do not confuse the second one. ! The only relevant TREE_ASM_WRITTEN use is on SSA names. */ ! bp_pack_value (bp, (TREE_CODE (expr) != SSA_NAME ? 0 : TREE_ASM_WRITTEN (expr)), 1); if (TYPE_P (expr)) bp_pack_value (bp, TYPE_ARTIFICIAL (expr), 1); Index: gcc/lto/lto.c =================================================================== *** gcc/lto/lto.c (revision 199650) --- gcc/lto/lto.c (working copy) *************** lto_register_function_decl_in_symtab (st *** 1788,1793 **** --- 1788,1794 ---- } } + static unsigned long num_merged_types = 0; /* Given a streamer cache structure DATA_IN (holding a sequence of trees for one compilation unit) go over all trees starting at index FROM until the *************** uniquify_nodes (struct data_in *data_in, *** 1817,1823 **** to reset that flag afterwards - nothing that refers to those types is left and they are collected. */ if (newt != t) ! TREE_VISITED (t) = 1; } } --- 1818,1827 ---- to reset that flag afterwards - nothing that refers to those types is left and they are collected. */ if (newt != t) ! { ! num_merged_types++; ! TREE_VISITED (t) = 1; ! } } } *************** print_lto_report_1 (void) *** 3136,3141 **** --- 3140,3146 ---- htab_collisions (type_hash_cache)); else fprintf (stderr, "[%s] GIMPLE type hash cache table is empty\n", pfx); + fprintf (stderr, "[%s] Merged %lu types\n", pfx, num_merged_types); print_gimple_types_stats (pfx); print_lto_report (pfx);