]> git.ipfire.org Git - thirdparty/gcc.git/commit
OpenMP/Fortran: Fix handling of 'declare target' with 'link' clause [PR115559]
authorTobias Burnus <tburnus@baylibre.com>
Mon, 29 Jul 2024 09:46:57 +0000 (11:46 +0200)
committerTobias Burnus <tburnus@baylibre.com>
Mon, 29 Jul 2024 09:46:57 +0000 (11:46 +0200)
commit29b1587e7d34667a1fd63071c1e4f5475cd71026
treeae397d08eea21d4bd0712ee9c90d496d55e701da
parent14c47e7eb06e8b95913794f6059560fc2fa6de91
OpenMP/Fortran: Fix handling of 'declare target' with 'link' clause [PR115559]

Contrary to a normal 'declare target', the 'declare target link' attribute
also needs to set node->offloadable and push the offload_vars in the front end.

Linked variables require that the data is mapped. For module variables, this
can happen anywhere. For variables in an external subprograms or the main
programm, this can only happen in the either that program itself or in an
internal subprogram. - Whether a variable is just normally mapped or linked then
becomes relevant if a device routine exists that can access that variable,
i.e. an internal procedure has then to be marked as declare target.

PR fortran/115559

gcc/fortran/ChangeLog:

* trans-common.cc (build_common_decl): Add 'omp declare target' and
'omp declare target link' variables to offload_vars.
* trans-decl.cc (add_attributes_to_decl): Likewise; update args and
call decl_attributes.
(get_proc_pointer_decl, gfc_get_extern_function_decl,
build_function_decl): Update calls.
(gfc_get_symbol_decl): Likewise; move after 'DECL_STATIC (t)=1'
to avoid errors with symtab_node::get_create.

libgomp/ChangeLog:

* testsuite/libgomp.fortran/declare-target-link.f90: New test.
gcc/fortran/trans-common.cc
gcc/fortran/trans-decl.cc
libgomp/testsuite/libgomp.fortran/declare-target-link.f90 [new file with mode: 0644]