Mark offload symbols as global in lto
2016-02-08 Tom de Vries <tom@codesourcery.com>
PR lto/69607
* lto-partition.c (promote_offload_tables): New function.
* lto-partition.h (promote_offload_tables): Declare.
* lto.c (do_whole_program_analysis): call promote_offload_tables.
* testsuite/libgomp.c/target-36.c: New test.
---
gcc/lto/lto-partition.c | 28 ++++++++++++++++++++++++++++
gcc/lto/lto-partition.h | 1 +
gcc/lto/lto.c | 2 ++
libgomp/testsuite/libgomp.c/target-36.c | 4 ++++
4 files changed, 35 insertions(+)
@@ -34,6 +34,7 @@ along with GCC; see the file COPYING3. If not see
#include "ipa-prop.h"
#include "ipa-inline.h"
#include "lto-partition.h"
+#include "omp-low.h"
vec<ltrans_partition> ltrans_partitions;
@@ -1003,6 +1004,33 @@ promote_symbol (symtab_node *node)
"Promoting as hidden: %s\n", node->name ());
}
+/* Promote the symbols in the offload tables. */
+
+void
+promote_offload_tables (void)
+{
+ if (vec_safe_is_empty (offload_funcs) && vec_safe_is_empty (offload_vars))
+ return;
+
+ for (unsigned i = 0; i < vec_safe_length (offload_funcs); i++)
+ {
+ tree fn_decl = (*offload_funcs)[i];
+ cgraph_node *node = cgraph_node::get (fn_decl);
+ if (node->externally_visible)
+ continue;
+ promote_symbol (node);
+ }
+
+ for (unsigned i = 0; i < vec_safe_length (offload_vars); i++)
+ {
+ tree var_decl = (*offload_vars)[i];
+ varpool_node *node = varpool_node::get (var_decl);
+ if (node->externally_visible)
+ continue;
+ promote_symbol (node);
+ }
+}
+
/* Return true if NODE needs named section even if it won't land in the partition
symbol table.
FIXME: we should really not use named sections for inline clones and master
@@ -36,6 +36,7 @@ extern vec<ltrans_partition> ltrans_partitions;
void lto_1_to_1_map (void);
void lto_max_map (void);
void lto_balanced_map (int);
+extern void promote_offload_tables (void);
void lto_promote_cross_file_statics (void);
void free_ltrans_partitions (void);
void lto_promote_statics_nonwpa (void);
@@ -3138,6 +3138,8 @@ do_whole_program_analysis (void)
to globals with hidden visibility because they are accessed from multiple
partitions. */
lto_promote_cross_file_statics ();
+ /* Promote all the offload symbols. */
+ promote_offload_tables ();
timevar_pop (TV_WHOPR_PARTITIONING);
timevar_stop (TV_PHASE_OPT_GEN);
new file mode 100644
@@ -0,0 +1,4 @@
+/* { dg-do run { target lto } } */
+/* { dg-additional-options "-flto -flto-partition=1to1 -fno-toplevel-reorder" } */
+
+#include "target-1.c"