[PATCH] D112292: [Clang][OpenMP] Allow loop iteration var with threadprivate directive

Jennifer Yu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 21 20:12:09 PDT 2021


jyu2 created this revision.
jyu2 added reviewers: ABataev, mikerice, jdoerfert.
jyu2 added projects: clang, OpenMP.
Herald added subscribers: guansong, yaxunl.
jyu2 requested review of this revision.
Herald added a subscriber: sstefan1.

Loop iteration var with threadprivate is predetermined as threadprivate.

Current clang emit error when loop var that appear in threadprivate
directives.

According to OpenMP 5.1 [2.21.1.1]

  For first predetermined rule is:
  Variables that appear in threadprivate directives or variables with the
  _Thread_local (in C) or thread_local (in C++) storage-class specifier
  are threadprivate

The error should not be emitted.

To fix this, set PredeterminedCKind with OMPC_threadprivate when loopvar
with threadprivate.

Setting PredeterminedCKind with DVar.CKind according the rule.  And use
PredeterminedCKind to emit error.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D112292

Files:
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_loop_messages.cpp
  clang/test/OpenMP/distribute_simd_loop_messages.cpp
  clang/test/OpenMP/for_loop_messages.cpp
  clang/test/OpenMP/for_simd_loop_messages.cpp
  clang/test/OpenMP/master_taskloop_loop_messages.cpp
  clang/test/OpenMP/master_taskloop_simd_loop_messages.cpp
  clang/test/OpenMP/parallel_for_loop_messages.cpp
  clang/test/OpenMP/parallel_for_simd_loop_messages.cpp
  clang/test/OpenMP/parallel_master_taskloop_loop_messages.cpp
  clang/test/OpenMP/parallel_master_taskloop_simd_loop_messages.cpp
  clang/test/OpenMP/simd_loop_messages.cpp
  clang/test/OpenMP/target_parallel_for_loop_messages.cpp
  clang/test/OpenMP/target_parallel_for_simd_loop_messages.cpp
  clang/test/OpenMP/target_simd_loop_messages.cpp
  clang/test/OpenMP/target_teams_distribute_loop_messages.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_loop_messages.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_simd_loop_messages.cpp
  clang/test/OpenMP/target_teams_distribute_simd_loop_messages.cpp
  clang/test/OpenMP/taskloop_loop_messages.cpp
  clang/test/OpenMP/taskloop_simd_loop_messages.cpp
  clang/test/OpenMP/teams_distribute_loop_messages.cpp
  clang/test/OpenMP/teams_distribute_parallel_for_loop_messages.cpp
  clang/test/OpenMP/teams_distribute_parallel_for_simd_loop_messages.cpp
  clang/test/OpenMP/teams_distribute_simd_loop_messages.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D112292.381462.patch
Type: text/x-patch
Size: 29683 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20211022/18564395/attachment-0001.bin>


More information about the cfe-commits mailing list