@@ -9582,6 +9582,20 @@ static void genMapInfo(const OMPExecutableDirective &D, CodeGenFunction &CGF,
95829582 MappedVarSet, CombinedInfo);
95839583 genMapInfo(MEHandler, CGF, CombinedInfo, OMPBuilder, MappedVarSet);
95849584}
9585+
9586+ static void emitNumTeamsForBareTargetDirective(
9587+ CodeGenFunction &CGF, const OMPExecutableDirective &D,
9588+ llvm::SmallVectorImpl<llvm::Value *> &NumTeams) {
9589+ const auto *C = D.getSingleClause<OMPNumTeamsClause>();
9590+ assert(!C->varlist_empty() && "ompx_bare requires explicit num_teams");
9591+ CodeGenFunction::RunCleanupsScope NumTeamsScope(CGF);
9592+ for (auto *E : C->getNumTeams()) {
9593+ llvm::Value *V = CGF.EmitScalarExpr(E);
9594+ NumTeams.push_back(
9595+ CGF.Builder.CreateIntCast(V, CGF.Int32Ty, /*isSigned=*/true));
9596+ }
9597+ }
9598+
95859599static void emitTargetCallKernelLaunch(
95869600 CGOpenMPRuntime *OMPRuntime, llvm::Function *OutlinedFn,
95879601 const OMPExecutableDirective &D,
@@ -9651,8 +9665,14 @@ static void emitTargetCallKernelLaunch(
96519665 return CGF.Builder.saveIP();
96529666 };
96539667
9668+ bool IsBare = D.hasClausesOfKind<OMPXBareClause>();
9669+ SmallVector<llvm::Value *, 3> NumTeams;
9670+ if (IsBare)
9671+ emitNumTeamsForBareTargetDirective(CGF, D, NumTeams);
9672+ else
9673+ NumTeams.push_back(OMPRuntime->emitNumTeamsForTargetDirective(CGF, D));
9674+
96549675 llvm::Value *DeviceID = emitDeviceID(Device, CGF);
9655- llvm::Value *NumTeams = OMPRuntime->emitNumTeamsForTargetDirective(CGF, D);
96569676 llvm::Value *NumThreads =
96579677 OMPRuntime->emitNumThreadsForTargetDirective(CGF, D);
96589678 llvm::Value *RTLoc = OMPRuntime->emitUpdateLocation(CGF, D.getBeginLoc());
0 commit comments