LTO: Force externally_visible+tree_public for offload_vars/funcs (PR97179) gcc/ChangeLog: PR lto/97179 * lto-cgraph.c (input_offload_tables): diff --git a/gcc/lto/lto-partition.c b/gcc/lto/lto-partition.c index 8e0488a..52f4811 100644 --- a/gcc/lto/lto-partition.c +++ b/gcc/lto/lto-partition.c @@ -35,6 +35,7 @@ along with GCC; see the file COPYING3. If not see #include "ipa-fnsummary.h" #include "lto-partition.h" #include "sreal.h" +#include "omp-offload.h" /* For offload_funcs and offload_vars. */ vec ltrans_partitions; @@ -1120,6 +1121,7 @@ void lto_promote_cross_file_statics (void) { unsigned i, n_sets; + tree decl; gcc_assert (flag_wpa); @@ -1135,6 +1137,20 @@ lto_promote_cross_file_statics (void) part->encoder = compute_ltrans_boundary (part->encoder); } + /* Ensure that all offload table referenced vars/funcs are available. */ + if (offload_funcs) + FOR_EACH_VEC_ELT (*offload_funcs, i, decl) + { + cgraph_node::get (decl)->externally_visible = 1; + TREE_PUBLIC (decl) = 1; + } + if (offload_vars) + FOR_EACH_VEC_ELT (*offload_vars, i, decl) + { + varpool_node::get (decl)->externally_visible = 1; + TREE_PUBLIC (decl) = 1; + } + lto_clone_numbers = new hash_map; /* Look at boundaries and promote symbols as needed. */