Go to file
Tobias Burnus 814e29e390 OpenMP: Fix mapping of zero-sized arrays with non-literal size: map(var[:n]), n = 0
For map(ptr[:0]), the used map kind is GOMP_MAP_ATTACH_ZERO_LENGTH_ARRAY_SECTION
and it is permitted that 'ptr' does not exist. 'ptr' is set to the device
pointee if it exists or to the host value otherwise.

For map(ptr[:3]), the variable is first mapped and then ptr is updated to point
to the just-mapped device data; the attachment uses GOMP_MAP_ATTACH.

For map(ptr[:n]), generates always a GOMP_MAP_ATTACH, but when n == 0, it
was failing with:
   "pointer target not mapped for attach"

The solution is not to fail but first to check whether it was mapped before.
It turned out that for the mapping part, GCC adds a run-time check whether
n == 0 - and uses GOMP_MAP_ZERO_LEN_ARRAY_SECTION for the mapping.
Thus, we just have to check whether there such a mapping for the address
for which the GOMP_MAP_ATTACH. was requested. And, if there was, the
error diagnostic can be skipped.

Unsurprisingly, this issue occurs in real-world code; it was detected in
a code that distributes work via MPI and for some processes, some bounds
ended up to be zero.

libgomp/ChangeLog:

	* target.c (gomp_attach_pointer): Return bool; accept additional
	bool to optionally silence the fatal pointee-not-found error.
	(gomp_map_vars_internal): If the pointee could not be found,
	check whether it was mapped as GOMP_MAP_ZERO_LEN_ARRAY_SECTION.
	* libgomp.h (gomp_attach_pointer): Update prototype.
	* oacc-mem.c (acc_attach_async, goacc_enter_data_internal): Update
	calls.
	* testsuite/libgomp.c/target-map-zero-sized.c: New test.
	* testsuite/libgomp.c/target-map-zero-sized-2.c: New test.
	* testsuite/libgomp.c/target-map-zero-sized-3.c: New test.
2025-05-14 20:06:49 +02:00
.forgejo
.github
INSTALL
c++tools
config Daily bump. 2025-04-16 00:18:18 +00:00
contrib Daily bump. 2025-05-10 00:17:59 +00:00
fixincludes
gcc Remove the mixed stmt_vec_info/SLP node record_stmt_cost overload 2025-05-14 18:49:22 +02:00
gnattools Daily bump. 2025-04-02 00:18:25 +00:00
gotools
include libiberty: remove duplicated declaration of mkstemps 2025-05-14 15:58:33 +02:00
libada
libatomic Daily bump. 2025-05-10 00:17:59 +00:00
libbacktrace Daily bump. 2025-04-11 00:17:32 +00:00
libcc1
libcody
libcpp Daily bump. 2025-05-13 00:18:32 +00:00
libdecnumber
libffi
libgcc Daily bump. 2025-04-26 00:19:18 +00:00
libgcobol Daily bump. 2025-05-14 00:18:21 +00:00
libgfortran Daily bump. 2025-05-14 00:18:21 +00:00
libgm2 Daily bump. 2025-04-25 00:18:00 +00:00
libgo
libgomp OpenMP: Fix mapping of zero-sized arrays with non-literal size: map(var[:n]), n = 0 2025-05-14 20:06:49 +02:00
libgrust Daily bump. 2025-04-01 00:19:09 +00:00
libiberty Daily bump. 2025-05-14 00:18:21 +00:00
libitm Daily bump. 2025-05-10 00:17:59 +00:00
libobjc
libphobos Daily bump. 2025-05-10 00:17:59 +00:00
libquadmath Daily bump. 2025-04-10 00:18:06 +00:00
libsanitizer Daily bump. 2025-05-03 00:18:18 +00:00
libssp
libstdc++-v3 libstdc++: Renamed bits/move_only_function.h to bits/funcwrap.h [PR119125] 2025-05-14 15:00:41 +02:00
libvtv Daily bump. 2025-05-10 00:17:59 +00:00
lto-plugin
maintainer-scripts Daily bump. 2025-04-26 00:19:18 +00:00
zlib
.b4-config
.dir-locals.el
.gitattributes
.gitignore
ABOUT-NLS
COPYING
COPYING.LIB
COPYING.RUNTIME
COPYING3
COPYING3.LIB
ChangeLog Daily bump. 2025-04-29 00:20:16 +00:00
ChangeLog.jit
ChangeLog.tree-ssa
MAINTAINERS Remove Marcus Shawcroft 2025-05-14 11:41:11 +01:00
Makefile.def toplevel, libcobol: Add dependency on libquadmath build [PR119244]. 2025-03-25 19:31:10 +00:00
Makefile.in toplevel, libcobol: Add dependency on libquadmath build [PR119244]. 2025-03-25 19:31:10 +00:00
Makefile.tpl toplevel, Makefile: Add missing CXX_FOR_TARGET export [PR88319]. 2025-03-23 20:44:33 +00:00
README
SECURITY.txt
ar-lib
compile
config-ml.in
config.guess
config.rpath
config.sub
configure cobol: Restrict COBOL to supported Linux arches [PR119217] 2025-04-22 13:47:17 +02:00
configure.ac cobol: Restrict COBOL to supported Linux arches [PR119217] 2025-04-22 13:47:17 +02:00
depcomp
install-sh
libtool-ldflags
libtool.m4
ltgcc.m4
ltmain.sh
ltoptions.m4
ltsugar.m4
ltversion.m4
lt~obsolete.m4
missing
mkdep
mkinstalldirs
move-if-change
multilib.am
symlink-tree
test-driver
ylwrap

README

This directory contains the GNU Compiler Collection (GCC).

The GNU Compiler Collection is free software.  See the files whose
names start with COPYING for copying permission.  The manuals, and
some of the runtime libraries, are under different terms; see the
individual source files for details.

The directory INSTALL contains copies of the installation information
as HTML and plain text.  The source of this information is
gcc/doc/install.texi.  The installation information includes details
of what is included in the GCC sources and what files GCC installs.

See the file gcc/doc/gcc.texi (together with other files that it
includes) for usage and porting information.  An online readable
version of the manual is in the files gcc/doc/gcc.info*.

See http://gcc.gnu.org/bugs/ for how to report bugs usefully.

Copyright years on GCC source files may be listed using range
notation, e.g., 1987-2012, indicating that every year in the range,
inclusive, is a copyrightable year that could otherwise be listed
individually.