@@ -612,17 +612,19 @@ class OpenMPIRBuilder {
612612 // / such InsertPoints need to be preserved, it can split the block itself
613613 // / before calling the callback.
614614 // /
615- // / AllocaIP and CodeGenIP must not point to the same position.
616- // /
617- // / \param AllocaIP is the insertion point at which new alloca instructions
618- // / should be placed. The BasicBlock it is pointing to must
619- // / not be split.
620- // / \param CodeGenIP is the insertion point at which the body code should be
621- // / placed.
622- // /
615+ // / AllocIP and CodeGenIP must not point to the same position.
616+ // /
617+ // / \param AllocIP is the insertion point at which new allocations should
618+ // / be placed. The BasicBlock it is pointing to must not be
619+ // / split.
620+ // / \param CodeGenIP is the insertion point at which the body code should be
621+ // / placed.
622+ // / \param DeallocIPs is the list of insertion points where explicit
623+ // / deallocations, if needed, should be placed.
623624 // / \return an error, if any were triggered during execution.
624625 using BodyGenCallbackTy =
625- function_ref<Error(InsertPointTy AllocaIP, InsertPointTy CodeGenIP)>;
626+ function_ref<Error(InsertPointTy AllocIP, InsertPointTy CodeGenIP,
627+ ArrayRef<InsertPointTy> DeallocIPs)>;
626628
627629 // This is created primarily for sections construct as llvm::function_ref
628630 // (BodyGenCallbackTy) is not storable (as described in the comments of
@@ -631,7 +633,8 @@ class OpenMPIRBuilder {
631633 // /
632634 // / \return an error, if any were triggered during execution.
633635 using StorableBodyGenCallbackTy =
634- std::function<Error(InsertPointTy AllocaIP, InsertPointTy CodeGenIP)>;
636+ std::function<Error(InsertPointTy AllocIP, InsertPointTy CodeGenIP,
637+ ArrayRef<InsertPointTy> DeallocIPs)>;
635638
636639 // / Callback type for loop body code generation.
637640 // /
@@ -725,7 +728,9 @@ class OpenMPIRBuilder {
725728 // / Generator for '#omp parallel'
726729 // /
727730 // / \param Loc The insert and source location description.
728- // / \param AllocaIP The insertion points to be used for alloca instructions.
731+ // / \param AllocIP The insertion point to be used for allocations.
732+ // / \param DeallocIPs The insertion points to be used for explicit
733+ // / deallocations, if needed.
729734 // / \param BodyGenCB Callback that will generate the region code.
730735 // / \param PrivCB Callback to copy a given variable (think copy constructor).
731736 // / \param FiniCB Callback to finalize variable copies.
@@ -736,10 +741,10 @@ class OpenMPIRBuilder {
736741 // /
737742 // / \returns The insertion position *after* the parallel.
738743 LLVM_ABI InsertPointOrErrorTy createParallel (
739- const LocationDescription &Loc, InsertPointTy AllocaIP ,
740- BodyGenCallbackTy BodyGenCB, PrivatizeCallbackTy PrivCB ,
741- FinalizeCallbackTy FiniCB, Value *IfCondition , Value *NumThreads ,
742- omp::ProcBindKind ProcBind, bool IsCancellable);
744+ const LocationDescription &Loc, InsertPointTy AllocIP ,
745+ ArrayRef<InsertPointTy> DeallocIPs, BodyGenCallbackTy BodyGenCB ,
746+ PrivatizeCallbackTy PrivCB, FinalizeCallbackTy FiniCB , Value *IfCondition ,
747+ Value *NumThreads, omp::ProcBindKind ProcBind, bool IsCancellable);
743748
744749 // / Generator for the control flow structure of an OpenMP canonical loop.
745750 // /
@@ -1363,7 +1368,9 @@ class OpenMPIRBuilder {
13631368 // / Generator for `#omp task`
13641369 // /
13651370 // / \param Loc The location where the task construct was encountered.
1366- // / \param AllocaIP The insertion point to be used for alloca instructions.
1371+ // / \param AllocIP The insertion point to be used for allocations.
1372+ // / \param DeallocIPs The insertion points to be used for explicit
1373+ // / deallocations, if needed.
13671374 // / \param BodyGenCB Callback that will generate the region code.
13681375 // / \param Tied True if the task is tied, false if the task is untied.
13691376 // / \param Final i1 value which is `true` if the task is final, `false` if the
@@ -1379,21 +1386,23 @@ class OpenMPIRBuilder {
13791386 // / \param Mergeable If the given task is `mergeable`
13801387 // / \param priority `priority-value' specifies the execution order of the
13811388 // / tasks that is generated by the construct
1382- LLVM_ABI InsertPointOrErrorTy
1383- createTask ( const LocationDescription &Loc, InsertPointTy AllocaIP ,
1384- BodyGenCallbackTy BodyGenCB, bool Tied = true ,
1385- Value *Final = nullptr , Value *IfCondition = nullptr ,
1386- SmallVector<DependData> Dependencies = {}, bool Mergeable = false ,
1387- Value *EventHandle = nullptr , Value *Priority = nullptr );
1389+ LLVM_ABI InsertPointOrErrorTy createTask (
1390+ const LocationDescription &Loc, InsertPointTy AllocIP ,
1391+ ArrayRef<InsertPointTy> DeallocIPs, BodyGenCallbackTy BodyGenCB,
1392+ bool Tied = true , Value *Final = nullptr , Value *IfCondition = nullptr ,
1393+ SmallVector<DependData> Dependencies = {}, bool Mergeable = false ,
1394+ Value *EventHandle = nullptr , Value *Priority = nullptr );
13881395
13891396 // / Generator for the taskgroup construct
13901397 // /
13911398 // / \param Loc The location where the taskgroup construct was encountered.
1392- // / \param AllocaIP The insertion point to be used for alloca instructions.
1399+ // / \param AllocIP The insertion point to be used for allocations.
1400+ // / \param DeallocIPs The insertion point to be used for explicit deallocation
1401+ // / instructions, if needed.
13931402 // / \param BodyGenCB Callback that will generate the region code.
1394- LLVM_ABI InsertPointOrErrorTy createTaskgroup (const LocationDescription &Loc,
1395- InsertPointTy AllocaIP ,
1396- BodyGenCallbackTy BodyGenCB);
1403+ LLVM_ABI InsertPointOrErrorTy createTaskgroup (
1404+ const LocationDescription &Loc, InsertPointTy AllocIP ,
1405+ ArrayRef<InsertPointTy> DeallocIPs, BodyGenCallbackTy BodyGenCB);
13971406
13981407 using FileIdentifierInfoCallbackTy =
13991408 std::function<std::tuple<std::string, uint64_t >()>;
@@ -2262,7 +2271,8 @@ class OpenMPIRBuilder {
22622271 struct OutlineInfo {
22632272 using PostOutlineCBTy = std::function<void (Function &)>;
22642273 PostOutlineCBTy PostOutlineCB;
2265- BasicBlock *EntryBB, *ExitBB, *OuterAllocaBB;
2274+ BasicBlock *EntryBB, *ExitBB, *OuterAllocBB;
2275+ SmallVector<BasicBlock *> OuterDeallocBBs;
22662276 SmallVector<Value *, 2 > ExcludeArgsFromAggregate;
22672277
22682278 LLVM_ABI virtual ~OutlineInfo () = default ;
@@ -2335,7 +2345,8 @@ class OpenMPIRBuilder {
23352345 // / \return an error, if any were triggered during execution.
23362346 LLVM_ABI Error emitIfClause (Value *Cond, BodyGenCallbackTy ThenGen,
23372347 BodyGenCallbackTy ElseGen,
2338- InsertPointTy AllocaIP = {});
2348+ InsertPointTy AllocIP = {},
2349+ ArrayRef<InsertPointTy> DeallocIPs = {});
23392350
23402351 // / Create the global variable holding the offload mappings information.
23412352 LLVM_ABI GlobalVariable *
@@ -2891,11 +2902,13 @@ class OpenMPIRBuilder {
28912902 // / Generator for `#omp distribute`
28922903 // /
28932904 // / \param Loc The location where the distribute construct was encountered.
2894- // / \param AllocaIP The insertion points to be used for alloca instructions.
2905+ // / \param AllocIP The insertion point to be used for allocations.
2906+ // / \param DeallocIPs The insertion points to be used for explicit
2907+ // / deallocations, if needed.
28952908 // / \param BodyGenCB Callback that will generate the region code.
2896- LLVM_ABI InsertPointOrErrorTy createDistribute (const LocationDescription &Loc,
2897- InsertPointTy AllocaIP ,
2898- BodyGenCallbackTy BodyGenCB);
2909+ LLVM_ABI InsertPointOrErrorTy createDistribute (
2910+ const LocationDescription &Loc, InsertPointTy AllocIP ,
2911+ ArrayRef<InsertPointTy> DeallocIPs, BodyGenCallbackTy BodyGenCB);
28992912
29002913 // / Generate conditional branch and relevant BasicBlocks through which private
29012914 // / threads copy the 'copyin' variables from Master copy to threadprivate
@@ -3223,9 +3236,11 @@ class OpenMPIRBuilder {
32233236 // / Generator for '#omp target data'
32243237 // /
32253238 // / \param Loc The location where the target data construct was encountered.
3226- // / \param AllocaIP The insertion points to be used for alloca instructions .
3239+ // / \param AllocIP The insertion points to be used for allocations .
32273240 // / \param CodeGenIP The insertion point at which the target directive code
32283241 // / should be placed.
3242+ // / \param DeallocIPs The insertion points at which explicit deallocations
3243+ // / should be placed, if needed.
32293244 // / \param IsBegin If true then emits begin mapper call otherwise emits
32303245 // / end mapper call.
32313246 // / \param DeviceID Stores the DeviceID from the device clause.
@@ -3238,10 +3253,10 @@ class OpenMPIRBuilder {
32383253 // / \param DeviceAddrCB Optional callback to generate code related to
32393254 // / use_device_ptr and use_device_addr.
32403255 LLVM_ABI InsertPointOrErrorTy createTargetData (
3241- const LocationDescription &Loc, InsertPointTy AllocaIP ,
3242- InsertPointTy CodeGenIP, Value *DeviceID, Value *IfCond ,
3243- TargetDataInfo &Info, GenMapInfoCallbackTy GenMapInfoCB ,
3244- CustomMapperCallbackTy CustomMapperCB,
3256+ const LocationDescription &Loc, InsertPointTy AllocIP ,
3257+ InsertPointTy CodeGenIP, ArrayRef<InsertPointTy> DeallocIPs ,
3258+ Value *DeviceID, Value *IfCond, TargetDataInfo &Info ,
3259+ GenMapInfoCallbackTy GenMapInfoCB, CustomMapperCallbackTy CustomMapperCB,
32453260 omp::RuntimeFunction *MapperFunc = nullptr ,
32463261 function_ref<InsertPointOrErrorTy(InsertPointTy CodeGenIP,
32473262 BodyGenTy BodyGenType)>
@@ -3250,7 +3265,8 @@ class OpenMPIRBuilder {
32503265 Value *SrcLocInfo = nullptr);
32513266
32523267 using TargetBodyGenCallbackTy = function_ref<InsertPointOrErrorTy(
3253- InsertPointTy AllocaIP, InsertPointTy CodeGenIP)>;
3268+ InsertPointTy AllocIP, InsertPointTy CodeGenIP,
3269+ ArrayRef<InsertPointTy> DeallocIPs)>;
32543270
32553271 using TargetGenArgAccessorsCallbackTy = function_ref<InsertPointOrErrorTy(
32563272 Argument &Arg, Value *Input, Value *&RetVal, InsertPointTy AllocaIP,
@@ -3262,6 +3278,8 @@ class OpenMPIRBuilder {
32623278 // / \param IsOffloadEntry whether it is an offload entry.
32633279 // / \param CodeGenIP The insertion point where the call to the outlined
32643280 // / function should be emitted.
3281+ // / \param DeallocIPs The insertion points at which explicit deallocations
3282+ // / should be placed, if needed.
32653283 // / \param Info Stores all information realted to the Target directive.
32663284 // / \param EntryInfo The entry information about the function.
32673285 // / \param DefaultAttrs Structure containing the default attributes, including
@@ -3282,8 +3300,9 @@ class OpenMPIRBuilder {
32823300 // / not.
32833301 LLVM_ABI InsertPointOrErrorTy createTarget (
32843302 const LocationDescription &Loc, bool IsOffloadEntry,
3285- OpenMPIRBuilder::InsertPointTy AllocaIP,
3286- OpenMPIRBuilder::InsertPointTy CodeGenIP, TargetDataInfo &Info,
3303+ OpenMPIRBuilder::InsertPointTy AllocIP,
3304+ OpenMPIRBuilder::InsertPointTy CodeGenIP,
3305+ ArrayRef<InsertPointTy> DeallocIPs, TargetDataInfo &Info,
32873306 TargetRegionEntryInfo &EntryInfo,
32883307 const TargetKernelDefaultAttrs &DefaultAttrs,
32893308 const TargetKernelRuntimeAttrs &RuntimeAttrs, Value *IfCond,
0 commit comments