[Libomptarget] Work around bug in initialization of libomptarget
authorJoseph Huber <jhuber6@vols.utk.edu>
Fri, 4 Mar 2022 17:07:57 +0000 (12:07 -0500)
committerJoseph Huber <jhuber6@vols.utk.edu>
Fri, 4 Mar 2022 18:13:31 +0000 (13:13 -0500)
commite2dcc2218c64ae1b6a774f52bd3aec87a6902b58
tree3174887bfd469797dce328bf6cbd42c35e03fe42
parent703240c71fd640af7490069e8149d32d78d14da1
[Libomptarget] Work around bug in initialization of libomptarget

Libomptarget uses some shared variables to track certain internal stated
in the runtime. This causes problems when we have code that contains no
OpenMP kernels. These variables are normally initialized upon kernel
entry, but if there are no kernels we will see no initialization.
Currently we load the runtime into each source file when not running in
LTO mode, so these variables will be erroneously considered undefined or
dead and removed, causing miscompiles. This patch temporarily works
around the most obvious case, but others still exhibit this problem. We
will need to fix this more soundly later.

Fixes #54208.

Reviewed By: jdoerfert

Differential Revision: https://reviews.llvm.org/D121007
openmp/libomptarget/DeviceRTL/src/Mapping.cpp