@@ -6555,12 +6555,12 @@ OpenMPIRBuilder::InsertPointOrErrorTy OpenMPIRBuilder::createTargetData(
6555
6555
const LocationDescription &Loc, InsertPointTy AllocaIP,
6556
6556
InsertPointTy CodeGenIP, Value *DeviceID, Value *IfCond,
6557
6557
TargetDataInfo &Info, GenMapInfoCallbackTy GenMapInfoCB,
6558
+ function_ref<Value *(unsigned int )> CustomMapperCB,
6558
6559
omp::RuntimeFunction *MapperFunc,
6559
6560
function_ref<InsertPointOrErrorTy(InsertPointTy CodeGenIP,
6560
6561
BodyGenTy BodyGenType)>
6561
6562
BodyGenCB,
6562
- function_ref<void(unsigned int , Value *)> DeviceAddrCB,
6563
- function_ref<Value *(unsigned int )> CustomMapperCB, Value *SrcLocInfo) {
6563
+ function_ref<void(unsigned int , Value *)> DeviceAddrCB, Value *SrcLocInfo) {
6564
6564
if (!updateToLocation (Loc))
6565
6565
return InsertPointTy ();
6566
6566
@@ -6586,8 +6586,8 @@ OpenMPIRBuilder::InsertPointOrErrorTy OpenMPIRBuilder::createTargetData(
6586
6586
InsertPointTy CodeGenIP) -> Error {
6587
6587
MapInfo = &GenMapInfoCB (Builder.saveIP ());
6588
6588
emitOffloadingArrays (AllocaIP, Builder.saveIP (), *MapInfo, Info,
6589
- /* IsNonContiguous= */ true , DeviceAddrCB ,
6590
- CustomMapperCB );
6589
+ CustomMapperCB ,
6590
+ /* IsNonContiguous= */ true , DeviceAddrCB );
6591
6591
6592
6592
TargetDataRTArgs RTArgs;
6593
6593
emitOffloadingArraysArgument (Builder, RTArgs, Info);
@@ -7488,24 +7488,26 @@ OpenMPIRBuilder::InsertPointOrErrorTy OpenMPIRBuilder::emitTargetTask(
7488
7488
7489
7489
void OpenMPIRBuilder::emitOffloadingArraysAndArgs (
7490
7490
InsertPointTy AllocaIP, InsertPointTy CodeGenIP, TargetDataInfo &Info,
7491
- TargetDataRTArgs &RTArgs, MapInfosTy &CombinedInfo, bool IsNonContiguous,
7492
- bool ForEndCall, function_ref<void (unsigned int , Value * )> DeviceAddrCB ,
7493
- function_ref<Value * (unsigned int )> CustomMapperCB ) {
7494
- emitOffloadingArrays (AllocaIP, CodeGenIP, CombinedInfo, Info, IsNonContiguous ,
7495
- DeviceAddrCB, CustomMapperCB );
7491
+ TargetDataRTArgs &RTArgs, MapInfosTy &CombinedInfo,
7492
+ function_ref<Value * (unsigned int )> CustomMapperCB, bool IsNonContiguous ,
7493
+ bool ForEndCall, function_ref<void (unsigned int , Value * )> DeviceAddrCB ) {
7494
+ emitOffloadingArrays (AllocaIP, CodeGenIP, CombinedInfo, Info, CustomMapperCB ,
7495
+ IsNonContiguous, DeviceAddrCB );
7496
7496
emitOffloadingArraysArgument (Builder, RTArgs, Info, ForEndCall);
7497
7497
}
7498
7498
7499
7499
static void
7500
7500
emitTargetCall (OpenMPIRBuilder &OMPBuilder, IRBuilderBase &Builder,
7501
7501
OpenMPIRBuilder::InsertPointTy AllocaIP,
7502
+ OpenMPIRBuilder::TargetDataInfo &Info,
7502
7503
const OpenMPIRBuilder::TargetKernelDefaultAttrs &DefaultAttrs,
7503
7504
const OpenMPIRBuilder::TargetKernelRuntimeAttrs &RuntimeAttrs,
7504
7505
Value *IfCond, Function *OutlinedFn, Constant *OutlinedFnID,
7505
7506
SmallVectorImpl<Value *> &Args,
7506
7507
OpenMPIRBuilder::GenMapInfoCallbackTy GenMapInfoCB,
7507
- SmallVector<llvm::OpenMPIRBuilder::DependData> Dependencies = {},
7508
- bool HasNoWait = false ) {
7508
+ function_ref<Value *(unsigned int )> CustomMapperCB,
7509
+ SmallVector<llvm::OpenMPIRBuilder::DependData> Dependencies,
7510
+ bool HasNoWait) {
7509
7511
// Generate a function call to the host fallback implementation of the target
7510
7512
// region. This is called by the host when no offload entry was generated for
7511
7513
// the target region and when the offloading call fails at runtime.
@@ -7583,7 +7585,7 @@ emitTargetCall(OpenMPIRBuilder &OMPBuilder, IRBuilderBase &Builder,
7583
7585
OpenMPIRBuilder::MapInfosTy &MapInfo = GenMapInfoCB (Builder.saveIP ());
7584
7586
OpenMPIRBuilder::TargetDataRTArgs RTArgs;
7585
7587
OMPBuilder.emitOffloadingArraysAndArgs (AllocaIP, Builder.saveIP (), Info,
7586
- RTArgs, MapInfo,
7588
+ RTArgs, MapInfo, CustomMapperCB,
7587
7589
/* IsNonContiguous=*/ true ,
7588
7590
/* ForEndCall=*/ false );
7589
7591
@@ -7687,12 +7689,14 @@ emitTargetCall(OpenMPIRBuilder &OMPBuilder, IRBuilderBase &Builder,
7687
7689
7688
7690
OpenMPIRBuilder::InsertPointOrErrorTy OpenMPIRBuilder::createTarget (
7689
7691
const LocationDescription &Loc, bool IsOffloadEntry, InsertPointTy AllocaIP,
7690
- InsertPointTy CodeGenIP, TargetRegionEntryInfo &EntryInfo,
7692
+ InsertPointTy CodeGenIP, TargetDataInfo &Info,
7693
+ TargetRegionEntryInfo &EntryInfo,
7691
7694
const TargetKernelDefaultAttrs &DefaultAttrs,
7692
7695
const TargetKernelRuntimeAttrs &RuntimeAttrs, Value *IfCond,
7693
- SmallVectorImpl<Value *> &Args , GenMapInfoCallbackTy GenMapInfoCB,
7696
+ SmallVectorImpl<Value *> &Inputs , GenMapInfoCallbackTy GenMapInfoCB,
7694
7697
OpenMPIRBuilder::TargetBodyGenCallbackTy CBFunc,
7695
7698
OpenMPIRBuilder::TargetGenArgAccessorsCallbackTy ArgAccessorFuncCB,
7699
+ function_ref<Value *(unsigned int )> CustomMapperCB,
7696
7700
SmallVector<DependData> Dependencies, bool HasNowait) {
7697
7701
7698
7702
if (!updateToLocation (Loc))
@@ -7707,16 +7711,16 @@ OpenMPIRBuilder::InsertPointOrErrorTy OpenMPIRBuilder::createTarget(
7707
7711
// and ArgAccessorFuncCB
7708
7712
if (Error Err = emitTargetOutlinedFunction (
7709
7713
*this , Builder, IsOffloadEntry, EntryInfo, DefaultAttrs, OutlinedFn,
7710
- OutlinedFnID, Args , CBFunc, ArgAccessorFuncCB))
7714
+ OutlinedFnID, Inputs , CBFunc, ArgAccessorFuncCB))
7711
7715
return Err;
7712
7716
7713
7717
// If we are not on the target device, then we need to generate code
7714
7718
// to make a remote call (offload) to the previously outlined function
7715
7719
// that represents the target region. Do that now.
7716
7720
if (!Config.isTargetDevice ())
7717
- emitTargetCall (*this , Builder, AllocaIP, DefaultAttrs, RuntimeAttrs, IfCond ,
7718
- OutlinedFn, OutlinedFnID, Args , GenMapInfoCB, Dependencies ,
7719
- HasNowait);
7721
+ emitTargetCall (*this , Builder, AllocaIP, Info, DefaultAttrs, RuntimeAttrs ,
7722
+ IfCond, OutlinedFn, OutlinedFnID, Inputs , GenMapInfoCB,
7723
+ CustomMapperCB, Dependencies, HasNowait);
7720
7724
return Builder.saveIP ();
7721
7725
}
7722
7726
@@ -8041,9 +8045,9 @@ void OpenMPIRBuilder::emitUDMapperArrayInitOrDel(
8041
8045
OffloadingArgs);
8042
8046
}
8043
8047
8044
- Function *OpenMPIRBuilder::emitUserDefinedMapper (
8045
- function_ref<MapInfosTy & (InsertPointTy CodeGenIP, llvm::Value *PtrPHI,
8046
- llvm::Value *BeginArg)>
8048
+ Expected< Function *> OpenMPIRBuilder::emitUserDefinedMapper (
8049
+ function_ref<MapInfosOrErrorTy (InsertPointTy CodeGenIP, llvm::Value *PtrPHI,
8050
+ llvm::Value *BeginArg)>
8047
8051
GenMapInfoCB,
8048
8052
Type *ElemTy, StringRef FuncName,
8049
8053
function_ref<bool(unsigned int , Function **)> CustomMapperCB) {
@@ -8117,7 +8121,9 @@ Function *OpenMPIRBuilder::emitUserDefinedMapper(
8117
8121
PtrPHI->addIncoming (PtrBegin, HeadBB);
8118
8122
8119
8123
// Get map clause information. Fill up the arrays with all mapped variables.
8120
- MapInfosTy &Info = GenMapInfoCB (Builder.saveIP (), PtrPHI, BeginIn);
8124
+ MapInfosOrErrorTy Info = GenMapInfoCB (Builder.saveIP (), PtrPHI, BeginIn);
8125
+ if (!Info)
8126
+ return Info.takeError ();
8121
8127
8122
8128
// Call the runtime API __tgt_mapper_num_components to get the number of
8123
8129
// pre-existing components.
@@ -8129,20 +8135,20 @@ Function *OpenMPIRBuilder::emitUserDefinedMapper(
8129
8135
Builder.CreateShl (PreviousSize, Builder.getInt64 (getFlagMemberOffset ()));
8130
8136
8131
8137
// Fill up the runtime mapper handle for all components.
8132
- for (unsigned I = 0 ; I < Info. BasePointers .size (); ++I) {
8138
+ for (unsigned I = 0 ; I < Info-> BasePointers .size (); ++I) {
8133
8139
Value *CurBaseArg =
8134
- Builder.CreateBitCast (Info. BasePointers [I], Builder.getPtrTy ());
8140
+ Builder.CreateBitCast (Info-> BasePointers [I], Builder.getPtrTy ());
8135
8141
Value *CurBeginArg =
8136
- Builder.CreateBitCast (Info. Pointers [I], Builder.getPtrTy ());
8137
- Value *CurSizeArg = Info. Sizes [I];
8138
- Value *CurNameArg = Info. Names .size ()
8139
- ? Info. Names [I]
8142
+ Builder.CreateBitCast (Info-> Pointers [I], Builder.getPtrTy ());
8143
+ Value *CurSizeArg = Info-> Sizes [I];
8144
+ Value *CurNameArg = Info-> Names .size ()
8145
+ ? Info-> Names [I]
8140
8146
: Constant::getNullValue (Builder.getPtrTy ());
8141
8147
8142
8148
// Extract the MEMBER_OF field from the map type.
8143
8149
Value *OriMapType = Builder.getInt64 (
8144
8150
static_cast <std::underlying_type_t <OpenMPOffloadMappingFlags>>(
8145
- Info. Types [I]));
8151
+ Info-> Types [I]));
8146
8152
Value *MemberMapType =
8147
8153
Builder.CreateNUWAdd (OriMapType, ShiftedPreviousSize);
8148
8154
@@ -8263,9 +8269,9 @@ Function *OpenMPIRBuilder::emitUserDefinedMapper(
8263
8269
8264
8270
void OpenMPIRBuilder::emitOffloadingArrays (
8265
8271
InsertPointTy AllocaIP, InsertPointTy CodeGenIP, MapInfosTy &CombinedInfo,
8266
- TargetDataInfo &Info, bool IsNonContiguous ,
8267
- function_ref< void ( unsigned int , Value *)> DeviceAddrCB ,
8268
- function_ref<Value * (unsigned int )> CustomMapperCB ) {
8272
+ TargetDataInfo &Info, function_ref<Value *( unsigned int )> CustomMapperCB ,
8273
+ bool IsNonContiguous ,
8274
+ function_ref<void (unsigned int , Value * )> DeviceAddrCB ) {
8269
8275
8270
8276
// Reset the array information.
8271
8277
Info.clearArrayInfo ();
0 commit comments