+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>
\f
/* 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;
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)
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))
{
/* 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);
+ }
}
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);
}