[PATCH] D151356: [OpenMP] Fix transformed loop's var privacy

Joel E. Denny via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed May 24 10:59:01 PDT 2023


jdenny created this revision.
jdenny added reviewers: Meinersbur, ABataev.
jdenny added a project: OpenMP.
Herald added subscribers: sunshaoce, zzheng, guansong, yaxunl.
Herald added a project: All.
jdenny requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added subscribers: openmp-commits, cfe-commits, jplehr, sstefan1.
Herald added a project: clang.

Without this patch, the following example crashes Clang:

  #pragma omp target map(i)
  #pragma omp tile sizes(2)
  for (i = 0; i < N; ++i)
    ;

This patch fixes the crash by changing `Sema::isOpenMPPrivateDecl` not 
to identify `i` as private just because it's the loop variable of a
`tile` construct.

While OpenMP TR11 and earlier do specify privacy for loop variables of
loops *generated* from a `tile` construct, I haven't found text
stating that the original loop variable must be private in the above
example, so this patch leaves it shared.  Even so, it is a bit 
unexpected that value of `i` after the loop is `N - 1` instead of `N`.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D151356

Files:
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/OpenMP/unroll_codegen_parallel_for_factor.cpp
  openmp/libomptarget/test/offloading/target-tile.c

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D151356.525266.patch
Type: text/x-patch
Size: 5122 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230524/532e4db7/attachment-0001.bin>


More information about the cfe-commits mailing list