openmp: Fix up omp_check_private [PR101535]
authorJakub Jelinek <jakub@redhat.com>
Wed, 21 Jul 2021 07:45:02 +0000 (09:45 +0200)
committerJakub Jelinek <jakub@redhat.com>
Wed, 21 Jul 2021 07:45:02 +0000 (09:45 +0200)
commitb136b7a78774107943fe94051c42b5a968a3ad3f
tree5a2005a076ba43bd889ccee9f6a536ce08b5eda7
parentaea199f96cf116ba4c81426207acde371556610c
openmp: Fix up omp_check_private [PR101535]

The target data construct shouldn't affect omp_check_private, unless
the decl there is privatized (use_device_* clauses).  The routine
had some code for that, but it just did continue; in a loop that looped
only if the region type is one of selected 4 kinds, so effectively resulted
in return false; instead of looping again.  And not diagnosing lastprivate
(or reduction etc.) on a variable that is private to containing parallel
results in ICEs later on, as there is no original list item to which store
the last result.
The target construct is unclear as it has an implicit parallel region
and it is not obvious if the data privatization clauses on the construct
shall be treated as data privatization on the implicit parallel or just
on the target.  For now treat those as privatization on the implicit
parallel, but treat map clauses as shared on the implicit parallel.

2021-07-21  Jakub Jelinek  <jakub@redhat.com>

PR middle-end/101535
* gimplify.c (omp_check_private): Properly skip ORT_TARGET_DATA
contexts in which decl isn't privatized and for ORT_TARGET return
false if decl is mapped.

* c-c++-common/gomp/pr101535-1.c: New test.
* c-c++-common/gomp/pr101535-2.c: New test.
gcc/gimplify.c
gcc/testsuite/c-c++-common/gomp/pr101535-1.c [new file with mode: 0644]
gcc/testsuite/c-c++-common/gomp/pr101535-2.c [new file with mode: 0644]