[hsa] Set program allocation for static local variables
authorMartin Jambor <mjambor@suse.cz>
Thu, 8 Feb 2018 13:03:52 +0000 (14:03 +0100)
committerMartin Jambor <jamborm@gcc.gnu.org>
Thu, 8 Feb 2018 13:03:52 +0000 (14:03 +0100)
2018-02-08  Martin Jambor  <mjambor@suse.cz>

* hsa-gen.c (get_symbol_for_decl): Set program allocation for
static local variables.

libgomp/
* testsuite/libgomp.hsa.c/staticvar.c: New test.

From-SVN: r257484

gcc/ChangeLog
gcc/hsa-gen.c
libgomp/ChangeLog
libgomp/testsuite/libgomp.hsa.c/staticvar.c [new file with mode: 0644]

index 4d65b9435a58853b9d1c053de75a2ede872358f4..770d408fa16387c52e803170a5c476745d661365 100644 (file)
@@ -1,3 +1,8 @@
+2018-02-08  Martin Jambor  <mjambor@suse.cz>
+
+       * hsa-gen.c (get_symbol_for_decl): Set program allocation for
+       static local variables.
+
 2018-02-08  Richard Biener  <rguenther@suse.de>
 
        PR tree-optimization/84278
index af0b33d658fb51ee9d2687c1f9445d4050535a81..55a46b5a16ac2219c5863cee21ec1b2fe84b4702 100644 (file)
@@ -932,9 +932,13 @@ get_symbol_for_decl (tree decl)
          else if (lookup_attribute ("hsa_group_segment",
                                     DECL_ATTRIBUTES (decl)))
            segment = BRIG_SEGMENT_GROUP;
-         else if (TREE_STATIC (decl)
-                  || lookup_attribute ("hsa_global_segment",
-                                       DECL_ATTRIBUTES (decl)))
+         else if (TREE_STATIC (decl))
+           {
+             segment = BRIG_SEGMENT_GLOBAL;
+             allocation = BRIG_ALLOCATION_PROGRAM;
+           }
+         else if (lookup_attribute ("hsa_global_segment",
+                                    DECL_ATTRIBUTES (decl)))
            segment = BRIG_SEGMENT_GLOBAL;
          else
            segment = BRIG_SEGMENT_PRIVATE;
index df8a57d6ab15b22f254ed0f4661598f64c197f66..d0130490de3026f924f470604f90931b437e8efa 100644 (file)
@@ -1,3 +1,7 @@
+2018-02-08  Martin Jambor  <mjambor@suse.cz>
+
+       * testsuite/libgomp.hsa.c/staticvar.c: New test.
+
 2018-02-07  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>
 
        * testsuite/libgomp.oacc-c-c++-common/pr84217.c (abort)
diff --git a/libgomp/testsuite/libgomp.hsa.c/staticvar.c b/libgomp/testsuite/libgomp.hsa.c/staticvar.c
new file mode 100644 (file)
index 0000000..6d20c9a
--- /dev/null
@@ -0,0 +1,23 @@
+extern void abort (void);
+
+#pragma omp declare target
+int
+foo (void)
+{
+  static int s;
+  return ++s;
+}
+#pragma omp end declare target
+
+int
+main ()
+{
+  int r;
+  #pragma omp target map(from:r)
+  {
+    r = foo ();
+  }
+  if (r != 1)
+    abort ();
+  return 0;
+}