]> git.ipfire.org Git - thirdparty/gcc.git/commit
OpenMP: Fix nested use_device_ptr
authorChung-Lin Tang <cltang@codesourcery.com>
Tue, 5 Apr 2022 15:31:34 +0000 (08:31 -0700)
committerChung-Lin Tang <cltang@codesourcery.com>
Tue, 5 Apr 2022 15:38:23 +0000 (08:38 -0700)
commitdb43489efb81368fa5352d60072090e0ee0e6a04
treeab1413fe6f2a42e7947367296f419a7c4e250ed2
parentda61dd848c0721cb2366bcd1197104caff92e145
OpenMP: Fix nested use_device_ptr

This patch fixes a bug in lower_omp_target, where for Fortran arrays,
the expanded sender assignment is wrongly using the variable in the
current ctx, instead of the one looked-up outside, which is causing
use_device_ptr/addr to fail to work when used inside an omp-parallel
(where the omp child_fn is split away from the original).

The fix is inside omp-low.cc, though because the omp_array_data langhook
is used only by Fortran, this is essentially Fortran-specific.

2022-04-05  Chung-Lin Tang  <cltang@codesourcery.com>

gcc/ChangeLog:

* omp-low.cc (lower_omp_target): Use outer context looked-up 'var' as
argument to lang_hooks.decls.omp_array_data, instead of 'ovar' from
current clause.

libgomp/ChangeLog:

* testsuite/libgomp.fortran/use_device_ptr-4.f90: New testcase.

(cherry picked from commit b0af8e3a502a64a0e0a04cc54ef055e5d942240f)
gcc/omp-low.c
libgomp/testsuite/libgomp.fortran/use_device_ptr-4.f90 [new file with mode: 0644]