[PATCH] D154180: [OPENMP52] Codegen support for doacross clause.

Jennifer Yu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Jul 3 09:29:26 PDT 2023


jyu2 added inline comments.


================
Comment at: clang/lib/CodeGen/CGOpenMPRuntime.cpp:11405-11406
+  llvm::OpenMPIRBuilder &OMPBuilder = CGM.getOpenMPRuntime().getOMPBuilder();
+  const OMPDependClause *DepC = dyn_cast<OMPDependClause>(C);
+  const OMPDoacrossClause *DoC = dyn_cast<OMPDoacrossClause>(C);
+  if ((DoC && DoC->getDependenceType() == OMPC_DOACROSS_source) ||
----------------
ABataev wrote:
> 1. const auto *
> 2. Can you try torework it to make it more C++-ish? Use template deduction to avoid runtime dyn_casts.
> e.g. something like:
> ```
> namespace {
> template <typename T>
> class OMPDoacrossKind {
> public:
> bool isSink(const T *) {return false;}
> }
> }
> template <>
> class OMPDoacrossKInd<OMPDependClause> {
> public:
> bool isSink(const OMPDependClause* C) {return C->getDependenceType();}
> }
> ...
> ```
> and use `if (OMPDoacrossKInd<T>::isSink(C)) RTLFn = ...` and same for `Source`
Good idea!!!  Thank you so much.  Changed.


================
Comment at: clang/lib/CodeGen/CGStmtOpenMP.cpp:5859-5868
+  const auto DOC = dyn_cast<OMPDoacrossClause>(C);
+  const auto DC = dyn_cast<OMPDependClause>(C);
+  bool IsDependSource = false;
+  if ((DC && DC->getDependencyKind() == OMPC_DEPEND_source) ||
+      (DOC && DOC->getDependenceType() == OMPC_DOACROSS_source))
+    IsDependSource = true;
+  CGF.Builder.restoreIP(
----------------
ABataev wrote:
> Same, use template-based analysis instead of runtime-based.
Thanks.  Changed.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D154180/new/

https://reviews.llvm.org/D154180



More information about the cfe-commits mailing list