@@ -6549,12 +6549,12 @@ OpenMPIRBuilder::InsertPointOrErrorTy OpenMPIRBuilder::createTargetData(
6549
6549
const LocationDescription &Loc, InsertPointTy AllocaIP,
6550
6550
InsertPointTy CodeGenIP, Value *DeviceID, Value *IfCond,
6551
6551
TargetDataInfo &Info, GenMapInfoCallbackTy GenMapInfoCB,
6552
+ function_ref<Value *(unsigned int )> CustomMapperCB,
6552
6553
omp::RuntimeFunction *MapperFunc,
6553
6554
function_ref<InsertPointOrErrorTy(InsertPointTy CodeGenIP,
6554
6555
BodyGenTy BodyGenType)>
6555
6556
BodyGenCB,
6556
- function_ref<void(unsigned int , Value *)> DeviceAddrCB,
6557
- function_ref<Value *(unsigned int )> CustomMapperCB, Value *SrcLocInfo) {
6557
+ function_ref<void(unsigned int , Value *)> DeviceAddrCB, Value *SrcLocInfo) {
6558
6558
if (!updateToLocation (Loc))
6559
6559
return InsertPointTy ();
6560
6560
@@ -6580,8 +6580,8 @@ OpenMPIRBuilder::InsertPointOrErrorTy OpenMPIRBuilder::createTargetData(
6580
6580
InsertPointTy CodeGenIP) -> Error {
6581
6581
MapInfo = &GenMapInfoCB (Builder.saveIP ());
6582
6582
emitOffloadingArrays (AllocaIP, Builder.saveIP (), *MapInfo, Info,
6583
- /* IsNonContiguous= */ true , DeviceAddrCB ,
6584
- CustomMapperCB );
6583
+ CustomMapperCB ,
6584
+ /* IsNonContiguous= */ true , DeviceAddrCB );
6585
6585
6586
6586
TargetDataRTArgs RTArgs;
6587
6587
emitOffloadingArraysArgument (Builder, RTArgs, Info);
@@ -7394,24 +7394,26 @@ OpenMPIRBuilder::InsertPointOrErrorTy OpenMPIRBuilder::emitTargetTask(
7394
7394
7395
7395
void OpenMPIRBuilder::emitOffloadingArraysAndArgs (
7396
7396
InsertPointTy AllocaIP, InsertPointTy CodeGenIP, TargetDataInfo &Info,
7397
- TargetDataRTArgs &RTArgs, MapInfosTy &CombinedInfo, bool IsNonContiguous,
7398
- bool ForEndCall, function_ref<void (unsigned int , Value * )> DeviceAddrCB ,
7399
- function_ref<Value * (unsigned int )> CustomMapperCB ) {
7400
- emitOffloadingArrays (AllocaIP, CodeGenIP, CombinedInfo, Info, IsNonContiguous ,
7401
- DeviceAddrCB, CustomMapperCB );
7397
+ TargetDataRTArgs &RTArgs, MapInfosTy &CombinedInfo,
7398
+ function_ref<Value * (unsigned int )> CustomMapperCB, bool IsNonContiguous ,
7399
+ bool ForEndCall, function_ref<void (unsigned int , Value * )> DeviceAddrCB ) {
7400
+ emitOffloadingArrays (AllocaIP, CodeGenIP, CombinedInfo, Info, CustomMapperCB ,
7401
+ IsNonContiguous, DeviceAddrCB );
7402
7402
emitOffloadingArraysArgument (Builder, RTArgs, Info, ForEndCall);
7403
7403
}
7404
7404
7405
7405
static void
7406
7406
emitTargetCall (OpenMPIRBuilder &OMPBuilder, IRBuilderBase &Builder,
7407
7407
OpenMPIRBuilder::InsertPointTy AllocaIP,
7408
+ OpenMPIRBuilder::TargetDataInfo &Info,
7408
7409
const OpenMPIRBuilder::TargetKernelDefaultAttrs &DefaultAttrs,
7409
7410
const OpenMPIRBuilder::TargetKernelRuntimeAttrs &RuntimeAttrs,
7410
7411
Value *IfCond, Function *OutlinedFn, Constant *OutlinedFnID,
7411
7412
SmallVectorImpl<Value *> &Args,
7412
7413
OpenMPIRBuilder::GenMapInfoCallbackTy GenMapInfoCB,
7413
- SmallVector<llvm::OpenMPIRBuilder::DependData> Dependencies = {},
7414
- bool HasNoWait = false ) {
7414
+ function_ref<Value *(unsigned int )> CustomMapperCB,
7415
+ SmallVector<llvm::OpenMPIRBuilder::DependData> Dependencies,
7416
+ bool HasNoWait) {
7415
7417
// Generate a function call to the host fallback implementation of the target
7416
7418
// region. This is called by the host when no offload entry was generated for
7417
7419
// the target region and when the offloading call fails at runtime.
@@ -7489,7 +7491,7 @@ emitTargetCall(OpenMPIRBuilder &OMPBuilder, IRBuilderBase &Builder,
7489
7491
OpenMPIRBuilder::MapInfosTy &MapInfo = GenMapInfoCB (Builder.saveIP ());
7490
7492
OpenMPIRBuilder::TargetDataRTArgs RTArgs;
7491
7493
OMPBuilder.emitOffloadingArraysAndArgs (AllocaIP, Builder.saveIP (), Info,
7492
- RTArgs, MapInfo,
7494
+ RTArgs, MapInfo, CustomMapperCB,
7493
7495
/* IsNonContiguous=*/ true ,
7494
7496
/* ForEndCall=*/ false );
7495
7497
@@ -7593,12 +7595,14 @@ emitTargetCall(OpenMPIRBuilder &OMPBuilder, IRBuilderBase &Builder,
7593
7595
7594
7596
OpenMPIRBuilder::InsertPointOrErrorTy OpenMPIRBuilder::createTarget (
7595
7597
const LocationDescription &Loc, bool IsOffloadEntry, InsertPointTy AllocaIP,
7596
- InsertPointTy CodeGenIP, TargetRegionEntryInfo &EntryInfo,
7598
+ InsertPointTy CodeGenIP, TargetDataInfo &Info,
7599
+ TargetRegionEntryInfo &EntryInfo,
7597
7600
const TargetKernelDefaultAttrs &DefaultAttrs,
7598
7601
const TargetKernelRuntimeAttrs &RuntimeAttrs, Value *IfCond,
7599
- SmallVectorImpl<Value *> &Args , GenMapInfoCallbackTy GenMapInfoCB,
7602
+ SmallVectorImpl<Value *> &Inputs , GenMapInfoCallbackTy GenMapInfoCB,
7600
7603
OpenMPIRBuilder::TargetBodyGenCallbackTy CBFunc,
7601
7604
OpenMPIRBuilder::TargetGenArgAccessorsCallbackTy ArgAccessorFuncCB,
7605
+ function_ref<Value *(unsigned int )> CustomMapperCB,
7602
7606
SmallVector<DependData> Dependencies, bool HasNowait) {
7603
7607
7604
7608
if (!updateToLocation (Loc))
@@ -7613,16 +7617,16 @@ OpenMPIRBuilder::InsertPointOrErrorTy OpenMPIRBuilder::createTarget(
7613
7617
// and ArgAccessorFuncCB
7614
7618
if (Error Err = emitTargetOutlinedFunction (
7615
7619
*this , Builder, IsOffloadEntry, EntryInfo, DefaultAttrs, OutlinedFn,
7616
- OutlinedFnID, Args , CBFunc, ArgAccessorFuncCB))
7620
+ OutlinedFnID, Inputs , CBFunc, ArgAccessorFuncCB))
7617
7621
return Err;
7618
7622
7619
7623
// If we are not on the target device, then we need to generate code
7620
7624
// to make a remote call (offload) to the previously outlined function
7621
7625
// that represents the target region. Do that now.
7622
7626
if (!Config.isTargetDevice ())
7623
- emitTargetCall (*this , Builder, AllocaIP, DefaultAttrs, RuntimeAttrs, IfCond ,
7624
- OutlinedFn, OutlinedFnID, Args , GenMapInfoCB, Dependencies ,
7625
- HasNowait);
7627
+ emitTargetCall (*this , Builder, AllocaIP, Info, DefaultAttrs, RuntimeAttrs ,
7628
+ IfCond, OutlinedFn, OutlinedFnID, Inputs , GenMapInfoCB,
7629
+ CustomMapperCB, Dependencies, HasNowait);
7626
7630
return Builder.saveIP ();
7627
7631
}
7628
7632
@@ -7947,9 +7951,9 @@ void OpenMPIRBuilder::emitUDMapperArrayInitOrDel(
7947
7951
OffloadingArgs);
7948
7952
}
7949
7953
7950
- Function *OpenMPIRBuilder::emitUserDefinedMapper (
7951
- function_ref<MapInfosTy & (InsertPointTy CodeGenIP, llvm::Value *PtrPHI,
7952
- llvm::Value *BeginArg)>
7954
+ Expected< Function *> OpenMPIRBuilder::emitUserDefinedMapper (
7955
+ function_ref<MapInfosOrErrorTy (InsertPointTy CodeGenIP, llvm::Value *PtrPHI,
7956
+ llvm::Value *BeginArg)>
7953
7957
GenMapInfoCB,
7954
7958
Type *ElemTy, StringRef FuncName,
7955
7959
function_ref<bool(unsigned int , Function **)> CustomMapperCB) {
@@ -8023,7 +8027,9 @@ Function *OpenMPIRBuilder::emitUserDefinedMapper(
8023
8027
PtrPHI->addIncoming (PtrBegin, HeadBB);
8024
8028
8025
8029
// Get map clause information. Fill up the arrays with all mapped variables.
8026
- MapInfosTy &Info = GenMapInfoCB (Builder.saveIP (), PtrPHI, BeginIn);
8030
+ MapInfosOrErrorTy Info = GenMapInfoCB (Builder.saveIP (), PtrPHI, BeginIn);
8031
+ if (!Info)
8032
+ return Info.takeError ();
8027
8033
8028
8034
// Call the runtime API __tgt_mapper_num_components to get the number of
8029
8035
// pre-existing components.
@@ -8035,20 +8041,20 @@ Function *OpenMPIRBuilder::emitUserDefinedMapper(
8035
8041
Builder.CreateShl (PreviousSize, Builder.getInt64 (getFlagMemberOffset ()));
8036
8042
8037
8043
// Fill up the runtime mapper handle for all components.
8038
- for (unsigned I = 0 ; I < Info. BasePointers .size (); ++I) {
8044
+ for (unsigned I = 0 ; I < Info-> BasePointers .size (); ++I) {
8039
8045
Value *CurBaseArg =
8040
- Builder.CreateBitCast (Info. BasePointers [I], Builder.getPtrTy ());
8046
+ Builder.CreateBitCast (Info-> BasePointers [I], Builder.getPtrTy ());
8041
8047
Value *CurBeginArg =
8042
- Builder.CreateBitCast (Info. Pointers [I], Builder.getPtrTy ());
8043
- Value *CurSizeArg = Info. Sizes [I];
8044
- Value *CurNameArg = Info. Names .size ()
8045
- ? Info. Names [I]
8048
+ Builder.CreateBitCast (Info-> Pointers [I], Builder.getPtrTy ());
8049
+ Value *CurSizeArg = Info-> Sizes [I];
8050
+ Value *CurNameArg = Info-> Names .size ()
8051
+ ? Info-> Names [I]
8046
8052
: Constant::getNullValue (Builder.getPtrTy ());
8047
8053
8048
8054
// Extract the MEMBER_OF field from the map type.
8049
8055
Value *OriMapType = Builder.getInt64 (
8050
8056
static_cast <std::underlying_type_t <OpenMPOffloadMappingFlags>>(
8051
- Info. Types [I]));
8057
+ Info-> Types [I]));
8052
8058
Value *MemberMapType =
8053
8059
Builder.CreateNUWAdd (OriMapType, ShiftedPreviousSize);
8054
8060
@@ -8169,9 +8175,9 @@ Function *OpenMPIRBuilder::emitUserDefinedMapper(
8169
8175
8170
8176
void OpenMPIRBuilder::emitOffloadingArrays (
8171
8177
InsertPointTy AllocaIP, InsertPointTy CodeGenIP, MapInfosTy &CombinedInfo,
8172
- TargetDataInfo &Info, bool IsNonContiguous ,
8173
- function_ref< void ( unsigned int , Value *)> DeviceAddrCB ,
8174
- function_ref<Value * (unsigned int )> CustomMapperCB ) {
8178
+ TargetDataInfo &Info, function_ref<Value *( unsigned int )> CustomMapperCB ,
8179
+ bool IsNonContiguous ,
8180
+ function_ref<void (unsigned int , Value * )> DeviceAddrCB ) {
8175
8181
8176
8182
// Reset the array information.
8177
8183
Info.clearArrayInfo ();
0 commit comments