Check that must_remain_in_tu is partitioned correctly, and that
refereced_from_asm is not renamed.
gcc/lto/ChangeLog:
* lto-partition.cc (lto_1_to_1_map): must_remain_in_tu check.
(privatize_symbol_name_1): refereced_from_asm check.
---
gcc/lto/lto-partition.cc | 43 ++++++++++++++++++++++++++++++++++++++++
1 file changed, 43 insertions(+)
diff --git a/gcc/lto/lto-partition.cc b/gcc/lto/lto-partition.cc
index b87ca440bc9..484a9ea9d94 100644
--- a/gcc/lto/lto-partition.cc
+++ b/gcc/lto/lto-partition.cc
@@ -393,6 +393,42 @@ lto_1_to_1_map (void)
/* Order partitions by order of symbols because they are linked into binary
that way. */
ltrans_partitions.qsort (cmp_partitions_order);
+
+ /* Check that symbols with must_remain_in_tu are partitioned correctly. */
+ if (flag_checking)
+ {
+ unsigned partitions = ltrans_partitions.length ();
+ for (unsigned i = 0; i < partitions ; i++)
+ {
+ ltrans_partition p = ltrans_partitions[i];
+ lto_symtab_encoder_iterator lsei;
+ for (lsei = lsei_start_in_partition (p->encoder);
+ !lsei_end_p (lsei);
+ lsei_next_in_partition (&lsei))
+ {
+ symtab_node *node = dyn_cast<symtab_node*> (lsei_node (lsei));
+ if (!node)
+ continue;
+ if (!node->must_remain_in_tu)
+ continue;
+ if (!lto_symtab_encoder_in_partition_p (p->encoder, node))
+ continue;
+ if (node->asm_name ()[0] == '*')
+ continue;
+ if (!node->lto_file_data)
+ continue;
+
+ ltrans_partition *slot = pmap.get (node->lto_file_data);
+ if (!slot || *(slot) != p)
+ {
+ const char* fname = node->lto_file_data->file_name;
+ fatal_error (input_location, "Symbol %s from file %s"
+ "cannot be in partition %s",
+ node->asm_name (), fname, p->name);
+ }
+ }
+ }
+ }
}
/* Creates partition with all toplevel assembly.
@@ -1691,6 +1727,13 @@ privatize_symbol_name_1 (symtab_node *node, tree decl)
if (must_not_rename (node, name0))
return false;
+ if (node->referenced_from_asm)
+ {
+ /* Symbols referenced from asm should not change their name. */
+ fatal_error (input_location, "Tried to privatize symbol %s.",
+ node->asm_name ());
+ }
+
const char *name = maybe_rewrite_identifier (name0);
unsigned &clone_number = lto_clone_numbers->get_or_insert (name);
symtab->change_decl_assembler_name (decl,
--
2.50.0