]> git.ipfire.org Git - thirdparty/gcc.git/commit
OpenMP/C++: Fix (first)private clause with member variables [PR110347]
authorJakub Jelinek <jakub@redhat.com>
Mon, 4 Mar 2024 11:55:27 +0000 (12:55 +0100)
committerTobias Burnus <tburnus@baylibre.com>
Mon, 4 Mar 2024 11:55:27 +0000 (12:55 +0100)
commit2d20f690921a82ee6db0c2fbac7dd5f13d4a0882
tree1fd804b54953ffb2beb4c17573833d95680a1472
parent0e7bc3eaa36b81004b799124d2fe00137401a43b
OpenMP/C++: Fix (first)private clause with member variables [PR110347]

OpenMP permits '(first)private' for C++ member variables, which GCC handles
by tagging those by DECL_OMP_PRIVATIZED_MEMBER, adding a temporary VAR_DECL
and DECL_VALUE_EXPR pointing to the 'this->member_var' in the C++ front end.

The idea is that in omp-low.cc, the DECL_VALUE_EXPR is used before the
region (for 'firstprivate'; ignored for 'private') while in the region,
the DECL itself is used.

In gimplify, the value expansion is suppressed and deferred if the
  lang_hooks.decls.omp_disregard_value_expr (decl, shared)
returns true - which is never the case if 'shared' is true. In OpenMP 4.5,
only 'map' and 'use_device_ptr' was permitted for the 'target' directive.
And when OpenMP 5.0's 'private'/'firstprivate' clauses was added, the
the update that now 'shared' argument could be false was missed. The
respective check has now been added.

2024-03-01  Jakub Jelinek  <jakub@redhat.com>
    Tobias Burnus  <tburnus@baylibre.com>

PR c++/110347

gcc/ChangeLog:

* gimplify.cc (omp_notice_variable): Fix 'shared' arg to
lang_hooks.decls.omp_disregard_value_expr for
(first)private in target regions.

libgomp/ChangeLog:

* testsuite/libgomp.c++/target-lambda-3.C: Moved from
gcc/testsuite/g++.dg/gomp/ and fixed is-mapped handling.
* testsuite/libgomp.c++/target-lambda-1.C: Modify to also
also work without offloading.
* testsuite/libgomp.c++/firstprivate-1.C: New test.
* testsuite/libgomp.c++/firstprivate-2.C: New test.
* testsuite/libgomp.c++/private-1.C: New test.
* testsuite/libgomp.c++/private-2.C: New test.
* testsuite/libgomp.c++/target-lambda-4.C: New test.
* testsuite/libgomp.c++/use_device_ptr-1.C: New test.

gcc/testsuite/ChangeLog:

* g++.dg/gomp/target-lambda-1.C: Moved to become a
run-time test under testsuite/libgomp.c++.

Co-authored-by: Tobias Burnus <tburnus@baylibre.com>
(cherry picked from commit 4f82d5a95a244d0aa4f8b2541b47a21bce8a191b)
13 files changed:
gcc/ChangeLog.omp
gcc/gimplify.cc
gcc/testsuite/ChangeLog.omp
gcc/testsuite/g++.dg/gomp/target-lambda-1.C [deleted file]
libgomp/ChangeLog.omp
libgomp/testsuite/libgomp.c++/firstprivate-1.C [new file with mode: 0644]
libgomp/testsuite/libgomp.c++/firstprivate-2.C [new file with mode: 0644]
libgomp/testsuite/libgomp.c++/private-1.C [new file with mode: 0644]
libgomp/testsuite/libgomp.c++/private-2.C [new file with mode: 0644]
libgomp/testsuite/libgomp.c++/target-lambda-1.C
libgomp/testsuite/libgomp.c++/target-lambda-3.C [new file with mode: 0644]
libgomp/testsuite/libgomp.c++/target-lambda-4.C [new file with mode: 0644]
libgomp/testsuite/libgomp.c++/use_device_ptr-1.C [new file with mode: 0644]