This is to fix runtime problem for member data used in target region.
authorJennifer Yu <jennifer.yu@intel.com>
Mon, 9 Jan 2023 20:30:08 +0000 (12:30 -0800)
committerJennifer Yu <jennifer.yu@intel.com>
Wed, 11 Jan 2023 00:59:49 +0000 (16:59 -0800)
commitfe29a1695a6c69eb6616db01a559a3804d55fde8
treeaadddc32019d10d9ceb5d6b7b0e2d6f13b61ab8d
parent07aaae13037dadcbf3988fb503c83fd90a3310b1
This is to fix runtime problem for member data used in target region.

The problem is happened when base class member field is used in target
region , the size is wrong, cause runtime to fail. Currently the size of
calculation is depended on index of field, since field is in base class,
the calculation is wrong.

According OpenMP 5.2 148:21:
If the target construct is within a class non-static member function,
and a variable is an accessible data member of the object for which the
non-static data member function is invoked, the variable is treated as
if the this[:1] expression had appeared in a map clause with a map-type
of tofrom.

One way to fix this is emitting code to generate this[:1] instead only
when class has any base class.

Differential Revision: https://reviews.llvm.org/D141350
clang/lib/CodeGen/CGOpenMPRuntime.cpp
clang/test/OpenMP/target_map_member_expr_codegen.cpp [new file with mode: 0644]
openmp/libomptarget/test/mapping/target_map_for_member_data.cpp [new file with mode: 0644]