]> git.ipfire.org Git - thirdparty/gcc.git/commit
libgomp: Fix declare target link with offset array-section mapping [PR116107]
authorTobias Burnus <tburnus@baylibre.com>
Mon, 29 Jul 2024 09:40:38 +0000 (11:40 +0200)
committerTobias Burnus <tburnus@baylibre.com>
Mon, 29 Jul 2024 09:40:38 +0000 (11:40 +0200)
commit14c47e7eb06e8b95913794f6059560fc2fa6de91
tree2370fc93479e8fe161b6fe816e83c0f3295aa032
parentb3176b620ff29a06c90992ca3d29f3cffd459537
libgomp: Fix declare target link with offset array-section mapping [PR116107]

Assume that 'int var[100]' is 'omp declare target link(var)'. When now
mapping an array section with offset such as 'map(to:var[20:10])',
the device-side link pointer has to store &<device-storage-data>[0] minus
the offset such that var[20] will access <device-storage-data>[0]. But
the offset calculation was missed such that the device-side 'var' pointed
to the first element of the mapped data - and var[20] points beyond at
some invalid memory.

PR middle-end/116107

libgomp/ChangeLog:

* target.c (gomp_map_vars_internal): Honor array mapping offsets
with declare-target 'link' variables.
* testsuite/libgomp.c-c++-common/target-link-2.c: New test.
libgomp/target.c
libgomp/testsuite/libgomp.c-c++-common/target-link-2.c [new file with mode: 0644]