[clang] [OpenMP][CodeGen] Improved codegen for combined loop directives (PR #72417)

Gheorghe-Teodor Bercea via cfe-commits cfe-commits at lists.llvm.org
Tue Feb 6 10:59:14 PST 2024


================
@@ -6106,6 +6106,8 @@ class OMPTeamsGenericLoopDirective final : public OMPLoopDirective {
 class OMPTargetTeamsGenericLoopDirective final : public OMPLoopDirective {
   friend class ASTStmtReader;
   friend class OMPExecutableDirective;
+  /// true if loop directive's associated loop can be a parallel for.
+  bool CanBeParallelFor = false;
----------------
doru1004 wrote:

I don't think it is possible to have the analysis in Sema and not use a flag here.

The two options we have are:
1. Do the analysis in Sema and have the flag and then read the flag in CG.
2. Have the analysis in CG and then there's no reason to pass anything around and CG can call the function when needed.

There is a 3rd hybrid way to do this where this function is moved back into CG:
```
bool Sema::teamsLoopCanBeParallelFor(Stmt *AStmt) {
  TeamsLoopChecker Checker(*this);
  Checker.Visit(AStmt);
  return Checker.teamsLoopCanBeParallelFor();
}
```

But then I don't know how you can call the TeamsLoopChecker which lives in Sema.

https://github.com/llvm/llvm-project/pull/72417


More information about the cfe-commits mailing list