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
This commit is contained in:
Alexandre Oliva 2018-07-31 21:19:25 +00:00 committed by Alexandre Oliva
parent fa6fd7b7af
commit b348c78aa4
6 changed files with 33 additions and 1 deletions

View file

@ -1,3 +1,13 @@
2018-07-31 Alexandre Oliva <oliva@adacore.com>
* 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 <oliva@adacore.com>
Olivier Hainque <hainque@adacore.com>

View file

@ -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;

View file

@ -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)

View file

@ -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))
{

View file

@ -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);
}
}

View file

@ -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);
}