public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH, PR69607] Mark offload symbols as global in lto
@ 2016-02-08 13:01 Tom de Vries
  2016-02-08 14:00 ` Ilya Verbin
  2016-02-17 12:03 ` Tom de Vries
  0 siblings, 2 replies; 8+ messages in thread
From: Tom de Vries @ 2016-02-08 13:01 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: gcc-patches, Ilya Verbin

[-- Attachment #1: Type: text/plain, Size: 734 bytes --]

Hi,

when running libgomp.c testsuite with "-flto -flto-partition=1to1
-fno-toplevel-reorder" we run into many compilation failures like this:
...
/tmp/xxxxxxxx.ltrans0.ltrans.o:(.gnu.offload_funcs+0x1a0): undefined 
reference to `MAIN__._omp_fn.0'^M
...

The problem is that the offload table is in one lto partition, and the 
function listed in the offload table is in another, without the function 
having been promoted to be visible in the other partition.

The patch fixes this by promoting the symbols in the offload table such 
that they're visible in all partitions.

Bootstrapped and reg-tested on x86_64.

Build for nvidia accelerator and reg-tested libgomp with various lto 
settings.

OK for trunk, stage1?

Thanks,
- Tom

[-- Attachment #2: 0005-Mark-offload-symbols-as-global-in-lto.patch --]
[-- Type: text/x-patch, Size: 3256 bytes --]

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(+)

diff --git a/gcc/lto/lto-partition.c b/gcc/lto/lto-partition.c
index 9eb63c2..56598d4 100644
--- a/gcc/lto/lto-partition.c
+++ b/gcc/lto/lto-partition.c
@@ -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
diff --git a/gcc/lto/lto-partition.h b/gcc/lto/lto-partition.h
index 31e3764..1a38126 100644
--- a/gcc/lto/lto-partition.h
+++ b/gcc/lto/lto-partition.h
@@ -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);
diff --git a/gcc/lto/lto.c b/gcc/lto/lto.c
index 6718fbbe..ecec1bc 100644
--- a/gcc/lto/lto.c
+++ b/gcc/lto/lto.c
@@ -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);
diff --git a/libgomp/testsuite/libgomp.c/target-36.c b/libgomp/testsuite/libgomp.c/target-36.c
new file mode 100644
index 0000000..bafb718
--- /dev/null
+++ b/libgomp/testsuite/libgomp.c/target-36.c
@@ -0,0 +1,4 @@
+/* { dg-do run { target lto } } */
+/* { dg-additional-options "-flto -flto-partition=1to1 -fno-toplevel-reorder" } */
+
+#include "target-1.c"

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2016-03-14  6:17 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-02-08 13:01 [PATCH, PR69607] Mark offload symbols as global in lto Tom de Vries
2016-02-08 14:00 ` Ilya Verbin
2016-02-17 12:03 ` Tom de Vries
2016-02-17 12:30   ` Jakub Jelinek
2016-02-17 15:49     ` Tom de Vries
2016-02-24 13:38       ` [PING][PATCH, " Tom de Vries
2016-03-07 14:38         ` [PING^2][PATCH, " Tom de Vries
2016-03-14  6:17           ` [PING^3][PATCH, " Tom de Vries

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).