Skip to content

Commit 071ca05

Browse files
committed
[mlir][OpenMP] - MLIR to LLVMIR translation support for delayed privatization of allocatables in omp.target ops
This PR adds support to translate the `private` clause from MLIR to LLVMIR when used on allocatables in the context of an `omp.target` op.
1 parent 2918a47 commit 071ca05

File tree

7 files changed

+369
-35
lines changed

7 files changed

+369
-35
lines changed

flang/lib/Optimizer/OpenMP/MapsForPrivatizedSymbols.cpp

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,6 @@ class MapsForPrivatizedSymbolsPass
4949
: public flangomp::impl::MapsForPrivatizedSymbolsPassBase<
5050
MapsForPrivatizedSymbolsPass> {
5151

52-
bool privatizerNeedsMap(omp::PrivateClauseOp &privatizer) {
53-
Region &allocRegion = privatizer.getAllocRegion();
54-
Value blockArg0 = allocRegion.getArgument(0);
55-
if (blockArg0.use_empty())
56-
return false;
57-
return true;
58-
}
5952
omp::MapInfoOp createMapInfo(Location loc, Value var,
6053
fir::FirOpBuilder &builder) {
6154
uint64_t mapTypeTo = static_cast<
@@ -134,7 +127,7 @@ class MapsForPrivatizedSymbolsPass
134127
omp::PrivateClauseOp privatizer =
135128
SymbolTable::lookupNearestSymbolFrom<omp::PrivateClauseOp>(
136129
targetOp, privatizerName);
137-
if (!privatizerNeedsMap(privatizer)) {
130+
if (!privatizer.needsMap()) {
138131
privVarMapIdx.push_back(-1);
139132
continue;
140133
}

mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,16 @@ def PrivateClauseOp : OpenMP_Op<"private", [IsolatedFromAbove, RecipeInterface]>
135135
auto &region = getDeallocRegion();
136136
return region.empty() ? nullptr : region.getArgument(0);
137137
}
138+
139+
/// privatizerNeedsMap returns true if the value being privatized in an
140+
/// omp.target p should additionally be mapped to the target region
141+
/// using a MapInfoOp. This is most common when an allocatable is privatized.
142+
/// In such cases, the descriptor is use in privatization and needs to be
143+
/// mapped on to the device.
144+
bool needsMap() {
145+
Value blockArg0 = getAllocRegion().getArgument(0);
146+
return !blockArg0.use_empty();
147+
}
138148
}];
139149

140150
let hasRegionVerifier = 1;

mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp

Lines changed: 125 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -300,10 +300,6 @@ static LogicalResult checkImplementationStatus(Operation &op) {
300300
if (privatizer.getDataSharingType() ==
301301
omp::DataSharingClauseType::FirstPrivate)
302302
result = todo("firstprivate");
303-
304-
if (!privatizer.getDeallocRegion().empty())
305-
result = op.emitError("not yet implemented: privatization of "
306-
"structures in omp.target operation");
307303
}
308304
}
309305
checkThreadLimit(op, result);
@@ -3810,6 +3806,43 @@ createDeviceArgumentAccessor(MapInfoData &mapData, llvm::Argument &arg,
38103806
return builder.saveIP();
38113807
}
38123808

3809+
/// Return the llvm::Value * corresponding to the `privateVar` that
3810+
/// is being privatized. It isn't always as simple as looking up
3811+
/// moduleTranslation with privateVar. For instance, in case of
3812+
/// an allocatable, the descriptor for the allocatable is privatized.
3813+
/// This descriptor is mapped using an MapInfoOp. So, this function
3814+
/// will return a pointer to the llvm::Value corresponding to the
3815+
/// block argument for the mapped descriptor.
3816+
static llvm::Value *
3817+
findHostAssociatedValue(Value privateVar, omp::TargetOp targetOp,
3818+
llvm::DenseMap<Value, int> &mappedPrivateVars,
3819+
llvm::IRBuilderBase &builder,
3820+
LLVM::ModuleTranslation &moduleTranslation) {
3821+
if (mappedPrivateVars.contains(privateVar)) {
3822+
int blockArgIndex = mappedPrivateVars[privateVar];
3823+
Value blockArg = targetOp.getRegion().getArgument(blockArgIndex);
3824+
Type privVarType = privateVar.getType();
3825+
Type blockArgType = blockArg.getType();
3826+
assert(isa<LLVM::LLVMPointerType>(blockArgType) &&
3827+
"A block argument corresponding to a mapped var should have "
3828+
"!llvm.ptr type");
3829+
3830+
if (privVarType == blockArg.getType())
3831+
return moduleTranslation.lookupValue(blockArg);
3832+
3833+
if (!isa<LLVM::LLVMPointerType>(privVarType)) {
3834+
// This typically happens when the privatized type is lowered from
3835+
// boxchar<KIND> and gets lowered to !llvm.struct<(ptr, i64)>. That is the
3836+
// struct/pair is passed by value. But, mapped values are passed only as
3837+
// pointers, so before we privatize, we must load the pointer.
3838+
llvm::Value *load =
3839+
builder.CreateLoad(moduleTranslation.convertType(privVarType),
3840+
moduleTranslation.lookupValue(blockArg));
3841+
return load;
3842+
}
3843+
}
3844+
return moduleTranslation.lookupValue(privateVar);
3845+
}
38133846
static LogicalResult
38143847
convertOmpTarget(Operation &opInst, llvm::IRBuilderBase &builder,
38153848
LLVM::ModuleTranslation &moduleTranslation) {
@@ -3821,6 +3854,19 @@ convertOmpTarget(Operation &opInst, llvm::IRBuilderBase &builder,
38213854
bool isTargetDevice = ompBuilder->Config.isTargetDevice();
38223855
auto parentFn = opInst.getParentOfType<LLVM::LLVMFuncOp>();
38233856
auto &targetRegion = targetOp.getRegion();
3857+
// Holds the private vars that have been mapped along with
3858+
// the block argument that corresponds to the MapInfoOp
3859+
// corresponding to the private var in question.
3860+
// So, for instance
3861+
//
3862+
// %10 = omp.map.info var_ptr(%6#0 : !fir.ref<!fir.box<!fir.heap<i32>>>, ..)
3863+
// omp.target map_entries(%10 -> %arg0) private(@box.privatizer %6#0-> %arg1)
3864+
//
3865+
// Then, %10 has been created so that the descriptor can be used by the
3866+
// privatizer
3867+
// @box.privatizer on the device side. Here we'd record {%6#0, 0} in the
3868+
// mappedPrivateVars map.
3869+
llvm::DenseMap<Value, int> mappedPrivateVars;
38243870
DataLayout dl = DataLayout(opInst.getParentOfType<ModuleOp>());
38253871
SmallVector<Value> mapVars = targetOp.getMapVars();
38263872
ArrayRef<BlockArgument> mapBlockArgs =
@@ -3832,6 +3878,55 @@ convertOmpTarget(Operation &opInst, llvm::IRBuilderBase &builder,
38323878
bool isOffloadEntry =
38333879
isTargetDevice || !ompBuilder->Config.TargetTriples.empty();
38343880

3881+
// For some private variables, the MapsForPrivatizedVariablesPass
3882+
// creates MapInfoOp instances. Go through the private variables and
3883+
// the mapped variables so that during codegeneration we are able
3884+
// to quickly look up the corresponding map variable, if any for each
3885+
// private variable.
3886+
if (!targetOp.getPrivateVars().empty() && !targetOp.getMapVars().empty()) {
3887+
auto argIface = llvm::cast<omp::BlockArgOpenMPOpInterface>(*targetOp);
3888+
OperandRange privateVars = targetOp.getPrivateVars();
3889+
std::optional<ArrayAttr> privateSyms = targetOp.getPrivateSyms();
3890+
std::optional<DenseI64ArrayAttr> privateMapIndices =
3891+
targetOp.getPrivateMapsAttr();
3892+
3893+
for (auto [privVarIdx, privVarSymPair] :
3894+
llvm::enumerate(llvm::zip_equal(privateVars, *privateSyms))) {
3895+
auto privVar = std::get<0>(privVarSymPair);
3896+
auto privSym = std::get<1>(privVarSymPair);
3897+
3898+
SymbolRefAttr privatizerName = llvm::cast<SymbolRefAttr>(privSym);
3899+
omp::PrivateClauseOp privatizer =
3900+
findPrivatizer(targetOp, privatizerName);
3901+
3902+
if (!privatizer.needsMap())
3903+
continue;
3904+
3905+
mlir::Value mappedValue =
3906+
targetOp.getMappedValueForPrivateVar(privVarIdx);
3907+
assert(mappedValue);
3908+
3909+
// The MapInfoOp defining the map var isn't really needed later.
3910+
// So, we don't store it in any datastructure. Instead, we just
3911+
// do some sanity checks on it right now.
3912+
auto mapInfoOp = mappedValue.getDefiningOp<omp::MapInfoOp>();
3913+
Type varType = mapInfoOp.getVarType();
3914+
3915+
// Check #1: Check that the type of the private variable matches
3916+
// the type of the variable being mapped.
3917+
if (!isa<LLVM::LLVMPointerType>(privVar.getType()))
3918+
assert(
3919+
varType == privVar.getType() &&
3920+
"Type of private var doesn't match the type of the mapped value");
3921+
3922+
// Ok, only 1 sanity check for now.
3923+
// Record the index of the block argument corresponding to this
3924+
// mapvar.
3925+
mappedPrivateVars.insert({privVar, argIface.getMapBlockArgsStart() +
3926+
(*privateMapIndices)[privVarIdx]});
3927+
}
3928+
}
3929+
38353930
using InsertPointTy = llvm::OpenMPIRBuilder::InsertPointTy;
38363931
auto bodyCB = [&](InsertPointTy allocaIP, InsertPointTy codeGenIP)
38373932
-> llvm::OpenMPIRBuilder::InsertPointOrErrorTy {
@@ -3858,9 +3953,10 @@ convertOmpTarget(Operation &opInst, llvm::IRBuilderBase &builder,
38583953
moduleTranslation.lookupValue(mapInfoOp.getVarPtr());
38593954
moduleTranslation.mapValue(arg, mapOpValue);
38603955
}
3861-
38623956
// Do privatization after moduleTranslation has already recorded
38633957
// mapped values.
3958+
SmallVector<llvm::Value *> llvmPrivateVars;
3959+
SmallVector<Region *> privateCleanupRegions;
38643960
if (!targetOp.getPrivateVars().empty()) {
38653961
builder.restoreIP(allocaIP);
38663962

@@ -3876,11 +3972,13 @@ convertOmpTarget(Operation &opInst, llvm::IRBuilderBase &builder,
38763972
omp::PrivateClauseOp privatizer = findPrivatizer(&opInst, privSym);
38773973
assert(privatizer.getDataSharingType() !=
38783974
omp::DataSharingClauseType::FirstPrivate &&
3879-
privatizer.getDeallocRegion().empty() &&
38803975
"unsupported privatizer");
3881-
moduleTranslation.mapValue(privatizer.getAllocMoldArg(),
3882-
moduleTranslation.lookupValue(privVar));
38833976
Region &allocRegion = privatizer.getAllocRegion();
3977+
BlockArgument allocRegionArg = allocRegion.getArgument(0);
3978+
moduleTranslation.mapValue(
3979+
allocRegionArg,
3980+
findHostAssociatedValue(privVar, targetOp, mappedPrivateVars,
3981+
builder, moduleTranslation));
38843982
SmallVector<llvm::Value *, 1> yieldedValues;
38853983
if (failed(inlineConvertOmpRegions(
38863984
allocRegion, "omp.targetop.privatizer", builder,
@@ -3889,7 +3987,12 @@ convertOmpTarget(Operation &opInst, llvm::IRBuilderBase &builder,
38893987
"failed to inline `alloc` region of `omp.private`");
38903988
}
38913989
assert(yieldedValues.size() == 1);
3892-
moduleTranslation.mapValue(privBlockArg, yieldedValues.front());
3990+
llvm::Value *llvmReplacementValue = yieldedValues.front();
3991+
moduleTranslation.mapValue(privBlockArg, llvmReplacementValue);
3992+
if (!privatizer.getDeallocRegion().empty()) {
3993+
llvmPrivateVars.push_back(llvmReplacementValue);
3994+
privateCleanupRegions.push_back(&privatizer.getDeallocRegion());
3995+
}
38933996
moduleTranslation.forgetMapping(allocRegion);
38943997
builder.restoreIP(builder.saveIP());
38953998
}
@@ -3901,6 +4004,19 @@ convertOmpTarget(Operation &opInst, llvm::IRBuilderBase &builder,
39014004
return exitBlock.takeError();
39024005

39034006
builder.SetInsertPoint(*exitBlock);
4007+
if (!llvmPrivateVars.empty()) {
4008+
assert(llvmPrivateVars.size() == privateCleanupRegions.size() &&
4009+
"Number of private variables needing cleanup not equal to number"
4010+
"of privatizers with dealloc regions");
4011+
if (failed(inlineOmpRegionCleanup(
4012+
privateCleanupRegions, llvmPrivateVars, moduleTranslation,
4013+
builder, "omp.targetop.private.cleanup",
4014+
/*shouldLoadCleanupRegionArg=*/false))) {
4015+
return llvm::createStringError(
4016+
"failed to inline `dealloc` region of `omp.private` "
4017+
"op in the target region");
4018+
}
4019+
}
39044020
return builder.saveIP();
39054021
};
39064022

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
// RUN: mlir-translate -mlir-to-llvmir %s | FileCheck %s
2+
3+
llvm.func @dealloc_foo_0(!llvm.ptr)
4+
5+
omp.private {type = private} @box.heap_privatizer0 : !llvm.ptr alloc {
6+
^bb0(%arg0: !llvm.ptr):
7+
%0 = llvm.mlir.constant(1 : i32) : i32
8+
%7 = llvm.alloca %0 x !llvm.struct<(ptr, i64, i32, i8, i8, i8, i8)> : (i32) -> !llvm.ptr
9+
omp.yield(%7 : !llvm.ptr)
10+
} dealloc {
11+
^bb0(%arg0: !llvm.ptr):
12+
llvm.call @dealloc_foo_0(%arg0) : (!llvm.ptr) -> ()
13+
omp.yield
14+
}
15+
16+
llvm.func @alloc_foo_1(!llvm.ptr)
17+
llvm.func @dealloc_foo_1(!llvm.ptr)
18+
19+
omp.private {type = private} @box.heap_privatizer1 : !llvm.ptr alloc {
20+
^bb0(%arg0: !llvm.ptr):
21+
%0 = llvm.mlir.constant(1 : i32) : i32
22+
%7 = llvm.alloca %0 x !llvm.struct<(ptr, i64, i32, i8, i8, i8, i8)> : (i32) -> !llvm.ptr
23+
llvm.call @alloc_foo_1(%arg0) : (!llvm.ptr) -> ()
24+
omp.yield(%7 : !llvm.ptr)
25+
} dealloc {
26+
^bb0(%arg0: !llvm.ptr):
27+
llvm.call @dealloc_foo_1(%arg0) : (!llvm.ptr) -> ()
28+
omp.yield
29+
}
30+
31+
llvm.func @target_allocatable_(%arg0: !llvm.ptr {fir.bindc_name = "lb"}, %arg1: !llvm.ptr {fir.bindc_name = "ub"}, %arg2: !llvm.ptr {fir.bindc_name = "l"}) attributes {fir.internal_name = "_QPtarget_allocatable"} {
32+
%6 = llvm.mlir.constant(1 : i64) : i64
33+
%7 = llvm.alloca %6 x i32 {bindc_name = "mapped_var"} : (i64) -> !llvm.ptr
34+
%13 = llvm.alloca %6 x !llvm.struct<(ptr, i64, i32, i8, i8, i8, i8)> {bindc_name = "alloc_var0"} : (i64) -> !llvm.ptr
35+
%14 = llvm.alloca %6 x !llvm.struct<(ptr, i64, i32, i8, i8, i8, i8)> {bindc_name = "alloc_var1"} : (i64) -> !llvm.ptr
36+
%53 = omp.map.info var_ptr(%7 : !llvm.ptr, i32) map_clauses(implicit, exit_release_or_enter_alloc) capture(ByCopy) -> !llvm.ptr {name = "mapped_var"}
37+
%54 = omp.map.info var_ptr(%13 : !llvm.ptr, !llvm.struct<(ptr, i64, i32, i8, i8, i8, i8)>) map_clauses(to) capture(ByRef) -> !llvm.ptr
38+
%55 = omp.map.info var_ptr(%14 : !llvm.ptr, !llvm.struct<(ptr, i64, i32, i8, i8, i8, i8)>) map_clauses(to) capture(ByRef) -> !llvm.ptr
39+
omp.target map_entries(%53 -> %arg3, %54 -> %arg4, %55 ->%arg5 : !llvm.ptr, !llvm.ptr, !llvm.ptr) private(@box.heap_privatizer0 %13 -> %arg6 [map_idx=1], @box.heap_privatizer1 %14 -> %arg7 [map_idx=2]: !llvm.ptr, !llvm.ptr) {
40+
llvm.call @use_private_var0(%arg6) : (!llvm.ptr) -> ()
41+
llvm.call @use_private_var1(%arg7) : (!llvm.ptr) -> ()
42+
omp.terminator
43+
}
44+
llvm.return
45+
}
46+
47+
48+
llvm.func @use_private_var0(!llvm.ptr) -> ()
49+
llvm.func @use_private_var1(!llvm.ptr) -> ()
50+
51+
// The first set of checks ensure that we are calling the offloaded function
52+
// with the right arguments, especially the second argument which needs to
53+
// be a memory reference to the descriptor for the privatized allocatable
54+
// CHECK: define void @target_allocatable_
55+
// CHECK-NOT: define internal void
56+
// CHECK: %[[DESC_ALLOC0:.*]] = alloca { ptr, i64, i32, i8, i8, i8, i8 }, i64 1
57+
// CHECK: %[[DESC_ALLOC1:.*]] = alloca { ptr, i64, i32, i8, i8, i8, i8 }, i64 1
58+
// CHECK: call void @__omp_offloading_[[OFFLOADED_FUNCTION:.*]](ptr {{[^,]+}},
59+
// CHECK-SAME: ptr %[[DESC_ALLOC0]], ptr %[[DESC_ALLOC1]])
60+
61+
// CHECK: define internal void @__omp_offloading_[[OFFLOADED_FUNCTION]]
62+
// CHECK-SAME: (ptr {{[^,]+}}, ptr %[[DESCRIPTOR_ARG0:[^,]+]],
63+
// CHECK-SAME: ptr %[[DESCRIPTOR_ARG1:.*]]) {
64+
65+
// `var0` privatrizer `alloc`
66+
// CHECK: %[[PRIV_DESC0:.*]] = alloca { ptr, i64, i32, i8, i8, i8, i8 }
67+
68+
// `var1` privatrizer `alloc`
69+
// CHECK: %[[PRIV_DESC1:.*]] = alloca { ptr, i64, i32, i8, i8, i8, i8 }
70+
// CHECK: call void @alloc_foo_1(ptr %[[DESCRIPTOR_ARG1]])
71+
72+
// target op body
73+
// CHECK: call void @use_private_var0(ptr %[[PRIV_DESC0]]
74+
// CHECK: call void @use_private_var1(ptr %[[PRIV_DESC1]]
75+
76+
// `var0` privatrizer `dealloc`
77+
// CHECK: call void @dealloc_foo_0(ptr %[[PRIV_DESC0]])
78+
79+
// `var1` privatrizer `dealloc`
80+
// CHECK: call void @dealloc_foo_1(ptr %[[PRIV_DESC1]])
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
// RUN: mlir-translate -mlir-to-llvmir %s | FileCheck %s
2+
3+
llvm.func @alloc_foo_1(!llvm.ptr)
4+
llvm.func @dealloc_foo_1(!llvm.ptr)
5+
6+
omp.private {type = private} @box.heap_privatizer : !llvm.ptr alloc {
7+
^bb0(%arg0: !llvm.ptr):
8+
%0 = llvm.mlir.constant(1 : i32) : i32
9+
%7 = llvm.alloca %0 x !llvm.struct<(ptr, i64, i32, i8, i8, i8, i8)> : (i32) -> !llvm.ptr
10+
llvm.call @alloc_foo_1(%arg0) : (!llvm.ptr) -> ()
11+
omp.yield(%7 : !llvm.ptr)
12+
} dealloc {
13+
^bb0(%arg0: !llvm.ptr):
14+
llvm.call @dealloc_foo_1(%arg0) : (!llvm.ptr) -> ()
15+
omp.yield
16+
}
17+
18+
llvm.func @target_allocatable_(%arg0: !llvm.ptr {fir.bindc_name = "lb"}, %arg1: !llvm.ptr {fir.bindc_name = "ub"}, %arg2: !llvm.ptr {fir.bindc_name = "l"}) attributes {fir.internal_name = "_QPtarget_allocatable"} {
19+
%0 = llvm.mlir.constant(1 : i32) : i32
20+
%1 = llvm.alloca %0 x !llvm.struct<(ptr, i64, i32, i8, i8, i8, i8)> {alignment = 8 : i64} : (i32) -> !llvm.ptr
21+
%3 = llvm.alloca %0 x !llvm.struct<(ptr, i64, i32, i8, i8, i8, i8)> {alignment = 8 : i64} : (i32) -> !llvm.ptr
22+
%4 = llvm.mlir.constant(1 : i64) : i64
23+
%5 = llvm.alloca %4 x f32 {bindc_name = "real_var"} : (i64) -> !llvm.ptr
24+
%7 = llvm.alloca %4 x i32 {bindc_name = "mapped_var"} : (i64) -> !llvm.ptr
25+
%9 = llvm.alloca %4 x !llvm.struct<(f32, f32)> {bindc_name = "comp_var"} : (i64) -> !llvm.ptr
26+
%11 = llvm.alloca %0 x !llvm.struct<(ptr, i64, i32, i8, i8, i8, i8)> {alignment = 8 : i64} : (i32) -> !llvm.ptr
27+
%13 = llvm.alloca %4 x !llvm.struct<(ptr, i64, i32, i8, i8, i8, i8)> {bindc_name = "alloc_var"} : (i64) -> !llvm.ptr
28+
%39 = llvm.load %arg2 : !llvm.ptr -> i64
29+
%52 = llvm.alloca %39 x f32 {bindc_name = "real_arr"} : (i64) -> !llvm.ptr
30+
%53 = omp.map.info var_ptr(%7 : !llvm.ptr, i32) map_clauses(implicit, exit_release_or_enter_alloc) capture(ByCopy) -> !llvm.ptr {name = "mapped_var"}
31+
%54 = omp.map.info var_ptr(%13 : !llvm.ptr, !llvm.struct<(ptr, i64, i32, i8, i8, i8, i8)>) map_clauses(to) capture(ByRef) -> !llvm.ptr
32+
omp.target map_entries(%53 -> %arg3, %54 -> %arg4 : !llvm.ptr, !llvm.ptr) private(@box.heap_privatizer %13 -> %arg5 [map_idx=1] : !llvm.ptr) {
33+
llvm.call @use_private_var(%arg5) : (!llvm.ptr) -> ()
34+
omp.terminator
35+
}
36+
llvm.return
37+
}
38+
39+
llvm.func @use_private_var(!llvm.ptr) -> ()
40+
41+
llvm.func @_FortranAAssign(!llvm.ptr, !llvm.ptr, !llvm.ptr, i32) -> !llvm.struct<()> attributes {fir.runtime, sym_visibility = "private"}
42+
43+
// The first set of checks ensure that we are calling the offloaded function
44+
// with the right arguments, especially the second argument which needs to
45+
// be a memory reference to the descriptor for the privatized allocatable
46+
// CHECK: define void @target_allocatable_
47+
// CHECK-NOT: define internal void
48+
// CHECK: %[[DESC_ALLOC:.*]] = alloca { ptr, i64, i32, i8, i8, i8, i8 }, i64 1
49+
// CHECK: call void @__omp_offloading_[[OFFLOADED_FUNCTION:.*]](ptr {{[^,]+}},
50+
// CHECK-SAME: ptr %[[DESC_ALLOC]])
51+
52+
// The second set of checks ensure that to allocate memory for the
53+
// allocatable, we are, in fact, using the memory reference of the descriptor
54+
// passed as the second argument to the offloaded function.
55+
// CHECK: define internal void @__omp_offloading_[[OFFLOADED_FUNCTION]]
56+
// CHECK-SAME: (ptr {{[^,]+}}, ptr %[[DESCRIPTOR_ARG:.*]]) {
57+
// CHECK: %[[DESC_TO_DEALLOC:.*]] = alloca { ptr, i64, i32, i8, i8, i8, i8 }
58+
// CHECK: call void @alloc_foo_1(ptr %[[DESCRIPTOR_ARG]])
59+
60+
61+
// CHECK: call void @use_private_var(ptr %[[DESC_TO_DEALLOC]]
62+
63+
// Now, check the deallocation of the private var.
64+
// CHECK: call void @dealloc_foo_1(ptr %[[DESC_TO_DEALLOC]])

0 commit comments

Comments
 (0)