@@ -8867,36 +8867,21 @@ emitMappingInformation(CodeGenFunction &CGF, llvm::OpenMPIRBuilder &OMPBuilder,
8867
8867
PLoc.getLine(), PLoc.getColumn(),
8868
8868
SrcLocStrSize);
8869
8869
}
8870
-
8871
8870
/// Emit the arrays used to pass the captures and map information to the
8872
8871
/// offloading runtime library. If there is no map or capture information,
8873
8872
/// return nullptr by reference.
8874
- static void emitOffloadingArrays (
8873
+ static void emitOffloadingArraysAndArgs (
8875
8874
CodeGenFunction &CGF, MappableExprsHandler::MapCombinedInfoTy &CombinedInfo,
8876
8875
CGOpenMPRuntime::TargetDataInfo &Info, llvm::OpenMPIRBuilder &OMPBuilder,
8877
- bool IsNonContiguous = false) {
8876
+ bool IsNonContiguous = false, bool ForEndCall = false ) {
8878
8877
CodeGenModule &CGM = CGF.CGM;
8879
8878
8880
- // Reset the array information.
8881
- Info.clearArrayInfo();
8882
- Info.NumberOfPtrs = CombinedInfo.BasePointers.size();
8883
-
8884
8879
using InsertPointTy = llvm::OpenMPIRBuilder::InsertPointTy;
8885
8880
InsertPointTy AllocaIP(CGF.AllocaInsertPt->getParent(),
8886
8881
CGF.AllocaInsertPt->getIterator());
8887
8882
InsertPointTy CodeGenIP(CGF.Builder.GetInsertBlock(),
8888
8883
CGF.Builder.GetInsertPoint());
8889
8884
8890
- auto FillInfoMap = [&](MappableExprsHandler::MappingExprInfo &MapExpr) {
8891
- return emitMappingInformation(CGF, OMPBuilder, MapExpr);
8892
- };
8893
- if (CGM.getCodeGenOpts().getDebugInfo() !=
8894
- llvm::codegenoptions::NoDebugInfo) {
8895
- CombinedInfo.Names.resize(CombinedInfo.Exprs.size());
8896
- llvm::transform(CombinedInfo.Exprs, CombinedInfo.Names.begin(),
8897
- FillInfoMap);
8898
- }
8899
-
8900
8885
auto DeviceAddrCB = [&](unsigned int I, llvm::Value *NewDecl) {
8901
8886
if (const ValueDecl *DevVD = CombinedInfo.DevicePtrDecls[I]) {
8902
8887
Info.CaptureDeviceAddrMap.try_emplace(DevVD, NewDecl);
@@ -8907,14 +8892,14 @@ static void emitOffloadingArrays(
8907
8892
llvm::Value *MFunc = nullptr;
8908
8893
if (CombinedInfo.Mappers[I]) {
8909
8894
Info.HasMapper = true;
8910
- MFunc = CGF. CGM.getOpenMPRuntime().getOrCreateUserDefinedMapperFunc(
8895
+ MFunc = CGM.getOpenMPRuntime().getOrCreateUserDefinedMapperFunc(
8911
8896
cast<OMPDeclareMapperDecl>(CombinedInfo.Mappers[I]));
8912
8897
}
8913
8898
return MFunc;
8914
8899
};
8915
- OMPBuilder.emitOffloadingArrays(AllocaIP, CodeGenIP, CombinedInfo, Info,
8916
- /*IsNonContiguous=*/true, DeviceAddrCB ,
8917
- CustomMapperCB);
8900
+ OMPBuilder.emitOffloadingArraysAndArgs(
8901
+ AllocaIP, CodeGenIP, Info, Info.RTArgs, CombinedInfo, IsNonContiguous ,
8902
+ ForEndCall, DeviceAddrCB, CustomMapperCB);
8918
8903
}
8919
8904
8920
8905
/// Check for inner distribute directive.
@@ -9479,29 +9464,14 @@ llvm::Value *emitDynCGGroupMem(const OMPExecutableDirective &D,
9479
9464
}
9480
9465
return DynCGroupMem;
9481
9466
}
9467
+ static void genMapInfoForCaptures(
9468
+ MappableExprsHandler &MEHandler, CodeGenFunction &CGF,
9469
+ const CapturedStmt &CS, llvm::SmallVectorImpl<llvm::Value *> &CapturedVars,
9470
+ llvm::OpenMPIRBuilder &OMPBuilder,
9471
+ llvm::DenseSet<CanonicalDeclPtr<const Decl>> &MappedVarSet,
9472
+ MappableExprsHandler::MapCombinedInfoTy &CombinedInfo) {
9482
9473
9483
- static void emitTargetCallKernelLaunch(
9484
- CGOpenMPRuntime *OMPRuntime, llvm::Function *OutlinedFn,
9485
- const OMPExecutableDirective &D,
9486
- llvm::SmallVectorImpl<llvm::Value *> &CapturedVars, bool RequiresOuterTask,
9487
- const CapturedStmt &CS, bool OffloadingMandatory,
9488
- llvm::PointerIntPair<const Expr *, 2, OpenMPDeviceClauseModifier> Device,
9489
- llvm::Value *OutlinedFnID, CodeGenFunction::OMPTargetDataInfo &InputInfo,
9490
- llvm::Value *&MapTypesArray, llvm::Value *&MapNamesArray,
9491
- llvm::function_ref<llvm::Value *(CodeGenFunction &CGF,
9492
- const OMPLoopDirective &D)>
9493
- SizeEmitter,
9494
- CodeGenFunction &CGF, CodeGenModule &CGM) {
9495
- llvm::OpenMPIRBuilder &OMPBuilder = OMPRuntime->getOMPBuilder();
9496
-
9497
- // Fill up the arrays with all the captured variables.
9498
- MappableExprsHandler::MapCombinedInfoTy CombinedInfo;
9499
-
9500
- // Get mappable expression information.
9501
- MappableExprsHandler MEHandler(D, CGF);
9502
9474
llvm::DenseMap<llvm::Value *, llvm::Value *> LambdaPointers;
9503
- llvm::DenseSet<CanonicalDeclPtr<const Decl>> MappedVarSet;
9504
-
9505
9475
auto RI = CS.getCapturedRecordDecl()->field_begin();
9506
9476
auto *CV = CapturedVars.begin();
9507
9477
for (CapturedStmt::const_capture_iterator CI = CS.capture_begin(),
@@ -9568,18 +9538,64 @@ static void emitTargetCallKernelLaunch(
9568
9538
MEHandler.adjustMemberOfForLambdaCaptures(
9569
9539
OMPBuilder, LambdaPointers, CombinedInfo.BasePointers,
9570
9540
CombinedInfo.Pointers, CombinedInfo.Types);
9541
+ }
9542
+ static void
9543
+ genMapInfo(MappableExprsHandler &MEHandler, CodeGenFunction &CGF,
9544
+ MappableExprsHandler::MapCombinedInfoTy &CombinedInfo,
9545
+ llvm::OpenMPIRBuilder &OMPBuilder,
9546
+ const llvm::DenseSet<CanonicalDeclPtr<const Decl>> &SkippedVarSet =
9547
+ llvm::DenseSet<CanonicalDeclPtr<const Decl>>()) {
9548
+
9549
+ CodeGenModule &CGM = CGF.CGM;
9571
9550
// Map any list items in a map clause that were not captures because they
9572
9551
// weren't referenced within the construct.
9573
- MEHandler.generateAllInfo(CombinedInfo, OMPBuilder, MappedVarSet);
9552
+ MEHandler.generateAllInfo(CombinedInfo, OMPBuilder, SkippedVarSet);
9553
+
9554
+ auto FillInfoMap = [&](MappableExprsHandler::MappingExprInfo &MapExpr) {
9555
+ return emitMappingInformation(CGF, OMPBuilder, MapExpr);
9556
+ };
9557
+ if (CGM.getCodeGenOpts().getDebugInfo() !=
9558
+ llvm::codegenoptions::NoDebugInfo) {
9559
+ CombinedInfo.Names.resize(CombinedInfo.Exprs.size());
9560
+ llvm::transform(CombinedInfo.Exprs, CombinedInfo.Names.begin(),
9561
+ FillInfoMap);
9562
+ }
9563
+ }
9574
9564
9565
+ static void genMapInfo(const OMPExecutableDirective &D, CodeGenFunction &CGF,
9566
+ const CapturedStmt &CS,
9567
+ llvm::SmallVectorImpl<llvm::Value *> &CapturedVars,
9568
+ llvm::OpenMPIRBuilder &OMPBuilder,
9569
+ MappableExprsHandler::MapCombinedInfoTy &CombinedInfo) {
9570
+ // Get mappable expression information.
9571
+ MappableExprsHandler MEHandler(D, CGF);
9572
+ llvm::DenseSet<CanonicalDeclPtr<const Decl>> MappedVarSet;
9573
+
9574
+ genMapInfoForCaptures(MEHandler, CGF, CS, CapturedVars, OMPBuilder,
9575
+ MappedVarSet, CombinedInfo);
9576
+ genMapInfo(MEHandler, CGF, CombinedInfo, OMPBuilder, MappedVarSet);
9577
+ }
9578
+ static void emitTargetCallKernelLaunch(
9579
+ CGOpenMPRuntime *OMPRuntime, llvm::Function *OutlinedFn,
9580
+ const OMPExecutableDirective &D,
9581
+ llvm::SmallVectorImpl<llvm::Value *> &CapturedVars, bool RequiresOuterTask,
9582
+ const CapturedStmt &CS, bool OffloadingMandatory,
9583
+ llvm::PointerIntPair<const Expr *, 2, OpenMPDeviceClauseModifier> Device,
9584
+ llvm::Value *OutlinedFnID, CodeGenFunction::OMPTargetDataInfo &InputInfo,
9585
+ llvm::Value *&MapTypesArray, llvm::Value *&MapNamesArray,
9586
+ llvm::function_ref<llvm::Value *(CodeGenFunction &CGF,
9587
+ const OMPLoopDirective &D)>
9588
+ SizeEmitter,
9589
+ CodeGenFunction &CGF, CodeGenModule &CGM) {
9590
+ llvm::OpenMPIRBuilder &OMPBuilder = OMPRuntime->getOMPBuilder();
9591
+
9592
+ // Fill up the arrays with all the captured variables.
9593
+ MappableExprsHandler::MapCombinedInfoTy CombinedInfo;
9575
9594
CGOpenMPRuntime::TargetDataInfo Info;
9576
- // Fill up the arrays and create the arguments.
9577
- emitOffloadingArrays(CGF, CombinedInfo, Info, OMPBuilder);
9578
- bool EmitDebug = CGF.CGM.getCodeGenOpts().getDebugInfo() !=
9579
- llvm::codegenoptions::NoDebugInfo;
9580
- OMPBuilder.emitOffloadingArraysArgument(CGF.Builder, Info.RTArgs, Info,
9581
- EmitDebug,
9582
- /*ForEndCall=*/false);
9595
+ genMapInfo(D, CGF, CS, CapturedVars, OMPBuilder, CombinedInfo);
9596
+
9597
+ emitOffloadingArraysAndArgs(CGF, CombinedInfo, Info, OMPBuilder,
9598
+ /*IsNonContiguous=*/true, /*ForEndCall=*/false);
9583
9599
9584
9600
InputInfo.NumberOfTargetItems = Info.NumberOfPtrs;
9585
9601
InputInfo.BasePointersArray = Address(Info.RTArgs.BasePointersArray,
@@ -10474,22 +10490,15 @@ void CGOpenMPRuntime::emitTargetDataStandAloneCall(
10474
10490
PrePostActionTy &) {
10475
10491
// Fill up the arrays with all the mapped variables.
10476
10492
MappableExprsHandler::MapCombinedInfoTy CombinedInfo;
10477
-
10478
- // Get map clause information.
10493
+ CGOpenMPRuntime::TargetDataInfo Info;
10479
10494
MappableExprsHandler MEHandler(D, CGF);
10480
- MEHandler.generateAllInfo(CombinedInfo, OMPBuilder);
10495
+ genMapInfo(MEHandler, CGF, CombinedInfo, OMPBuilder);
10496
+ emitOffloadingArraysAndArgs(CGF, CombinedInfo, Info, OMPBuilder,
10497
+ /*IsNonContiguous=*/true, /*ForEndCall=*/false);
10481
10498
10482
- CGOpenMPRuntime::TargetDataInfo Info;
10483
- // Fill up the arrays and create the arguments.
10484
- emitOffloadingArrays(CGF, CombinedInfo, Info, OMPBuilder,
10485
- /*IsNonContiguous=*/true);
10486
10499
bool RequiresOuterTask = D.hasClausesOfKind<OMPDependClause>() ||
10487
10500
D.hasClausesOfKind<OMPNowaitClause>();
10488
- bool EmitDebug = CGF.CGM.getCodeGenOpts().getDebugInfo() !=
10489
- llvm::codegenoptions::NoDebugInfo;
10490
- OMPBuilder.emitOffloadingArraysArgument(CGF.Builder, Info.RTArgs, Info,
10491
- EmitDebug,
10492
- /*ForEndCall=*/false);
10501
+
10493
10502
InputInfo.NumberOfTargetItems = Info.NumberOfPtrs;
10494
10503
InputInfo.BasePointersArray = Address(Info.RTArgs.BasePointersArray,
10495
10504
CGF.VoidPtrTy, CGM.getPointerAlign());
0 commit comments