@@ -6555,12 +6555,12 @@ OpenMPIRBuilder::InsertPointOrErrorTy OpenMPIRBuilder::createTargetData(
65556555 const LocationDescription &Loc, InsertPointTy AllocaIP,
65566556 InsertPointTy CodeGenIP, Value *DeviceID, Value *IfCond,
65576557 TargetDataInfo &Info, GenMapInfoCallbackTy GenMapInfoCB,
6558+ function_ref<Value *(unsigned int )> CustomMapperCB,
65586559 omp::RuntimeFunction *MapperFunc,
65596560 function_ref<InsertPointOrErrorTy(InsertPointTy CodeGenIP,
65606561 BodyGenTy BodyGenType)>
65616562 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) {
65646564 if (!updateToLocation (Loc))
65656565 return InsertPointTy ();
65666566
@@ -6586,8 +6586,8 @@ OpenMPIRBuilder::InsertPointOrErrorTy OpenMPIRBuilder::createTargetData(
65866586 InsertPointTy CodeGenIP) -> Error {
65876587 MapInfo = &GenMapInfoCB (Builder.saveIP ());
65886588 emitOffloadingArrays (AllocaIP, Builder.saveIP (), *MapInfo, Info,
6589- /* IsNonContiguous= */ true , DeviceAddrCB ,
6590- CustomMapperCB );
6589+ CustomMapperCB ,
6590+ /* IsNonContiguous= */ true , DeviceAddrCB );
65916591
65926592 TargetDataRTArgs RTArgs;
65936593 emitOffloadingArraysArgument (Builder, RTArgs, Info);
@@ -7488,24 +7488,26 @@ OpenMPIRBuilder::InsertPointOrErrorTy OpenMPIRBuilder::emitTargetTask(
74887488
74897489void OpenMPIRBuilder::emitOffloadingArraysAndArgs (
74907490 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 );
74967496 emitOffloadingArraysArgument (Builder, RTArgs, Info, ForEndCall);
74977497}
74987498
74997499static void
75007500emitTargetCall (OpenMPIRBuilder &OMPBuilder, IRBuilderBase &Builder,
75017501 OpenMPIRBuilder::InsertPointTy AllocaIP,
7502+ OpenMPIRBuilder::TargetDataInfo &Info,
75027503 const OpenMPIRBuilder::TargetKernelDefaultAttrs &DefaultAttrs,
75037504 const OpenMPIRBuilder::TargetKernelRuntimeAttrs &RuntimeAttrs,
75047505 Value *IfCond, Function *OutlinedFn, Constant *OutlinedFnID,
75057506 SmallVectorImpl<Value *> &Args,
75067507 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) {
75097511 // Generate a function call to the host fallback implementation of the target
75107512 // region. This is called by the host when no offload entry was generated for
75117513 // the target region and when the offloading call fails at runtime.
@@ -7583,7 +7585,7 @@ emitTargetCall(OpenMPIRBuilder &OMPBuilder, IRBuilderBase &Builder,
75837585 OpenMPIRBuilder::MapInfosTy &MapInfo = GenMapInfoCB (Builder.saveIP ());
75847586 OpenMPIRBuilder::TargetDataRTArgs RTArgs;
75857587 OMPBuilder.emitOffloadingArraysAndArgs (AllocaIP, Builder.saveIP (), Info,
7586- RTArgs, MapInfo,
7588+ RTArgs, MapInfo, CustomMapperCB,
75877589 /* IsNonContiguous=*/ true ,
75887590 /* ForEndCall=*/ false );
75897591
@@ -7687,12 +7689,14 @@ emitTargetCall(OpenMPIRBuilder &OMPBuilder, IRBuilderBase &Builder,
76877689
76887690OpenMPIRBuilder::InsertPointOrErrorTy OpenMPIRBuilder::createTarget (
76897691 const LocationDescription &Loc, bool IsOffloadEntry, InsertPointTy AllocaIP,
7690- InsertPointTy CodeGenIP, TargetRegionEntryInfo &EntryInfo,
7692+ InsertPointTy CodeGenIP, TargetDataInfo &Info,
7693+ TargetRegionEntryInfo &EntryInfo,
76917694 const TargetKernelDefaultAttrs &DefaultAttrs,
76927695 const TargetKernelRuntimeAttrs &RuntimeAttrs, Value *IfCond,
7693- SmallVectorImpl<Value *> &Args , GenMapInfoCallbackTy GenMapInfoCB,
7696+ SmallVectorImpl<Value *> &Inputs , GenMapInfoCallbackTy GenMapInfoCB,
76947697 OpenMPIRBuilder::TargetBodyGenCallbackTy CBFunc,
76957698 OpenMPIRBuilder::TargetGenArgAccessorsCallbackTy ArgAccessorFuncCB,
7699+ function_ref<Value *(unsigned int )> CustomMapperCB,
76967700 SmallVector<DependData> Dependencies, bool HasNowait) {
76977701
76987702 if (!updateToLocation (Loc))
@@ -7707,16 +7711,16 @@ OpenMPIRBuilder::InsertPointOrErrorTy OpenMPIRBuilder::createTarget(
77077711 // and ArgAccessorFuncCB
77087712 if (Error Err = emitTargetOutlinedFunction (
77097713 *this , Builder, IsOffloadEntry, EntryInfo, DefaultAttrs, OutlinedFn,
7710- OutlinedFnID, Args , CBFunc, ArgAccessorFuncCB))
7714+ OutlinedFnID, Inputs , CBFunc, ArgAccessorFuncCB))
77117715 return Err;
77127716
77137717 // If we are not on the target device, then we need to generate code
77147718 // to make a remote call (offload) to the previously outlined function
77157719 // that represents the target region. Do that now.
77167720 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);
77207724 return Builder.saveIP ();
77217725}
77227726
@@ -8041,9 +8045,9 @@ void OpenMPIRBuilder::emitUDMapperArrayInitOrDel(
80418045 OffloadingArgs);
80428046}
80438047
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)>
80478051 GenMapInfoCB,
80488052 Type *ElemTy, StringRef FuncName,
80498053 function_ref<bool(unsigned int , Function **)> CustomMapperCB) {
@@ -8117,7 +8121,9 @@ Function *OpenMPIRBuilder::emitUserDefinedMapper(
81178121 PtrPHI->addIncoming (PtrBegin, HeadBB);
81188122
81198123 // 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 ();
81218127
81228128 // Call the runtime API __tgt_mapper_num_components to get the number of
81238129 // pre-existing components.
@@ -8129,20 +8135,20 @@ Function *OpenMPIRBuilder::emitUserDefinedMapper(
81298135 Builder.CreateShl (PreviousSize, Builder.getInt64 (getFlagMemberOffset ()));
81308136
81318137 // 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) {
81338139 Value *CurBaseArg =
8134- Builder.CreateBitCast (Info. BasePointers [I], Builder.getPtrTy ());
8140+ Builder.CreateBitCast (Info-> BasePointers [I], Builder.getPtrTy ());
81358141 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]
81408146 : Constant::getNullValue (Builder.getPtrTy ());
81418147
81428148 // Extract the MEMBER_OF field from the map type.
81438149 Value *OriMapType = Builder.getInt64 (
81448150 static_cast <std::underlying_type_t <OpenMPOffloadMappingFlags>>(
8145- Info. Types [I]));
8151+ Info-> Types [I]));
81468152 Value *MemberMapType =
81478153 Builder.CreateNUWAdd (OriMapType, ShiftedPreviousSize);
81488154
@@ -8263,9 +8269,9 @@ Function *OpenMPIRBuilder::emitUserDefinedMapper(
82638269
82648270void OpenMPIRBuilder::emitOffloadingArrays (
82658271 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 ) {
82698275
82708276 // Reset the array information.
82718277 Info.clearArrayInfo ();
0 commit comments