================
@@ -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 > 51) {
+ auto &&SerialLeague = [&S](CodeGenFunction &CGF, PrePostActionTy &) {
+ // OpenMP 6.0, 12.2, teams Construct
+ // When an if clause is present on a teams construct and the if clause
+ // expression evaluates to false, the number of formed teams is one.
+ const llvm::APInt One(32, 1);
+ IntegerLiteral NumTeams(
+ CGF.getContext(), One,
+ CGF.getContext().getIntTypeForBitwidth(32, /*Signed=*/0),
+ SourceLocation());
+ // the thread_limit clause is unaffected by the if clause
----------------
Thyre wrote:
Fixed in 864308760b0dae9071ad2518040193798f22fa07.
Thanks for the suggestion đŸ˜„
https://github.com/llvm/llvm-project/pull/207444
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits