diff --git a/llvm/lib/Transforms/IPO/OpenMPOpt.cpp b/llvm/lib/Transforms/IPO/OpenMPOpt.cpp --- a/llvm/lib/Transforms/IPO/OpenMPOpt.cpp +++ b/llvm/lib/Transforms/IPO/OpenMPOpt.cpp @@ -486,7 +486,8 @@ BooleanStateWithPtrSetVector ReachedUnknownParallelRegions; /// State to track if we are in SPMD-mode, assumed or know, and why we decided - /// we cannot be. + /// we cannot be. If it is assumed, then RequiresFullRuntime should also be + /// false. BooleanStateWithPtrSetVector SPMDCompatibilityTracker; /// The __kmpc_target_init call in this kernel, if any. If we find more than @@ -2883,6 +2884,8 @@ const int InitIsSPMDArgNo = 1; const int DeinitIsSPMDArgNo = 1; const int InitUseStateMachineArgNo = 2; + const int InitRequiresFullRuntimeArgNo = 3; + const int DeinitRequiresFullRuntimeArgNo = 2; auto &Ctx = getAnchorValue().getContext(); A.changeUseAfterManifest(KernelInitCB->getArgOperandUse(InitIsSPMDArgNo), @@ -2893,6 +2896,13 @@ A.changeUseAfterManifest( KernelDeinitCB->getArgOperandUse(DeinitIsSPMDArgNo), *ConstantInt::getBool(Ctx, 1)); + A.changeUseAfterManifest( + KernelInitCB->getArgOperandUse(InitRequiresFullRuntimeArgNo), + *ConstantInt::getBool(Ctx, 0)); + A.changeUseAfterManifest( + KernelDeinitCB->getArgOperandUse(DeinitRequiresFullRuntimeArgNo), + *ConstantInt::getBool(Ctx, 0)); + ++NumOpenMPTargetRegionKernelsSPMD; auto Remark = [&](OptimizationRemark OR) {