]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Structure element mapping for OpenMP 5.0 v3 devel/omp/gcc-10
authorChung-Lin Tang <cltang@codesourcery.com>
Mon, 31 May 2021 13:45:50 +0000 (21:45 +0800)
committerChung-Lin Tang <cltang@codesourcery.com>
Mon, 31 May 2021 14:11:26 +0000 (22:11 +0800)
This is a merge of patch:
https://gcc.gnu.org/pipermail/gcc-patches/2021-May/571515.html

v2 patch already merged at 18dd4f283e15894a26c9a105c4f87d9a585f93c5,
this commit only consists of the v2-to-v3 diff part in above URL.

This v3 adds a small bug fix, where the initialization of the refcount didn't
handle all cases, fixed by using gomp_refcount_increment here (more consistent).

libgomp/ChangeLog:

* target.c (gomp_map_vars_internal): For new key entries, set
k->refcount to 0, remove initialization of k->structelem_refcount,
use gomp_increment_refcount to consistently handle all increment cases.

(manual cherry pick of e7073707bab79ceceaa0e2d25a632d03ac98d0fd)

libgomp/target.c

index 500631e01516282485e00721c9134c4f3da3d7e6..2f9e4120aae61bd05a80f53b0bfe4043848d933b 100644 (file)
@@ -1559,7 +1559,7 @@ gomp_map_vars_internal (struct gomp_device_descr *devicep,
                size_t align = (size_t) 1 << (kind >> rshift);
                tgt->list[i].key = k;
                k->tgt = tgt;
-               k->refcount = 1;
+               k->refcount = 0;
                k->dynamic_refcount = 0;
                if (field_tgt_clear != FIELD_TGT_EMPTY)
                  {
@@ -1572,7 +1572,6 @@ gomp_map_vars_internal (struct gomp_device_descr *devicep,
                          {
                            /* Set to first structure element of sequence.  */
                            k->refcount |= REFCOUNT_STRUCTELEM_FLAG_FIRST;
-                           k->structelem_refcount = 1;
                            field_tgt_structelem_first = k;
                          }
                        else
@@ -1596,6 +1595,11 @@ gomp_map_vars_internal (struct gomp_device_descr *devicep,
                    k->tgt_offset = tgt_size;
                    tgt_size += k->host_end - k->host_start;
                  }
+               /* First increment, from 0 to 1. gomp_increment_refcount
+                  encapsulates the different increment cases, so use this
+                  instead of directly setting 1 during initialization.  */
+               gomp_increment_refcount (k, refcount_set);
+
                tgt->list[i].copy_from = GOMP_MAP_COPY_FROM_P (kind & typemask);
                tgt->list[i].always_copy_from
                  = GOMP_MAP_ALWAYS_FROM_P (kind & typemask);