> This patch adds remapping of node order for each lto partition.
> Resulting order conserves relative order inside partition, but
> is independent of outside symbols. So if lto partition contains
> identical set of symbols, their remapped order will be stable
> between compilations.
>
> gcc/ChangeLog:
>
> * ipa-devirt.cc (ipa_odr_summary_write):
> Add unused argument.
> * ipa-fnsummary.cc (ipa_fn_summary_write): Likewise.
> * ipa-icf.cc (sem_item_optimizer::write_summary): Likewise.
> * ipa-modref.cc (modref_write): Likewise.
> * ipa-prop.cc (ipa_prop_write_jump_functions): Likewise.
> (ipcp_write_transformation_summaries): Likewise.
> * ipa-sra.cc (ipa_sra_write_summary): Likewise.
> * lto-cgraph.cc (lto_symtab_encoder_delete): Delete remap.
> (lto_output_node): Remap order.
> (lto_output_varpool_node): Likewise.
> (output_cgraph_opt_summary): Add unused argument.
> * lto-streamer-out.cc (produce_asm): Use remapped order.
> (output_function): Propagate remapped order.
> (output_constructor): Likewise.
> (copy_function_or_variable): Likewise.
> (cmp_int): New.
> (create_order_remap): New.
> (lto_output): Create remap. Remap order.
> * lto-streamer.h (struct lto_symtab_encoder_d): Remap hash_map.
> (produce_asm): Add order argument.
> ---
> gcc/ipa-devirt.cc | 2 +-
> gcc/ipa-fnsummary.cc | 2 +-
> gcc/ipa-icf.cc | 2 +-
> gcc/ipa-modref.cc | 4 +-
> gcc/ipa-prop.cc | 4 +-
> gcc/ipa-sra.cc | 2 +-
> gcc/lto-cgraph.cc | 10 +++--
> gcc/lto-streamer-out.cc | 84 +++++++++++++++++++++++++++++++++++------
> gcc/lto-streamer.h | 5 ++-
> 9 files changed, 91 insertions(+), 24 deletions(-)
>
> diff --git a/gcc/ipa-devirt.cc b/gcc/ipa-devirt.cc
> index c406e5138db..098798281b7 100644
> --- a/gcc/ipa-devirt.cc
> +++ b/gcc/ipa-devirt.cc
> @@ -4131,7 +4131,7 @@ ipa_odr_summary_write (void)
> odr_enum_map = NULL;
> }
>
> - produce_asm (ob, NULL);
> + produce_asm (ob, NULL, -1);
Arguments of produce_asm seems somewhat magical.
> +/* Compare ints, callback for qsort. */
> +
> +static int
> +cmp_int (const void *a, const void *b)
> +{
> + int ia = *(int const*) a;
> + int ib = *(int const*) b;
> + return ia - ib;
> +}
Given that it is no longer C source, perhaps std::sort would allow doing
this without extra comparator. But I am fine with the function as it is :)
> +extern void produce_asm (struct output_block *ob, tree fn, int output_order);
I would suggest renaming produce_asm to produce_symbol_asm
and making produce_asm wrapper which passes fn=NULL and output_order=-1,
so we do not have odd parameters everywhere in streaming code.
OK with this change.
Honza