[clang] [Clang][OpenMP] Fix `if` clause not affecting `teams` construct on host (PR #207444)
Alexey Bataev via cfe-commits
cfe-commits at lists.llvm.org
Thu Jul 9 10:48:29 PDT 2026
Jan =?utf-8?q?André?= Reuter <j.reuter at fz-juelich.de>,
Jan =?utf-8?q?André?= Reuter <j.reuter at fz-juelich.de>,
Jan =?utf-8?q?André?= Reuter <j.reuter at fz-juelich.de>,
Jan =?utf-8?q?André?= Reuter <j.reuter at fz-juelich.de>,
Jan =?utf-8?q?André?= Reuter <j.reuter at fz-juelich.de>
Message-ID:
In-Reply-To: <llvm.org/llvm/llvm-project/pull/207444 at github.com>
================
@@ -7366,17 +7366,50 @@ static void emitCommonOMPTeamsDirective(CodeGenFunction &CGF,
CGF, S, *CS->getCapturedDecl()->param_begin(), InnermostKind,
CodeGen);
- const auto *NT = S.getSingleClause<OMPNumTeamsClause>();
- const auto *TL = S.getSingleClause<OMPThreadLimitClause>();
- if (NT || TL) {
- const Expr *NumTeams = NT ? NT->getNumTeams().front() : nullptr;
- const Expr *ThreadLimit = TL ? TL->getThreadLimit().front() : nullptr;
+ OMPTeamsScope Scope(CGF, S);
+ auto &&ParallelLeague = [&S](CodeGenFunction &CGF, PrePostActionTy &) {
+ const auto *NT = S.getSingleClause<OMPNumTeamsClause>();
+ const auto *TL = S.getSingleClause<OMPThreadLimitClause>();
+ if (NT || TL) {
+ const Expr *NumTeams = NT ? NT->getNumTeams().front() : nullptr;
+ const Expr *ThreadLimit = TL ? TL->getThreadLimit().front() : nullptr;
+
+ CGF.CGM.getOpenMPRuntime().emitNumTeamsClause(CGF, NumTeams, ThreadLimit,
+ S.getBeginLoc());
+ }
+ };
- CGF.CGM.getOpenMPRuntime().emitNumTeamsClause(CGF, NumTeams, ThreadLimit,
- S.getBeginLoc());
+ const Expr *IfCond = nullptr;
+ for (const auto *C : S.getClausesOfKind<OMPIfClause>()) {
+ if (C->getNameModifier() == OMPD_unknown ||
+ C->getNameModifier() == OMPD_teams) {
+ IfCond = C->getCondition();
+ break;
+ }
+ }
+ if (IfCond && CGF.CGM.getLangOpts().OpenMP >= 52) {
+ auto &&SerialLeague = [&S](CodeGenFunction &CGF, PrePostActionTy &) {
----------------
alexey-bataev wrote:
```suggestion
auto SerialLeague = [&S](CodeGenFunction &CGF, PrePostActionTy &) {
```
https://github.com/llvm/llvm-project/pull/207444
More information about the cfe-commits
mailing list