@@ -9489,18 +9489,30 @@ 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>
9493+ emitDynCGroupMem(const OMPExecutableDirective &D, 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 =
9500+ CGF.EmitScalarExpr(DynGPClause->getSize(), /*IgnoreResultAssign=*/true);
9501+ DynGP = CGF.Builder.CreateIntCast(DynGPVal, CGF.Int32Ty,
9502+ /*isSigned=*/false);
9503+ DynGPFallback = (DynGPClause->getFirstDynGroupprivateModifier() !=
9504+ OMPC_DYN_GROUPPRIVATE_strict &&
9505+ DynGPClause->getSecondDynGroupprivateModifier() !=
9506+ OMPC_DYN_GROUPPRIVATE_strict);
9507+ } else if (auto *OMPXDynCGClause =
9508+ D.getSingleClause<OMPXDynCGroupMemClause>()) {
9509+ CodeGenFunction::RunCleanupsScope DynCGMemScope(CGF);
9510+ llvm::Value *DynCGMemVal = CGF.EmitScalarExpr(OMPXDynCGClause->getSize(),
9511+ /*IgnoreResultAssign=*/true);
9512+ DynGP = CGF.Builder.CreateIntCast(DynCGMemVal, CGF.Int32Ty,
9513+ /*isSigned=*/false);
9514+ }
9515+ return {DynGP, DynGPFallback};
95049516}
95059517static void genMapInfoForCaptures(
95069518 MappableExprsHandler &MEHandler, CodeGenFunction &CGF,
@@ -9710,7 +9722,7 @@ static void emitTargetCallKernelLaunch(
97109722 llvm::Value *RTLoc = OMPRuntime->emitUpdateLocation(CGF, D.getBeginLoc());
97119723 llvm::Value *NumIterations =
97129724 OMPRuntime->emitTargetNumIterationsCall(CGF, D, SizeEmitter);
9713- llvm::Value *DynCGGroupMem = emitDynCGGroupMem (D, CGF);
9725+ auto [DynCGroupMem, DynCGroupMemFallback] = emitDynCGroupMem (D, CGF);
97149726 llvm::OpenMPIRBuilder::InsertPointTy AllocaIP(
97159727 CGF.AllocaInsertPt->getParent(), CGF.AllocaInsertPt->getIterator());
97169728
@@ -9720,7 +9732,7 @@ static void emitTargetCallKernelLaunch(
97209732
97219733 llvm::OpenMPIRBuilder::TargetKernelArgs Args(
97229734 NumTargetItems, RTArgs, NumIterations, NumTeams, NumThreads,
9723- DynCGGroupMem , HasNoWait);
9735+ DynCGroupMem , HasNoWait, DynCGroupMemFallback );
97249736
97259737 llvm::OpenMPIRBuilder::InsertPointTy AfterIP =
97269738 cantFail(OMPRuntime->getOMPBuilder().emitKernelLaunch(
0 commit comments