@@ -6549,12 +6549,12 @@ OpenMPIRBuilder::InsertPointOrErrorTy OpenMPIRBuilder::createTargetData(
65496549 const LocationDescription &Loc, InsertPointTy AllocaIP,
65506550 InsertPointTy CodeGenIP, Value *DeviceID, Value *IfCond,
65516551 TargetDataInfo &Info, GenMapInfoCallbackTy GenMapInfoCB,
6552+ function_ref<Value *(unsigned int )> CustomMapperCB,
65526553 omp::RuntimeFunction *MapperFunc,
65536554 function_ref<InsertPointOrErrorTy(InsertPointTy CodeGenIP,
65546555 BodyGenTy BodyGenType)>
65556556 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) {
65586558 if (!updateToLocation (Loc))
65596559 return InsertPointTy ();
65606560
@@ -6580,8 +6580,8 @@ OpenMPIRBuilder::InsertPointOrErrorTy OpenMPIRBuilder::createTargetData(
65806580 InsertPointTy CodeGenIP) -> Error {
65816581 MapInfo = &GenMapInfoCB (Builder.saveIP ());
65826582 emitOffloadingArrays (AllocaIP, Builder.saveIP (), *MapInfo, Info,
6583- /* IsNonContiguous= */ true , DeviceAddrCB ,
6584- CustomMapperCB );
6583+ CustomMapperCB ,
6584+ /* IsNonContiguous= */ true , DeviceAddrCB );
65856585
65866586 TargetDataRTArgs RTArgs;
65876587 emitOffloadingArraysArgument (Builder, RTArgs, Info);
@@ -7394,24 +7394,26 @@ OpenMPIRBuilder::InsertPointOrErrorTy OpenMPIRBuilder::emitTargetTask(
73947394
73957395void OpenMPIRBuilder::emitOffloadingArraysAndArgs (
73967396 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 );
74027402 emitOffloadingArraysArgument (Builder, RTArgs, Info, ForEndCall);
74037403}
74047404
74057405static void
74067406emitTargetCall (OpenMPIRBuilder &OMPBuilder, IRBuilderBase &Builder,
74077407 OpenMPIRBuilder::InsertPointTy AllocaIP,
7408+ OpenMPIRBuilder::TargetDataInfo &Info,
74087409 const OpenMPIRBuilder::TargetKernelDefaultAttrs &DefaultAttrs,
74097410 const OpenMPIRBuilder::TargetKernelRuntimeAttrs &RuntimeAttrs,
74107411 Value *IfCond, Function *OutlinedFn, Constant *OutlinedFnID,
74117412 SmallVectorImpl<Value *> &Args,
74127413 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) {
74157417 // Generate a function call to the host fallback implementation of the target
74167418 // region. This is called by the host when no offload entry was generated for
74177419 // the target region and when the offloading call fails at runtime.
@@ -7489,7 +7491,7 @@ emitTargetCall(OpenMPIRBuilder &OMPBuilder, IRBuilderBase &Builder,
74897491 OpenMPIRBuilder::MapInfosTy &MapInfo = GenMapInfoCB (Builder.saveIP ());
74907492 OpenMPIRBuilder::TargetDataRTArgs RTArgs;
74917493 OMPBuilder.emitOffloadingArraysAndArgs (AllocaIP, Builder.saveIP (), Info,
7492- RTArgs, MapInfo,
7494+ RTArgs, MapInfo, CustomMapperCB,
74937495 /* IsNonContiguous=*/ true ,
74947496 /* ForEndCall=*/ false );
74957497
@@ -7593,12 +7595,14 @@ emitTargetCall(OpenMPIRBuilder &OMPBuilder, IRBuilderBase &Builder,
75937595
75947596OpenMPIRBuilder::InsertPointOrErrorTy OpenMPIRBuilder::createTarget (
75957597 const LocationDescription &Loc, bool IsOffloadEntry, InsertPointTy AllocaIP,
7596- InsertPointTy CodeGenIP, TargetRegionEntryInfo &EntryInfo,
7598+ InsertPointTy CodeGenIP, TargetDataInfo &Info,
7599+ TargetRegionEntryInfo &EntryInfo,
75977600 const TargetKernelDefaultAttrs &DefaultAttrs,
75987601 const TargetKernelRuntimeAttrs &RuntimeAttrs, Value *IfCond,
7599- SmallVectorImpl<Value *> &Args , GenMapInfoCallbackTy GenMapInfoCB,
7602+ SmallVectorImpl<Value *> &Inputs , GenMapInfoCallbackTy GenMapInfoCB,
76007603 OpenMPIRBuilder::TargetBodyGenCallbackTy CBFunc,
76017604 OpenMPIRBuilder::TargetGenArgAccessorsCallbackTy ArgAccessorFuncCB,
7605+ function_ref<Value *(unsigned int )> CustomMapperCB,
76027606 SmallVector<DependData> Dependencies, bool HasNowait) {
76037607
76047608 if (!updateToLocation (Loc))
@@ -7613,16 +7617,16 @@ OpenMPIRBuilder::InsertPointOrErrorTy OpenMPIRBuilder::createTarget(
76137617 // and ArgAccessorFuncCB
76147618 if (Error Err = emitTargetOutlinedFunction (
76157619 *this , Builder, IsOffloadEntry, EntryInfo, DefaultAttrs, OutlinedFn,
7616- OutlinedFnID, Args , CBFunc, ArgAccessorFuncCB))
7620+ OutlinedFnID, Inputs , CBFunc, ArgAccessorFuncCB))
76177621 return Err;
76187622
76197623 // If we are not on the target device, then we need to generate code
76207624 // to make a remote call (offload) to the previously outlined function
76217625 // that represents the target region. Do that now.
76227626 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);
76267630 return Builder.saveIP ();
76277631}
76287632
@@ -7947,9 +7951,9 @@ void OpenMPIRBuilder::emitUDMapperArrayInitOrDel(
79477951 OffloadingArgs);
79487952}
79497953
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)>
79537957 GenMapInfoCB,
79547958 Type *ElemTy, StringRef FuncName,
79557959 function_ref<bool(unsigned int , Function **)> CustomMapperCB) {
@@ -8023,7 +8027,9 @@ Function *OpenMPIRBuilder::emitUserDefinedMapper(
80238027 PtrPHI->addIncoming (PtrBegin, HeadBB);
80248028
80258029 // 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 ();
80278033
80288034 // Call the runtime API __tgt_mapper_num_components to get the number of
80298035 // pre-existing components.
@@ -8035,20 +8041,20 @@ Function *OpenMPIRBuilder::emitUserDefinedMapper(
80358041 Builder.CreateShl (PreviousSize, Builder.getInt64 (getFlagMemberOffset ()));
80368042
80378043 // 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) {
80398045 Value *CurBaseArg =
8040- Builder.CreateBitCast (Info. BasePointers [I], Builder.getPtrTy ());
8046+ Builder.CreateBitCast (Info-> BasePointers [I], Builder.getPtrTy ());
80418047 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]
80468052 : Constant::getNullValue (Builder.getPtrTy ());
80478053
80488054 // Extract the MEMBER_OF field from the map type.
80498055 Value *OriMapType = Builder.getInt64 (
80508056 static_cast <std::underlying_type_t <OpenMPOffloadMappingFlags>>(
8051- Info. Types [I]));
8057+ Info-> Types [I]));
80528058 Value *MemberMapType =
80538059 Builder.CreateNUWAdd (OriMapType, ShiftedPreviousSize);
80548060
@@ -8169,9 +8175,9 @@ Function *OpenMPIRBuilder::emitUserDefinedMapper(
81698175
81708176void OpenMPIRBuilder::emitOffloadingArrays (
81718177 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 ) {
81758181
81768182 // Reset the array information.
81778183 Info.clearArrayInfo ();
0 commit comments