aboutsummaryrefslogtreecommitdiff
path: root/gcc/lto
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2020-10-28 10:28:18 +0100
committerJakub Jelinek <jakub@redhat.com>2020-10-28 10:29:09 +0100
commitf165ef89c08ddabb19583e45e8a6819f810d95ab (patch)
tree27d05b9d41f4df1998e9b8e04745d4f32bb7d54a /gcc/lto
parent279a9ce9d545f65a0bb1bc4564abafabfc25f82d (diff)
downloadgcc-f165ef89c08ddabb19583e45e8a6819f810d95ab.zip
gcc-f165ef89c08ddabb19583e45e8a6819f810d95ab.tar.gz
gcc-f165ef89c08ddabb19583e45e8a6819f810d95ab.tar.bz2
lto: LTO cgraph support for late declare variant resolution [PR96680]
> I've tried to add the saving/restoring next to ipa refs saving/restoring, as > the declare variant alt stuff is kind of extension of those, unfortunately > following doesn't compile, because I need to also write or read a tree there > (ctx is a portion of DECL_ATTRIBUTES of the base function), but the ipa refs > write/read back functions don't have arguments that can be used for that. This patch adds the streaming out and in of those omp_declare_variant_alt hash table on the side data for the declare_variant_alt cgraph_nodes and treats for LTO purposes the declare_variant_alt nodes (which have no body) as if they contained a body that calls all the possible variants. After IPA all the calls to these magic declare_variant_alt calls are replaced with call to one of the variant depending on which one has the highest score in the context. 2020-10-28 Jakub Jelinek <jakub@redhat.com> PR lto/96680 gcc/ * lto-streamer.h (omp_lto_output_declare_variant_alt, omp_lto_input_declare_variant_alt): Declare variant. * symtab.c (symtab_node::get_partitioning_class): Return SYMBOL_DUPLICATE for declare_variant_alt nodes. * passes.c (ipa_write_summaries): Add declare_variant_alt to partition. * lto-cgraph.c (output_refs): Call omp_lto_output_declare_variant_alt on declare_variant_alt nodes. (input_refs): Call omp_lto_input_declare_variant_alt on declare_variant_alt nodes. * lto-streamer-out.c (output_function): Don't call collect_block_tree_leafs if DECL_INITIAL is error_mark_node. (lto_output): Call output_function even for declare_variant_alt nodes. * omp-general.c (omp_lto_output_declare_variant_alt, omp_lto_input_declare_variant_alt): New functions. gcc/lto/ * lto-common.c (lto_fixup_prevailing_decls): Don't use LTO_NO_PREVAIL on TREE_LIST's TREE_PURPOSE. * lto-partition.c (lto_balanced_map): Treat declare_variant_alt nodes like definitions. libgomp/ * testsuite/libgomp.c/declare-variant-1.c: New test.
Diffstat (limited to 'gcc/lto')
-rw-r--r--gcc/lto/lto-common.c1
-rw-r--r--gcc/lto/lto-partition.c5
2 files changed, 3 insertions, 3 deletions
diff --git a/gcc/lto/lto-common.c b/gcc/lto/lto-common.c
index 3ca0fd8..6944c46 100644
--- a/gcc/lto/lto-common.c
+++ b/gcc/lto/lto-common.c
@@ -2592,7 +2592,6 @@ lto_fixup_prevailing_decls (tree t)
case TREE_LIST:
LTO_SET_PREVAIL (TREE_VALUE (t));
LTO_SET_PREVAIL (TREE_PURPOSE (t));
- LTO_NO_PREVAIL (TREE_PURPOSE (t));
break;
default:
gcc_unreachable ();
diff --git a/gcc/lto/lto-partition.c b/gcc/lto/lto-partition.c
index 7c15181..cc721f9 100644
--- a/gcc/lto/lto-partition.c
+++ b/gcc/lto/lto-partition.c
@@ -593,7 +593,8 @@ lto_balanced_map (int n_lto_partitions, int max_partition_size)
last_visited_node++;
- gcc_assert (node->definition || node->weakref);
+ gcc_assert (node->definition || node->weakref
+ || node->declare_variant_alt);
/* Compute boundary cost of callgraph edges. */
for (edge = node->callees; edge; edge = edge->next_callee)
@@ -704,7 +705,7 @@ lto_balanced_map (int n_lto_partitions, int max_partition_size)
int index;
node = dyn_cast <cgraph_node *> (ref->referring);
- gcc_assert (node->definition);
+ gcc_assert (node->definition || node->declare_variant_alt);
index = lto_symtab_encoder_lookup (partition->encoder,
node);
if (index != LCC_NOT_FOUND