Skip to content

Commit 4b3c1dc

Browse files
committed
Support char types
The way boxchars are handled isn't ideal, but !fir.ref<!fir.boxchar<>> seems to violate a lot of assumptions in the wider ecosystem of (hl)fir helpers making it difficult to generate a copy region. I suspect !fir.ref<!fir.boxchar<>> is not supposed to work (it looks like a mutable character box, which isn't possible because a boxchar should be an SSA value). Fixing this would be a big change beyond the scope of this already too large PR.
1 parent 444e16f commit 4b3c1dc

File tree

6 files changed

+105
-70
lines changed

6 files changed

+105
-70
lines changed

flang/lib/Lower/OpenMP/DataSharingProcessor.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -563,15 +563,14 @@ void DataSharingProcessor::doPrivatize(const semantics::Symbol *sym,
563563

564564
// Populate the `init` region.
565565
const bool needsInitialization =
566-
!fir::isa_trivial(allocType) ||
567-
Fortran::lower::hasDefaultInitialization(sym->GetUltimate());
566+
Fortran::lower::hasDefaultInitialization(sym->GetUltimate()) ||
567+
mlir::isa<fir::BaseBoxType>(allocType) ||
568+
mlir::isa<fir::BoxCharType>(allocType);
568569
if (needsInitialization) {
569570
mlir::Region &initRegion = result.getInitRegion();
570571
mlir::Block *initBlock = firOpBuilder.createBlock(
571572
&initRegion, /*insertPt=*/{}, {argType, argType}, {symLoc, symLoc});
572573

573-
if (fir::isa_char(allocType))
574-
TODO(symLoc, "Privatization init of characters");
575574
if (fir::isa_derived(allocType))
576575
TODO(symLoc, "Privatization init of derived types");
577576
if (Fortran::lower::hasDefaultInitialization(sym->GetUltimate()))

flang/lib/Lower/OpenMP/PrivateReductionUtils.cpp

Lines changed: 57 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,13 @@
1212

1313
#include "PrivateReductionUtils.h"
1414

15+
#include "flang/Optimizer/Builder/BoxValue.h"
16+
#include "flang/Optimizer/Builder/Character.h"
1517
#include "flang/Optimizer/Builder/FIRBuilder.h"
1618
#include "flang/Optimizer/Builder/HLFIRTools.h"
1719
#include "flang/Optimizer/Builder/Todo.h"
20+
#include "flang/Optimizer/Dialect/FIROps.h"
21+
#include "flang/Optimizer/Dialect/FIRType.h"
1822
#include "flang/Optimizer/HLFIR/HLFIROps.h"
1923
#include "flang/Optimizer/Support/FatalError.h"
2024
#include "mlir/Dialect/OpenMP/OpenMPDialect.h"
@@ -66,6 +70,21 @@ static void createCleanupRegion(fir::FirOpBuilder &builder, mlir::Location loc,
6670
return;
6771
}
6872

73+
if (auto boxCharTy = mlir::dyn_cast<fir::BoxCharType>(argType)) {
74+
auto [addr, len] =
75+
fir::factory::CharacterExprHelper{builder, loc}.createUnboxChar(
76+
block->getArgument(0));
77+
78+
// convert addr to a heap type so it can be used with fir::FreeMemOp
79+
auto refTy = mlir::cast<fir::ReferenceType>(addr.getType());
80+
auto heapTy = fir::HeapType::get(refTy.getEleTy());
81+
addr = builder.createConvert(loc, heapTy, addr);
82+
83+
builder.create<fir::FreeMemOp>(loc, addr);
84+
builder.create<mlir::omp::YieldOp>(loc);
85+
return;
86+
}
87+
6988
typeError();
7089
}
7190

@@ -129,14 +148,18 @@ void Fortran::lower::omp::populateByRefInitAndCleanupRegions(
129148
// }
130149
// omp.yield %box_alloca
131150
moldArg = builder.loadIfRef(loc, moldArg);
151+
mlir::SmallVector<mlir::Value> lenParams;
152+
hlfir::genLengthParameters(loc, builder, hlfir::Entity{moldArg}, lenParams);
132153
auto handleNullAllocatable = [&](mlir::Value boxAlloca) -> fir::IfOp {
133154
mlir::Value addr = builder.create<fir::BoxAddrOp>(loc, moldArg);
134155
mlir::Value isNotAllocated = builder.genIsNullAddr(loc, addr);
135156
fir::IfOp ifOp = builder.create<fir::IfOp>(loc, isNotAllocated,
136157
/*withElseRegion=*/true);
137158
builder.setInsertionPointToStart(&ifOp.getThenRegion().front());
138159
// just embox the null address and return
139-
mlir::Value nullBox = builder.create<fir::EmboxOp>(loc, ty, addr);
160+
mlir::Value nullBox =
161+
builder.create<fir::EmboxOp>(loc, ty, addr, /*shape=*/mlir::Value{},
162+
/*slice=*/mlir::Value{}, lenParams);
140163
builder.create<fir::StoreOp>(loc, nullBox, boxAlloca);
141164
return ifOp;
142165
};
@@ -149,7 +172,8 @@ void Fortran::lower::omp::populateByRefInitAndCleanupRegions(
149172
builder.setInsertionPointToEnd(initBlock);
150173
mlir::Value boxAlloca = allocatedPrivVarArg;
151174
mlir::Type innerTy = fir::unwrapRefType(boxTy.getEleTy());
152-
if (fir::isa_trivial(innerTy)) {
175+
bool isChar = fir::isa_char(innerTy);
176+
if (fir::isa_trivial(innerTy) || isChar) {
153177
// boxed non-sequence value e.g. !fir.box<!fir.heap<i32>>
154178
if (!isAllocatableOrPointer)
155179
TODO(loc,
@@ -158,10 +182,13 @@ void Fortran::lower::omp::populateByRefInitAndCleanupRegions(
158182
fir::IfOp ifUnallocated = handleNullAllocatable(boxAlloca);
159183

160184
builder.setInsertionPointToStart(&ifUnallocated.getElseRegion().front());
161-
mlir::Value valAlloc = builder.create<fir::AllocMemOp>(loc, innerTy);
185+
mlir::Value valAlloc = builder.createHeapTemporary(
186+
loc, innerTy, /*name=*/{}, /*shape=*/{}, lenParams);
162187
if (scalarInitValue)
163188
builder.createStoreWithConvert(loc, scalarInitValue, valAlloc);
164-
mlir::Value box = builder.create<fir::EmboxOp>(loc, ty, valAlloc);
189+
mlir::Value box = builder.create<fir::EmboxOp>(
190+
loc, ty, valAlloc, /*shape=*/mlir::Value{}, /*slice=*/mlir::Value{},
191+
lenParams);
165192
builder.create<fir::StoreOp>(loc, box, boxAlloca);
166193

167194
createCleanupRegion(builder, loc, argType, cleanupRegion);
@@ -170,7 +197,7 @@ void Fortran::lower::omp::populateByRefInitAndCleanupRegions(
170197
return;
171198
}
172199
innerTy = fir::extractSequenceType(boxTy);
173-
if (!mlir::isa<fir::SequenceType>(innerTy))
200+
if (!innerTy || !mlir::isa<fir::SequenceType>(innerTy))
174201
TODO(loc, "Unsupported boxed type for reduction/privatization");
175202

176203
fir::IfOp ifUnallocated{nullptr};
@@ -230,6 +257,31 @@ void Fortran::lower::omp::populateByRefInitAndCleanupRegions(
230257
return;
231258
}
232259

260+
if (auto boxCharTy = mlir::dyn_cast<fir::BoxCharType>(argType)) {
261+
mlir::Type eleTy = boxCharTy.getEleTy();
262+
builder.setInsertionPointToStart(initBlock);
263+
fir::factory::CharacterExprHelper charExprHelper{builder, loc};
264+
auto [addr, len] = charExprHelper.createUnboxChar(moldArg);
265+
266+
// Using heap temporary so that
267+
// 1) It is safe to use privatization inside of big loops.
268+
// 2) The lifetime can outlive the current stack frame for delayed task
269+
// execution.
270+
// We can't always allocate a boxchar implicitly as the type of the
271+
// omp.private because the allocation potentially needs the length
272+
// parameters fetched above.
273+
// TODO: this deviates from the intended design for delayed task execution.
274+
mlir::Value privateAddr = builder.createHeapTemporary(
275+
loc, eleTy, /*name=*/{}, /*shape=*/{}, /*lenParams=*/len);
276+
mlir::Value boxChar = charExprHelper.createEmboxChar(privateAddr, len);
277+
278+
createCleanupRegion(builder, loc, argType, cleanupRegion);
279+
280+
builder.setInsertionPointToEnd(initBlock);
281+
yield(boxChar);
282+
return;
283+
}
284+
233285
TODO(loc,
234286
"creating reduction/privatization init region for unsupported type");
235287
return;

flang/test/Lower/OpenMP/delayed-privatization-character.f90

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@ subroutine delayed_privatization_character(var1, l)
2424
end subroutine
2525

2626
! DYN_LEN-LABEL: omp.private {type = firstprivate}
27-
! DYN_LEN-SAME: @[[PRIVATIZER_SYM:.*]] : [[TYPE:!fir.boxchar<1>]] alloc {
27+
! DYN_LEN-SAME: @[[PRIVATIZER_SYM:.*]] : [[TYPE:!fir.boxchar<1>]] init {
2828

29-
! DYN_LEN-NEXT: ^bb0(%[[PRIV_ARG:.*]]: [[TYPE]]):
29+
! DYN_LEN-NEXT: ^bb0(%[[PRIV_ARG:.*]]: [[TYPE]], %[[ALLOC_ARG:.*]]: [[TYPE]]):
3030
! DYN_LEN-NEXT: %[[UNBOX:.*]]:2 = fir.unboxchar %[[PRIV_ARG]]
31-
! DYN_LEN: %[[PRIV_ALLOC:.*]] = fir.alloca !fir.char<1,?>(%[[UNBOX]]#1 : index)
32-
! DYN_LEN-NEXT: %[[PRIV_DECL:.*]]:2 = hlfir.declare %[[PRIV_ALLOC]] typeparams %[[UNBOX]]#1
33-
! DYN_LEN-NEXT: omp.yield(%[[PRIV_DECL]]#0 : !fir.boxchar<1>)
31+
! DYN_LEN-NEXT: %[[PRIV_ALLOC:.*]] = fir.allocmem !fir.char<1,?>(%[[UNBOX]]#1 : index)
32+
! DYN_LEN-NEXT: %[[EMBOXCHAR:.*]] = fir.emboxchar %[[PRIV_ALLOC]], %[[UNBOX]]#1
33+
! DYN_LEN: omp.yield(%[[EMBOXCHAR]] : !fir.boxchar<1>)
3434

3535
! DYN_LEN-NEXT: } copy {
3636
! DYN_LEN-NEXT: ^bb0(%[[PRIV_ORIG_ARG:.*]]: [[TYPE]], %[[PRIV_PRIV_ARG:.*]]: [[TYPE]]):
@@ -51,9 +51,4 @@ subroutine delayed_privatization_character_static_len(var1)
5151
end subroutine
5252

5353
! STATIC_LEN-LABEL: omp.private {type = private}
54-
! STATIC_LEN-SAME: @[[PRIVATIZER_SYM:.*]] : [[TYPE:!fir.ref<!fir.char<1,10>>]] alloc {
55-
56-
! STATIC_LEN-NEXT: ^bb0(%[[PRIV_ARG:.*]]: [[TYPE]]):
57-
! STATIC_LEN-NEXT: %[[C10:.*]] = arith.constant 10 : index
58-
! STATIC_LEN-NEXT: %[[PRIV_ALLOC:.*]] = fir.alloca !fir.char<1,10>
59-
! STATIC_LEN-NEXT: %[[PRIV_DECL:.*]]:2 = hlfir.declare %[[PRIV_ALLOC]] typeparams %[[C10]]
54+
! STATIC_LEN-SAME: @[[PRIVATIZER_SYM:.*]] : [[TYPE:!fir.char<1,10>]]

flang/test/Lower/OpenMP/parallel-private-clause-fixes.f90

Lines changed: 11 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,23 @@
33
! RUN: bbc -fopenmp -emit-hlfir %s -o - \
44
! RUN: | FileCheck %s
55

6-
! CHECK: omp.private {type = private} @[[BOX_HEAP_CHAR_PRIVATIZER:_QFsub01Eaaa_private_ref_box_heap_c8xU]] : !fir.ref<!fir.box<!fir.heap<!fir.char<1,?>>>> alloc {
7-
! CHECK: ^bb0(%[[ORIG_REF:.*]]: !fir.ref<!fir.box<!fir.heap<!fir.char<1,?>>>>):
8-
! CHECK: %[[VAL_4:.*]] = fir.alloca !fir.box<!fir.heap<!fir.char<1,?>>> {bindc_name = "aaa", pinned, uniq_name = "_QFsub01Eaaa"}
6+
! CHECK: omp.private {type = private} @[[BOX_HEAP_CHAR_PRIVATIZER:_QFsub01Eaaa_private_box_heap_c8xU]] : !fir.box<!fir.heap<!fir.char<1,?>>> init {
7+
! CHECK: ^bb0(%[[ORIG_REF:.*]]: !fir.ref<!fir.box<!fir.heap<!fir.char<1,?>>>>, %[[VAL_4:.*]]: !fir.ref<!fir.box<!fir.heap<!fir.char<1,?>>>>):
98
! CHECK: %[[VAL_5:.*]] = fir.load %[[ORIG_REF]] : !fir.ref<!fir.box<!fir.heap<!fir.char<1,?>>>>
9+
! CHECK: %[[ELESIZE:.*]] = fir.box_elesize %[[VAL_5]]
1010
! CHECK: %[[VAL_6:.*]] = fir.box_addr %[[VAL_5]] : (!fir.box<!fir.heap<!fir.char<1,?>>>) -> !fir.heap<!fir.char<1,?>>
1111
! CHECK: %[[VAL_7:.*]] = fir.convert %[[VAL_6]] : (!fir.heap<!fir.char<1,?>>) -> i64
1212
! CHECK: %[[VAL_8:.*]] = arith.constant 0 : i64
13-
! CHECK: %[[VAL_9:.*]] = arith.cmpi ne, %[[VAL_7]], %[[VAL_8]] : i64
13+
! CHECK: %[[VAL_9:.*]] = arith.cmpi eq, %[[VAL_7]], %[[VAL_8]] : i64
1414
! CHECK: fir.if %[[VAL_9]] {
15-
! CHECK: %[[ELEM_SIZE:.*]] = fir.box_elesize %{{.*}} : (!fir.box<!fir.heap<!fir.char<1,?>>>) -> index
16-
! CHECK: %[[VAL_10:.*]] = arith.constant 0 : index
17-
! CHECK: %[[VAL_11:.*]] = arith.cmpi sgt, %[[ELEM_SIZE]], %[[VAL_10]] : index
18-
! CHECK: %[[VAL_12:.*]] = arith.select %[[VAL_11]], %[[ELEM_SIZE]], %[[VAL_10]] : index
19-
! CHECK: %[[VAL_13:.*]] = fir.allocmem !fir.char<1,?>(%[[VAL_12]] : index) {fir.must_be_heap = true, uniq_name = "_QFsub01Eaaa.alloc"}
20-
! CHECK: %[[VAL_14:.*]] = fir.embox %[[VAL_13]] typeparams %[[VAL_12]] : (!fir.heap<!fir.char<1,?>>, index) -> !fir.box<!fir.heap<!fir.char<1,?>>>
21-
! CHECK: fir.store %[[VAL_14]] to %[[VAL_4]] : !fir.ref<!fir.box<!fir.heap<!fir.char<1,?>>>>
22-
! CHECK: } else {
23-
! CHECK: %[[VAL_15:.*]] = fir.zero_bits !fir.heap<!fir.char<1,?>>
24-
! CHECK: %[[VAL_16:.*]] = arith.constant 0 : index
25-
! CHECK: %[[VAL_17:.*]] = fir.embox %[[VAL_15]] typeparams %[[VAL_16]] : (!fir.heap<!fir.char<1,?>>, index) -> !fir.box<!fir.heap<!fir.char<1,?>>>
15+
! CHECK: %[[VAL_17:.*]] = fir.embox %[[VAL_6]] typeparams %[[ELESIZE]] : (!fir.heap<!fir.char<1,?>>, index) -> !fir.box<!fir.heap<!fir.char<1,?>>>
2616
! CHECK: fir.store %[[VAL_17]] to %[[VAL_4]] : !fir.ref<!fir.box<!fir.heap<!fir.char<1,?>>>>
17+
! CHECK: } else {
18+
! CHECK: %[[VAL_13:.*]] = fir.allocmem !fir.char<1,?>(%[[ELESIZE]] : index)
19+
! CHECK: %[[VAL_14:.*]] = fir.embox %[[VAL_13]] typeparams %[[ELESIZE]] : (!fir.heap<!fir.char<1,?>>, index) -> !fir.box<!fir.heap<!fir.char<1,?>>>
20+
! CHECK: fir.store %[[VAL_14]] to %[[VAL_4]] : !fir.ref<!fir.box<!fir.heap<!fir.char<1,?>>>>
2721
! CHECK: }
28-
! CHECK: %[[VAL_18:.*]]:2 = hlfir.declare %[[VAL_4]] {fortran_attrs = #{{.*}}<allocatable>, uniq_name = "_QFsub01Eaaa"} : (!fir.ref<!fir.box<!fir.heap<!fir.char<1,?>>>>) -> (!fir.ref<!fir.box<!fir.heap<!fir.char<1,?>>>>, !fir.ref<!fir.box<!fir.heap<!fir.char<1,?>>>>)
29-
!CHECK: omp.yield(%[[VAL_18]]#0 : !fir.ref<!fir.box<!fir.heap<!fir.char<1,?>>>>)
22+
!CHECK: omp.yield(%[[VAL_4]] : !fir.ref<!fir.box<!fir.heap<!fir.char<1,?>>>>)
3023
!CHECK: } dealloc {
3124
!CHECK: ^bb0(%[[ORIG_REF:.*]]: !fir.ref<!fir.box<!fir.heap<!fir.char<1,?>>>>):
3225
! CHECK: %[[VAL_19:.*]] = fir.load %[[ORIG_REF]] : !fir.ref<!fir.box<!fir.heap<!fir.char<1,?>>>>
@@ -35,13 +28,7 @@
3528
! CHECK: %[[VAL_22:.*]] = arith.constant 0 : i64
3629
! CHECK: %[[VAL_23:.*]] = arith.cmpi ne, %[[VAL_21]], %[[VAL_22]] : i64
3730
! CHECK: fir.if %[[VAL_23]] {
38-
! CHECK: %[[VAL_24:.*]] = fir.load %[[ORIG_REF]] : !fir.ref<!fir.box<!fir.heap<!fir.char<1,?>>>>
39-
! CHECK: %[[VAL_25:.*]] = fir.box_addr %[[VAL_24]] : (!fir.box<!fir.heap<!fir.char<1,?>>>) -> !fir.heap<!fir.char<1,?>>
40-
! CHECK: fir.freemem %[[VAL_25]] : !fir.heap<!fir.char<1,?>>
41-
! CHECK: %[[VAL_26:.*]] = fir.zero_bits !fir.heap<!fir.char<1,?>>
42-
! CHECK: %[[VAL_27:.*]] = arith.constant 0 : index
43-
! CHECK: %[[VAL_28:.*]] = fir.embox %[[VAL_26]] typeparams %[[VAL_27]] : (!fir.heap<!fir.char<1,?>>, index) -> !fir.box<!fir.heap<!fir.char<1,?>>>
44-
! CHECK: fir.store %[[VAL_28]] to %[[ORIG_REF]] : !fir.ref<!fir.box<!fir.heap<!fir.char<1,?>>>>
31+
! CHECK: fir.freemem %[[VAL_20]] : !fir.heap<!fir.char<1,?>>
4532
!CHECK: }
4633
!CHECK: omp.yield
4734
!CHECK: }

flang/test/Lower/OpenMP/parallel-private-clause-str.f90

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,45 +8,38 @@
88
! RUN: %flang_fc1 -emit-hlfir -fopenmp -o - %s 2>&1 \
99
! RUN: | FileCheck %s
1010

11-
!CHECK: omp.private {type = private} @[[STR_ARR_PRIVATIZER:_QFtest_allocatable_string_arrayEc_private_ref_box_heap_Uxc8xU]] : !fir.ref<!fir.box<!fir.heap<!fir.array<?x!fir.char<1,?>>>>> alloc {
12-
!CHECK: ^bb0(%[[ORIG_REF:.*]]: !fir.ref<!fir.box<!fir.heap<!fir.array<?x!fir.char<1,?>>>>>):
13-
!CHECK: %[[C_PVT_BOX_REF:.*]] = fir.alloca !fir.box<!fir.heap<!fir.array<?x!fir.char<1,?>>>> {bindc_name = "c", pinned, uniq_name = "_QFtest_allocatable_string_arrayEc"}
11+
!CHECK: omp.private {type = private} @[[STR_ARR_PRIVATIZER:_QFtest_allocatable_string_arrayEc_private_box_heap_Uxc8xU]] : [[TYPE:.*]] init {
12+
!CHECK: ^bb0(%[[ORIG_REF:.*]]: !fir.ref<[[TYPE]]>, %[[C_PVT_BOX_REF:.*]]: !fir.ref<[[TYPE]]>):
1413
!CHECK: %{{.*}} = fir.load %[[ORIG_REF]] : !fir.ref<!fir.box<!fir.heap<!fir.array<?x!fir.char<1,?>>>>>
1514
!CHECK: fir.if %{{.*}} {
16-
!CHECK: %[[C_PVT_ALLOC:.*]] = fir.allocmem !fir.array<?x!fir.char<1,?>>(%{{.*}} : index), %{{.*}} {fir.must_be_heap = true, uniq_name = "_QFtest_allocatable_string_arrayEc.alloc"}
17-
!CHECK: %[[C_PVT_BOX:.*]] = fir.embox %[[C_PVT_ALLOC]](%{{.*}}) typeparams %{{.*}} : (!fir.heap<!fir.array<?x!fir.char<1,?>>>, !fir.shapeshift<1>, index) -> !fir.box<!fir.heap<!fir.array<?x!fir.char<1,?>>>>
15+
!CHECK: } else {
16+
!CHECK: %[[C_PVT_ALLOC:.*]] = fir.allocmem !fir.array<?x!fir.char<1,?>>(%{{.*}} : index), %{{.*}}
17+
!CHECK: %[[C_PVT_BOX:.*]] = fir.rebox
1818
!CHECK: fir.store %[[C_PVT_BOX]] to %[[C_PVT_BOX_REF]] : !fir.ref<!fir.box<!fir.heap<!fir.array<?x!fir.char<1,?>>>>>
1919
!CHECK: }
20-
!CHECK: %[[C_PVT_DECL:.*]]:2 = hlfir.declare %[[C_PVT_BOX_REF]] {fortran_attrs = #fir.var_attrs<allocatable>, uniq_name = "_QFtest_allocatable_string_arrayEc"} : (!fir.ref<!fir.box<!fir.heap<!fir.array<?x!fir.char<1,?>>>>>) -> (!fir.ref<!fir.box<!fir.heap<!fir.array<?x!fir.char<1,?>>>>>, !fir.ref<!fir.box<!fir.heap<!fir.array<?x!fir.char<1,?>>>>>)
21-
!CHECK: omp.yield(%[[C_PVT_DECL]]#0 : !fir.ref<!fir.box<!fir.heap<!fir.array<?x!fir.char<1,?>>>>>)
20+
!CHECK: omp.yield(%[[C_PVT_BOX_REF]] : !fir.ref<!fir.box<!fir.heap<!fir.array<?x!fir.char<1,?>>>>>)
2221
!CHECK: } dealloc {
2322
!CHECK: ^bb0(%[[ORIG_REF:.*]]: !fir.ref<!fir.box<!fir.heap<!fir.array<?x!fir.char<1,?>>>>>):
2423
!CHECK: %{{.*}} = fir.load %[[ORIG_REF]] : !fir.ref<!fir.box<!fir.heap<!fir.array<?x!fir.char<1,?>>>>>
2524
!CHECK: fir.if %{{.*}} {
26-
!CHECK: %[[C_PVT_BOX:.*]] = fir.load %[[ORIG_REF]] : !fir.ref<!fir.box<!fir.heap<!fir.array<?x!fir.char<1,?>>>>>
27-
!CHECK: %[[C_PVT_ADDR:.*]] = fir.box_addr %[[C_PVT_BOX]] : (!fir.box<!fir.heap<!fir.array<?x!fir.char<1,?>>>>) -> !fir.heap<!fir.array<?x!fir.char<1,?>>>
28-
!CHECK: fir.freemem %[[C_PVT_ADDR]] : !fir.heap<!fir.array<?x!fir.char<1,?>>>
25+
!CHECK: fir.freemem %{{.*}} : !fir.heap<!fir.array<?x!fir.char<1,?>>>
2926
!CHECK: }
3027
!CHECK: omp.yield
3128
!CHECK: }
3229

33-
!CHECK: omp.private {type = private} @[[STR_PRIVATIZER:_QFtest_allocatable_stringEc_private_ref_box_heap_c8xU]] : !fir.ref<!fir.box<!fir.heap<!fir.char<1,?>>>> alloc {
34-
!CHECK: ^bb0(%[[ORIG_REF:.*]]: !fir.ref<!fir.box<!fir.heap<!fir.char<1,?>>>>):
35-
!CHECK: %[[C_PVT_BOX_REF:.*]] = fir.alloca !fir.box<!fir.heap<!fir.char<1,?>>> {bindc_name = "c", pinned, uniq_name = "_QFtest_allocatable_stringEc"}
30+
!CHECK: omp.private {type = private} @[[STR_PRIVATIZER:_QFtest_allocatable_stringEc_private_box_heap_c8xU]] : [[TYPE:!fir.box<!fir.heap<!fir.char<1,\?>>>]] init {
31+
!CHECK: ^bb0(%[[ORIG_REF:.*]]: !fir.ref<[[TYPE]]>, %[[C_PVT_BOX_REF:.*]]: !fir.ref<[[TYPE]]>):
3632
!CHECK: %[[C_BOX:.*]] = fir.load %[[ORIG_REF]] : !fir.ref<!fir.box<!fir.heap<!fir.char<1,?>>>>
3733
!CHECK: fir.if %{{.*}} {
38-
!CHECK: %[[C_PVT_MEM:.*]] = fir.allocmem !fir.char<1,?>(%{{.*}} : index) {fir.must_be_heap = true, uniq_name = "_QFtest_allocatable_stringEc.alloc"}
34+
!CHECK: %[[C_PVT_MEM:.*]] = fir.allocmem !fir.char<1,?>(%{{.*}} : index)
3935
!CHECK: %[[C_PVT_BOX:.*]] = fir.embox %[[C_PVT_MEM]] typeparams %{{.*}} : (!fir.heap<!fir.char<1,?>>, index) -> !fir.box<!fir.heap<!fir.char<1,?>>>
4036
!CHECK: fir.store %[[C_PVT_BOX]] to %[[C_PVT_BOX_REF]] : !fir.ref<!fir.box<!fir.heap<!fir.char<1,?>>>>
4137
!CHECK: }
42-
!CHECK: %[[C_PVT_DECL:.*]]:2 = hlfir.declare %[[C_PVT_BOX_REF]] {fortran_attrs = #fir.var_attrs<allocatable>, uniq_name = "_QFtest_allocatable_stringEc"} : (!fir.ref<!fir.box<!fir.heap<!fir.char<1,?>>>>) -> (!fir.ref<!fir.box<!fir.heap<!fir.char<1,?>>>>, !fir.ref<!fir.box<!fir.heap<!fir.char<1,?>>>>)
43-
!CHECK: omp.yield(%[[C_PVT_DECL]]#0 : !fir.ref<!fir.box<!fir.heap<!fir.char<1,?>>>>)
38+
!CHECK: omp.yield(%[[C_PVT_BOX_REF]] : !fir.ref<!fir.box<!fir.heap<!fir.char<1,?>>>>)
4439
!CHECK: } dealloc {
4540
!CHECK: ^bb0(%[[ORIG_REF:.*]]: !fir.ref<!fir.box<!fir.heap<!fir.char<1,?>>>>):
4641
!CHECK: fir.if %{{.*}} {
47-
!CHECK: %[[C_PVT_BOX:.*]] = fir.load %[[ORIG_REF]] : !fir.ref<!fir.box<!fir.heap<!fir.char<1,?>>>>
48-
!CHECK: %[[C_PVT_BOX_ADDR:.*]] = fir.box_addr %[[C_PVT_BOX]] : (!fir.box<!fir.heap<!fir.char<1,?>>>) -> !fir.heap<!fir.char<1,?>>
49-
!CHECK: fir.freemem %[[C_PVT_BOX_ADDR]] : !fir.heap<!fir.char<1,?>>
42+
!CHECK: fir.freemem %{{.*}} : !fir.heap<!fir.char<1,?>>
5043
!CHECK: }
5144
!CHECK: omp.yield
5245
!CHECK: }

0 commit comments

Comments
 (0)