@@ -602,17 +602,19 @@ class OpenMPIRBuilder {
602
602
// / such InsertPoints need to be preserved, it can split the block itself
603
603
// / before calling the callback.
604
604
// /
605
- // / AllocaIP and CodeGenIP must not point to the same position.
606
- // /
607
- // / \param AllocaIP is the insertion point at which new alloca instructions
608
- // / should be placed. The BasicBlock it is pointing to must
609
- // / not be split.
610
- // / \param CodeGenIP is the insertion point at which the body code should be
611
- // / placed.
612
- // /
605
+ // / AllocIP and CodeGenIP must not point to the same position.
606
+ // /
607
+ // / \param AllocIP is the insertion point at which new allocations should
608
+ // / be placed. The BasicBlock it is pointing to must not be
609
+ // / split.
610
+ // / \param CodeGenIP is the insertion point at which the body code should be
611
+ // / placed.
612
+ // / \param DeallocIPs is the list of insertion points where explicit
613
+ // / deallocations, if needed, should be placed.
613
614
// / \return an error, if any were triggered during execution.
614
615
using BodyGenCallbackTy =
615
- function_ref<Error(InsertPointTy AllocaIP, InsertPointTy CodeGenIP)>;
616
+ function_ref<Error(InsertPointTy AllocIP, InsertPointTy CodeGenIP,
617
+ ArrayRef<InsertPointTy> DeallocIPs)>;
616
618
617
619
// This is created primarily for sections construct as llvm::function_ref
618
620
// (BodyGenCallbackTy) is not storable (as described in the comments of
@@ -621,7 +623,8 @@ class OpenMPIRBuilder {
621
623
// /
622
624
// / \return an error, if any were triggered during execution.
623
625
using StorableBodyGenCallbackTy =
624
- std::function<Error(InsertPointTy AllocaIP, InsertPointTy CodeGenIP)>;
626
+ std::function<Error(InsertPointTy AllocIP, InsertPointTy CodeGenIP,
627
+ ArrayRef<InsertPointTy> DeallocIPs)>;
625
628
626
629
// / Callback type for loop body code generation.
627
630
// /
@@ -715,7 +718,9 @@ class OpenMPIRBuilder {
715
718
// / Generator for '#omp parallel'
716
719
// /
717
720
// / \param Loc The insert and source location description.
718
- // / \param AllocaIP The insertion points to be used for alloca instructions.
721
+ // / \param AllocIP The insertion point to be used for allocations.
722
+ // / \param DeallocIPs The insertion points to be used for explicit
723
+ // / deallocations, if needed.
719
724
// / \param BodyGenCB Callback that will generate the region code.
720
725
// / \param PrivCB Callback to copy a given variable (think copy constructor).
721
726
// / \param FiniCB Callback to finalize variable copies.
@@ -726,10 +731,10 @@ class OpenMPIRBuilder {
726
731
// /
727
732
// / \returns The insertion position *after* the parallel.
728
733
LLVM_ABI InsertPointOrErrorTy createParallel (
729
- const LocationDescription &Loc, InsertPointTy AllocaIP ,
730
- BodyGenCallbackTy BodyGenCB, PrivatizeCallbackTy PrivCB ,
731
- FinalizeCallbackTy FiniCB, Value *IfCondition , Value *NumThreads ,
732
- omp::ProcBindKind ProcBind, bool IsCancellable);
734
+ const LocationDescription &Loc, InsertPointTy AllocIP ,
735
+ ArrayRef<InsertPointTy> DeallocIPs, BodyGenCallbackTy BodyGenCB ,
736
+ PrivatizeCallbackTy PrivCB, FinalizeCallbackTy FiniCB , Value *IfCondition ,
737
+ Value *NumThreads, omp::ProcBindKind ProcBind, bool IsCancellable);
733
738
734
739
// / Generator for the control flow structure of an OpenMP canonical loop.
735
740
// /
@@ -1347,7 +1352,9 @@ class OpenMPIRBuilder {
1347
1352
// / Generator for `#omp task`
1348
1353
// /
1349
1354
// / \param Loc The location where the task construct was encountered.
1350
- // / \param AllocaIP The insertion point to be used for alloca instructions.
1355
+ // / \param AllocIP The insertion point to be used for allocations.
1356
+ // / \param DeallocIPs The insertion points to be used for explicit
1357
+ // / deallocations, if needed.
1351
1358
// / \param BodyGenCB Callback that will generate the region code.
1352
1359
// / \param Tied True if the task is tied, false if the task is untied.
1353
1360
// / \param Final i1 value which is `true` if the task is final, `false` if the
@@ -1363,21 +1370,23 @@ class OpenMPIRBuilder {
1363
1370
// / \param Mergeable If the given task is `mergeable`
1364
1371
// / \param priority `priority-value' specifies the execution order of the
1365
1372
// / tasks that is generated by the construct
1366
- LLVM_ABI InsertPointOrErrorTy
1367
- createTask ( const LocationDescription &Loc, InsertPointTy AllocaIP ,
1368
- BodyGenCallbackTy BodyGenCB, bool Tied = true ,
1369
- Value *Final = nullptr , Value *IfCondition = nullptr ,
1370
- SmallVector<DependData> Dependencies = {}, bool Mergeable = false ,
1371
- Value *EventHandle = nullptr , Value *Priority = nullptr );
1373
+ LLVM_ABI InsertPointOrErrorTy createTask (
1374
+ const LocationDescription &Loc, InsertPointTy AllocIP ,
1375
+ ArrayRef<InsertPointTy> DeallocIPs, BodyGenCallbackTy BodyGenCB,
1376
+ bool Tied = true , Value *Final = nullptr , Value *IfCondition = nullptr ,
1377
+ SmallVector<DependData> Dependencies = {}, bool Mergeable = false ,
1378
+ Value *EventHandle = nullptr , Value *Priority = nullptr );
1372
1379
1373
1380
// / Generator for the taskgroup construct
1374
1381
// /
1375
1382
// / \param Loc The location where the taskgroup construct was encountered.
1376
- // / \param AllocaIP The insertion point to be used for alloca instructions.
1383
+ // / \param AllocIP The insertion point to be used for allocations.
1384
+ // / \param DeallocIPs The insertion point to be used for explicit deallocation
1385
+ // / instructions, if needed.
1377
1386
// / \param BodyGenCB Callback that will generate the region code.
1378
- LLVM_ABI InsertPointOrErrorTy createTaskgroup (const LocationDescription &Loc,
1379
- InsertPointTy AllocaIP ,
1380
- BodyGenCallbackTy BodyGenCB);
1387
+ LLVM_ABI InsertPointOrErrorTy createTaskgroup (
1388
+ const LocationDescription &Loc, InsertPointTy AllocIP ,
1389
+ ArrayRef<InsertPointTy> DeallocIPs, BodyGenCallbackTy BodyGenCB);
1381
1390
1382
1391
using FileIdentifierInfoCallbackTy =
1383
1392
std::function<std::tuple<std::string, uint64_t >()>;
@@ -2246,7 +2255,8 @@ class OpenMPIRBuilder {
2246
2255
struct OutlineInfo {
2247
2256
using PostOutlineCBTy = std::function<void (Function &)>;
2248
2257
PostOutlineCBTy PostOutlineCB;
2249
- BasicBlock *EntryBB, *ExitBB, *OuterAllocaBB;
2258
+ BasicBlock *EntryBB, *ExitBB, *OuterAllocBB;
2259
+ SmallVector<BasicBlock *> OuterDeallocBBs;
2250
2260
SmallVector<Value *, 2 > ExcludeArgsFromAggregate;
2251
2261
2252
2262
LLVM_ABI virtual ~OutlineInfo () = default ;
@@ -2319,7 +2329,8 @@ class OpenMPIRBuilder {
2319
2329
// / \return an error, if any were triggered during execution.
2320
2330
LLVM_ABI Error emitIfClause (Value *Cond, BodyGenCallbackTy ThenGen,
2321
2331
BodyGenCallbackTy ElseGen,
2322
- InsertPointTy AllocaIP = {});
2332
+ InsertPointTy AllocIP = {},
2333
+ ArrayRef<InsertPointTy> DeallocIPs = {});
2323
2334
2324
2335
// / Create the global variable holding the offload mappings information.
2325
2336
LLVM_ABI GlobalVariable *
@@ -2874,11 +2885,13 @@ class OpenMPIRBuilder {
2874
2885
// / Generator for `#omp distribute`
2875
2886
// /
2876
2887
// / \param Loc The location where the distribute construct was encountered.
2877
- // / \param AllocaIP The insertion points to be used for alloca instructions.
2888
+ // / \param AllocIP The insertion point to be used for allocations.
2889
+ // / \param DeallocIPs The insertion points to be used for explicit
2890
+ // / deallocations, if needed.
2878
2891
// / \param BodyGenCB Callback that will generate the region code.
2879
- LLVM_ABI InsertPointOrErrorTy createDistribute (const LocationDescription &Loc,
2880
- InsertPointTy AllocaIP ,
2881
- BodyGenCallbackTy BodyGenCB);
2892
+ LLVM_ABI InsertPointOrErrorTy createDistribute (
2893
+ const LocationDescription &Loc, InsertPointTy AllocIP ,
2894
+ ArrayRef<InsertPointTy> DeallocIPs, BodyGenCallbackTy BodyGenCB);
2882
2895
2883
2896
// / Generate conditional branch and relevant BasicBlocks through which private
2884
2897
// / threads copy the 'copyin' variables from Master copy to threadprivate
@@ -3206,9 +3219,11 @@ class OpenMPIRBuilder {
3206
3219
// / Generator for '#omp target data'
3207
3220
// /
3208
3221
// / \param Loc The location where the target data construct was encountered.
3209
- // / \param AllocaIP The insertion points to be used for alloca instructions .
3222
+ // / \param AllocIP The insertion points to be used for allocations .
3210
3223
// / \param CodeGenIP The insertion point at which the target directive code
3211
3224
// / should be placed.
3225
+ // / \param DeallocIPs The insertion points at which explicit deallocations
3226
+ // / should be placed, if needed.
3212
3227
// / \param IsBegin If true then emits begin mapper call otherwise emits
3213
3228
// / end mapper call.
3214
3229
// / \param DeviceID Stores the DeviceID from the device clause.
@@ -3221,10 +3236,10 @@ class OpenMPIRBuilder {
3221
3236
// / \param DeviceAddrCB Optional callback to generate code related to
3222
3237
// / use_device_ptr and use_device_addr.
3223
3238
LLVM_ABI InsertPointOrErrorTy createTargetData (
3224
- const LocationDescription &Loc, InsertPointTy AllocaIP ,
3225
- InsertPointTy CodeGenIP, Value *DeviceID, Value *IfCond ,
3226
- TargetDataInfo &Info, GenMapInfoCallbackTy GenMapInfoCB ,
3227
- CustomMapperCallbackTy CustomMapperCB,
3239
+ const LocationDescription &Loc, InsertPointTy AllocIP ,
3240
+ InsertPointTy CodeGenIP, ArrayRef<InsertPointTy> DeallocIPs ,
3241
+ Value *DeviceID, Value *IfCond, TargetDataInfo &Info ,
3242
+ GenMapInfoCallbackTy GenMapInfoCB, CustomMapperCallbackTy CustomMapperCB,
3228
3243
omp::RuntimeFunction *MapperFunc = nullptr ,
3229
3244
function_ref<InsertPointOrErrorTy(InsertPointTy CodeGenIP,
3230
3245
BodyGenTy BodyGenType)>
@@ -3233,7 +3248,8 @@ class OpenMPIRBuilder {
3233
3248
Value *SrcLocInfo = nullptr);
3234
3249
3235
3250
using TargetBodyGenCallbackTy = function_ref<InsertPointOrErrorTy(
3236
- InsertPointTy AllocaIP, InsertPointTy CodeGenIP)>;
3251
+ InsertPointTy AllocIP, InsertPointTy CodeGenIP,
3252
+ ArrayRef<InsertPointTy> DeallocIPs)>;
3237
3253
3238
3254
using TargetGenArgAccessorsCallbackTy = function_ref<InsertPointOrErrorTy(
3239
3255
Argument &Arg, Value *Input, Value *&RetVal, InsertPointTy AllocaIP,
@@ -3245,6 +3261,8 @@ class OpenMPIRBuilder {
3245
3261
// / \param IsOffloadEntry whether it is an offload entry.
3246
3262
// / \param CodeGenIP The insertion point where the call to the outlined
3247
3263
// / function should be emitted.
3264
+ // / \param DeallocIPs The insertion points at which explicit deallocations
3265
+ // / should be placed, if needed.
3248
3266
// / \param Info Stores all information realted to the Target directive.
3249
3267
// / \param EntryInfo The entry information about the function.
3250
3268
// / \param DefaultAttrs Structure containing the default attributes, including
@@ -3265,8 +3283,9 @@ class OpenMPIRBuilder {
3265
3283
// / not.
3266
3284
LLVM_ABI InsertPointOrErrorTy createTarget (
3267
3285
const LocationDescription &Loc, bool IsOffloadEntry,
3268
- OpenMPIRBuilder::InsertPointTy AllocaIP,
3269
- OpenMPIRBuilder::InsertPointTy CodeGenIP, TargetDataInfo &Info,
3286
+ OpenMPIRBuilder::InsertPointTy AllocIP,
3287
+ OpenMPIRBuilder::InsertPointTy CodeGenIP,
3288
+ ArrayRef<InsertPointTy> DeallocIPs, TargetDataInfo &Info,
3270
3289
TargetRegionEntryInfo &EntryInfo,
3271
3290
const TargetKernelDefaultAttrs &DefaultAttrs,
3272
3291
const TargetKernelRuntimeAttrs &RuntimeAttrs, Value *IfCond,
0 commit comments