Add map info for dereference pointer.
authorJennifer Yu <jennifer.yu@intel.com>
Wed, 1 Mar 2023 16:22:21 +0000 (08:22 -0800)
committerJennifer Yu <jennifer.yu@intel.com>
Thu, 9 Mar 2023 01:43:43 +0000 (17:43 -0800)
commit0f2f378425821de77e50a0dcb67c4504389a56e8
treec0ec002d375de5f5fab5f2ff7c064b32f3505ea0
parent42a5dda553e84da98cb03630130e4820e93af8f2
Add map info for dereference pointer.

This is to fix run time problem when use:

int **a;
map((*a)[:3]), (*a)[1] or map(**a).

current we skip generate map info for dereference pointer:
&(*a), &(*a)[0], 3*sizeof(int), TARGET_PARAM | TO | FROM

One way to fix runtime problem is to generate map info for dereference
pointer.

map((*a)[:3]):
&(*a), &(*a), sizeof(pointer),  TARGET_PARAM | TO | FROM
&(*a), &(*a)[0], 3*sizeof(int),  PTR_AND_OBJ | TO | FROM

map(**a):
&(*a), &(*a), sizeof(pointer),  TARGET_PARAM | TO | FROM
&(*a), &(**a), sizeof(int),  PTR_AND_OBJ | TO | FROM

The change in CGOpenMPRuntime.cpp add that.

The change in SemaOpenMP is to fix variable of dereference pointer to array
captured by reference.  That is wrong. That cause run time to fail.

The rule is:
If variable is identified in a map clause it is always captured by
reference except if it is a pointer that is dereferenced somehow.

Differential Revision: https://reviews.llvm.org/D145093
clang/lib/CodeGen/CGOpenMPRuntime.cpp
clang/lib/Sema/SemaOpenMP.cpp
clang/test/OpenMP/target_map_deref_array_codegen.cpp [new file with mode: 0644]
clang/test/OpenMP/target_update_codegen.cpp
openmp/libomptarget/test/mapping/target_derefence_array_pointrs.cpp [new file with mode: 0644]