[PATCH] D145093: Add map info for dereference pointer.

Jennifer Yu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Mar 1 11:20:30 PST 2023


jyu2 created this revision.
jyu2 added reviewers: ABataev, mikerice, jdoerfert.
jyu2 added a project: OpenMP.
Herald added a project: All.
jyu2 requested review of this revision.
Herald added subscribers: openmp-commits, cfe-commits, sstefan1.
Herald added a project: clang.

This is to fix run time problem when use:

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

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.

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

The change in CGOpenMPRuntime.cpp add that.

The change in SemaOpenMP is to fix variable of dereference 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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D145093

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/OpenMP/target_map_deref_array_codegen.cpp
  openmp/libomptarget/test/mapping/target_derefence_array_pointrs.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D145093.501576.patch
Type: text/x-patch
Size: 13815 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230301/38ec5f74/attachment-0001.bin>


More information about the cfe-commits mailing list