Force output of vars with "omp declare target" attribute in gcc/varpool.c
authorIlya Verbin <ilya.verbin@intel.com>
Wed, 10 Dec 2014 20:52:10 +0000 (20:52 +0000)
committerIlya Verbin <iverbin@gcc.gnu.org>
Wed, 10 Dec 2014 20:52:10 +0000 (20:52 +0000)
gcc/
* varpool.c (varpool_node::get_create): Force output of vars with
"omp declare target" attribute.
libgomp/
* testsuite/libgomp.c/target-9.c: New test.

From-SVN: r218607

gcc/ChangeLog
gcc/varpool.c
libgomp/ChangeLog
libgomp/testsuite/libgomp.c/target-9.c [new file with mode: 0644]

index 5ffca8465f6f56cac9bfea574a6cca47577df96f..6befea5041c4c632b43afb1e9845690ae4ed1d97 100644 (file)
@@ -1,3 +1,8 @@
+2014-12-10  Ilya Verbin  <ilya.verbin@intel.com>
+
+       * varpool.c (varpool_node::get_create): Force output of vars with
+       "omp declare target" attribute.
+
 2014-12-10  Marc Glisse  <marc.glisse@inria.fr>
 
        * real.h (HONOR_NANS): Replace macro with 3 overloaded declarations.
index 0526b7f195e5d15a0a8c5e522a99d0fdc481bef5..db28c2acd90cb1a82596c760b0f97a7834370960 100644 (file)
@@ -175,6 +175,7 @@ varpool_node::get_create (tree decl)
       g->have_offload = true;
       if (!in_lto_p)
        vec_safe_push (offload_vars, decl);
+      node->force_output = 1;
 #endif
     }
 
index acf45fb00af8dcb8f89afdc3c5542b815ca8d137..8d8b8d8d6ec215c39d7de181a04fdd42d231a468 100644 (file)
@@ -1,3 +1,7 @@
+2014-12-10  Ilya Verbin  <ilya.verbin@intel.com>
+
+       * testsuite/libgomp.c/target-9.c: New test.
+
 2014-12-09  Varvara Rainchik  <varvara.rainchik@intel.com>
 
        * config.h.in: Regenerate.
diff --git a/libgomp/testsuite/libgomp.c/target-9.c b/libgomp/testsuite/libgomp.c/target-9.c
new file mode 100644 (file)
index 0000000..00fe0cb
--- /dev/null
@@ -0,0 +1,37 @@
+/* { dg-do run } */
+/* { dg-options "-O1" } */
+/* { dg-additional-options "-flto" { target lto } } */
+
+#include <stdlib.h>
+
+#define N 123456
+
+#pragma omp declare target
+int X, Y;
+#pragma omp end declare target
+
+void
+foo ()
+{
+  #pragma omp target map(alloc: X)
+    X = N;
+}
+
+int
+main ()
+{
+  int res;
+
+  foo ();
+
+  #pragma omp target map(alloc: X, Y) map(from: res)
+    {
+      Y = N;
+      res = X + Y;
+    }
+
+  if (res != N + N)
+    abort ();
+
+  return 0;
+}