@@ -9489,18 +9489,27 @@ static llvm::Value *emitDeviceID(
94899489 return DeviceID;
94909490}
94919491
9492- static llvm::Value *emitDynCGGroupMem(const OMPExecutableDirective &D,
9493- CodeGenFunction &CGF) {
9494- llvm::Value *DynCGroupMem = CGF.Builder.getInt32(0);
9495-
9496- if (auto *DynMemClause = D.getSingleClause<OMPXDynCGroupMemClause>()) {
9497- CodeGenFunction::RunCleanupsScope DynCGroupMemScope(CGF);
9498- llvm::Value *DynCGroupMemVal = CGF.EmitScalarExpr(
9499- DynMemClause->getSize(), /*IgnoreResultAssign=*/true);
9500- DynCGroupMem = CGF.Builder.CreateIntCast(DynCGroupMemVal, CGF.Int32Ty,
9501- /*isSigned=*/false);
9502- }
9503- return DynCGroupMem;
9492+ static std::pair<llvm::Value *, bool> emitDynCGroupMem(const OMPExecutableDirective &D,
9493+ CodeGenFunction &CGF) {
9494+ llvm::Value *DynGP = CGF.Builder.getInt32(0);
9495+ bool DynGPFallback = false;
9496+
9497+ if (auto *DynGPClause = D.getSingleClause<OMPDynGroupprivateClause>()) {
9498+ CodeGenFunction::RunCleanupsScope DynGPScope(CGF);
9499+ llvm::Value *DynGPVal = CGF.EmitScalarExpr(
9500+ DynGPClause->getSize(), /*IgnoreResultAssign=*/true);
9501+ DynGP = CGF.Builder.CreateIntCast(DynGPVal, CGF.Int32Ty,
9502+ /*isSigned=*/false);
9503+ DynGPFallback = (DynGPClause->getModifier() == OMPC_DYN_GROUPPRIVATE_fallback ||
9504+ OMPC_DYN_GROUPPRIVATE_unknown);
9505+ } else if (auto *OMPXDynCGClause = D.getSingleClause<OMPXDynCGroupMemClause>()) {
9506+ CodeGenFunction::RunCleanupsScope DynCGMemScope(CGF);
9507+ llvm::Value *DynCGMemVal = CGF.EmitScalarExpr(
9508+ OMPXDynCGClause->getSize(), /*IgnoreResultAssign=*/true);
9509+ DynGP = CGF.Builder.CreateIntCast(DynCGMemVal, CGF.Int32Ty,
9510+ /*isSigned=*/false);
9511+ }
9512+ return { DynGP, DynGPFallback };
95049513}
95059514static void genMapInfoForCaptures(
95069515 MappableExprsHandler &MEHandler, CodeGenFunction &CGF,
@@ -9710,7 +9719,7 @@ static void emitTargetCallKernelLaunch(
97109719 llvm::Value *RTLoc = OMPRuntime->emitUpdateLocation(CGF, D.getBeginLoc());
97119720 llvm::Value *NumIterations =
97129721 OMPRuntime->emitTargetNumIterationsCall(CGF, D, SizeEmitter);
9713- llvm::Value *DynCGGroupMem = emitDynCGGroupMem (D, CGF);
9722+ auto [DynCGroupMem, DynCGroupMemFallback] = emitDynCGroupMem (D, CGF);
97149723 llvm::OpenMPIRBuilder::InsertPointTy AllocaIP(
97159724 CGF.AllocaInsertPt->getParent(), CGF.AllocaInsertPt->getIterator());
97169725
@@ -9720,7 +9729,7 @@ static void emitTargetCallKernelLaunch(
97209729
97219730 llvm::OpenMPIRBuilder::TargetKernelArgs Args(
97229731 NumTargetItems, RTArgs, NumIterations, NumTeams, NumThreads,
9723- DynCGGroupMem , HasNoWait);
9732+ DynCGroupMem , HasNoWait, DynCGroupMemFallback );
97249733
97259734 llvm::OpenMPIRBuilder::InsertPointTy AfterIP =
97269735 cantFail(OMPRuntime->getOMPBuilder().emitKernelLaunch(
0 commit comments