From b348c78aa4ab72ea533a01ad24311f45b0b4f4cb Mon Sep 17 00:00:00 2001 From: Alexandre Oliva Date: Tue, 31 Jul 2018 21:19:25 +0000 Subject: [PATCH] Save discriminator info for LTO for gcc/ChangeLog * gimple-streamer-in.c (input_bb): Restore BB discriminator. * gimple-streamer-out.c (output_bb): Save it. * lto-streamer-in.c (input_struct_function_base): Restore instance discriminator if available. Create map on demand. * lto-streamer-out.c (output_struct_function_base): Save it if available. * final.c (decl_to_instance_map): Document LTO strategy. From-SVN: r263183 --- gcc/ChangeLog | 10 ++++++++++ gcc/final.c | 6 +++++- gcc/gimple-streamer-in.c | 1 + gcc/gimple-streamer-out.c | 1 + gcc/lto-streamer-in.c | 8 ++++++++ gcc/lto-streamer-out.c | 8 ++++++++ 6 files changed, 33 insertions(+), 1 deletion(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 4eda71bca0f..9b0ccfdaf31 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,13 @@ +2018-07-31 Alexandre Oliva + + * gimple-streamer-in.c (input_bb): Restore BB discriminator. + * gimple-streamer-out.c (output_bb): Save it. + * lto-streamer-in.c (input_struct_function_base): Restore + instance discriminator if available. Create map on demand. + * lto-streamer-out.c (output_struct_function_base): Save it if + available. + * final.c (decl_to_instance_map): Document LTO strategy. + 2018-07-31 Alexandre Oliva Olivier Hainque diff --git a/gcc/final.c b/gcc/final.c index a8338e0394c..842e5e067db 100644 --- a/gcc/final.c +++ b/gcc/final.c @@ -3154,7 +3154,11 @@ final_scan_insn (rtx_insn *insn, FILE *file, int optimize_p, /* Map DECLs to instance discriminators. This is allocated and - defined in ada/gcc-interfaces/trans.c, when compiling with -gnateS. */ + defined in ada/gcc-interfaces/trans.c, when compiling with -gnateS. + Mappings from this table are saved and restored for LTO, so + link-time compilation will have this map set, at least in + partitions containing at least one DECL with an associated instance + discriminator. */ decl_to_instance_map_t *decl_to_instance_map; diff --git a/gcc/gimple-streamer-in.c b/gcc/gimple-streamer-in.c index 6ffef29bf1f..31ba4cc4e00 100644 --- a/gcc/gimple-streamer-in.c +++ b/gcc/gimple-streamer-in.c @@ -270,6 +270,7 @@ input_bb (struct lto_input_block *ib, enum LTO_tags tag, bb->count = bb->count.apply_scale (count_materialization_scale, REG_BR_PROB_BASE); bb->flags = streamer_read_hwi (ib); + bb->discriminator = streamer_read_hwi (ib); /* LTO_bb1 has statements. LTO_bb0 does not. */ if (tag == LTO_bb0) diff --git a/gcc/gimple-streamer-out.c b/gcc/gimple-streamer-out.c index d120aa90295..3a2368047cc 100644 --- a/gcc/gimple-streamer-out.c +++ b/gcc/gimple-streamer-out.c @@ -212,6 +212,7 @@ output_bb (struct output_block *ob, basic_block bb, struct function *fn) streamer_write_uhwi (ob, bb->index); bb->count.stream_out (ob); streamer_write_hwi (ob, bb->flags); + streamer_write_hwi (ob, bb->discriminator); if (!gsi_end_p (bsi) || phi_nodes (bb)) { diff --git a/gcc/lto-streamer-in.c b/gcc/lto-streamer-in.c index 8529c82376b..4ddcc8f7ddd 100644 --- a/gcc/lto-streamer-in.c +++ b/gcc/lto-streamer-in.c @@ -1013,6 +1013,14 @@ input_struct_function_base (struct function *fn, struct data_in *data_in, /* Input the function start and end loci. */ fn->function_start_locus = stream_input_location_now (&bp, data_in); fn->function_end_locus = stream_input_location_now (&bp, data_in); + + /* Restore the instance discriminators if present. */ + int instance_number = bp_unpack_value (&bp, 1); + if (instance_number) + { + instance_number = bp_unpack_value (&bp, sizeof (int) * CHAR_BIT); + maybe_create_decl_to_instance_map ()->put (fn->decl, instance_number); + } } diff --git a/gcc/lto-streamer-out.c b/gcc/lto-streamer-out.c index 78b90e7f596..9e28d678342 100644 --- a/gcc/lto-streamer-out.c +++ b/gcc/lto-streamer-out.c @@ -2038,6 +2038,14 @@ output_struct_function_base (struct output_block *ob, struct function *fn) stream_output_location (ob, &bp, fn->function_start_locus); stream_output_location (ob, &bp, fn->function_end_locus); + /* Save the instance discriminator if present. */ + int *instance_number_p = NULL; + if (decl_to_instance_map) + instance_number_p = decl_to_instance_map->get (fn->decl); + bp_pack_value (&bp, !!instance_number_p, 1); + if (instance_number_p) + bp_pack_value (&bp, *instance_number_p, sizeof (int) * CHAR_BIT); + streamer_write_bitpack (&bp); } -- 2.30.2