Skip to content

Commit 797f011

Browse files
authored
[flang][OpenMP] Make lastprivate work with reallocated variables (#106559)
Fixes #100951
1 parent bedac64 commit 797f011

26 files changed

+157
-187
lines changed

flang/lib/Lower/Bridge.cpp

Lines changed: 23 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -858,7 +858,7 @@ class FirConverter : public Fortran::lower::AbstractConverter {
858858

859859
copyVarHLFIR(loc, Fortran::lower::SymbolBox::Intrinsic{dst},
860860
Fortran::lower::SymbolBox::Intrinsic{src}, isAllocatable,
861-
isPointer);
861+
isPointer, Fortran::semantics::Symbol::Flags());
862862
}
863863

864864
void copyHostAssociateVar(
@@ -895,7 +895,7 @@ class FirConverter : public Fortran::lower::AbstractConverter {
895895
rhs_sb = &hsb;
896896
}
897897

898-
copyVar(sym, *lhs_sb, *rhs_sb);
898+
copyVar(sym, *lhs_sb, *rhs_sb, sym.flags());
899899

900900
if (copyAssignIP && copyAssignIP->isSet() &&
901901
sym.test(Fortran::semantics::Symbol::Flag::OmpLastPrivate)) {
@@ -1211,16 +1211,18 @@ class FirConverter : public Fortran::lower::AbstractConverter {
12111211

12121212
void copyVar(const Fortran::semantics::Symbol &sym,
12131213
const Fortran::lower::SymbolBox &lhs_sb,
1214-
const Fortran::lower::SymbolBox &rhs_sb) {
1214+
const Fortran::lower::SymbolBox &rhs_sb,
1215+
Fortran::semantics::Symbol::Flags flags) {
12151216
mlir::Location loc = genLocation(sym.name());
12161217
if (lowerToHighLevelFIR())
1217-
copyVarHLFIR(loc, lhs_sb, rhs_sb);
1218+
copyVarHLFIR(loc, lhs_sb, rhs_sb, flags);
12181219
else
12191220
copyVarFIR(loc, sym, lhs_sb, rhs_sb);
12201221
}
12211222

12221223
void copyVarHLFIR(mlir::Location loc, Fortran::lower::SymbolBox dst,
1223-
Fortran::lower::SymbolBox src) {
1224+
Fortran::lower::SymbolBox src,
1225+
Fortran::semantics::Symbol::Flags flags) {
12241226
assert(lowerToHighLevelFIR());
12251227

12261228
bool isBoxAllocatable = dst.match(
@@ -1237,51 +1239,39 @@ class FirConverter : public Fortran::lower::AbstractConverter {
12371239
},
12381240
[](const auto &box) { return false; });
12391241

1240-
copyVarHLFIR(loc, dst, src, isBoxAllocatable, isBoxPointer);
1242+
copyVarHLFIR(loc, dst, src, isBoxAllocatable, isBoxPointer, flags);
12411243
}
12421244

12431245
void copyVarHLFIR(mlir::Location loc, Fortran::lower::SymbolBox dst,
12441246
Fortran::lower::SymbolBox src, bool isAllocatable,
1245-
bool isPointer) {
1247+
bool isPointer, Fortran::semantics::Symbol::Flags flags) {
12461248
assert(lowerToHighLevelFIR());
12471249
hlfir::Entity lhs{dst.getAddr()};
12481250
hlfir::Entity rhs{src.getAddr()};
1249-
// Temporary_lhs is set to true in hlfir.assign below to avoid user
1250-
// assignment to be used and finalization to be called on the LHS.
1251-
// This may or may not be correct but mimics the current behaviour
1252-
// without HLFIR.
1251+
12531252
auto copyData = [&](hlfir::Entity l, hlfir::Entity r) {
12541253
// Dereference RHS and load it if trivial scalar.
12551254
r = hlfir::loadTrivialScalar(loc, *builder, r);
1256-
builder->create<hlfir::AssignOp>(
1257-
loc, r, l,
1258-
/*isWholeAllocatableAssignment=*/false,
1259-
/*keepLhsLengthInAllocatableAssignment=*/false,
1260-
/*temporary_lhs=*/true);
1255+
builder->create<hlfir::AssignOp>(loc, r, l, isAllocatable);
12611256
};
12621257

1263-
if (isAllocatable) {
1264-
// Deep copy allocatable if it is allocated.
1265-
// Note that when allocated, the RHS is already allocated with the LHS
1266-
// shape for copy on entry in createHostAssociateVarClone.
1267-
// For lastprivate, this assumes that the RHS was not reallocated in
1268-
// the OpenMP region.
1269-
lhs = hlfir::derefPointersAndAllocatables(loc, *builder, lhs);
1270-
mlir::Value addr = hlfir::genVariableRawAddress(loc, *builder, lhs);
1271-
mlir::Value isAllocated = builder->genIsNotNullAddr(loc, addr);
1272-
builder->genIfThen(loc, isAllocated)
1273-
.genThen([&]() {
1274-
// Copy the DATA, not the descriptors.
1275-
copyData(lhs, rhs);
1276-
})
1277-
.end();
1278-
} else if (isPointer) {
1258+
if (isPointer) {
12791259
// Set LHS target to the target of RHS (do not copy the RHS
12801260
// target data into the LHS target storage).
12811261
auto loadVal = builder->create<fir::LoadOp>(loc, rhs);
12821262
builder->create<fir::StoreOp>(loc, loadVal, lhs);
1263+
} else if (isAllocatable &&
1264+
flags.test(Fortran::semantics::Symbol::Flag::OmpFirstPrivate)) {
1265+
// For firstprivate allocatable variables, RHS must be copied only when
1266+
// LHS is allocated.
1267+
hlfir::Entity temp =
1268+
hlfir::derefPointersAndAllocatables(loc, *builder, lhs);
1269+
mlir::Value addr = hlfir::genVariableRawAddress(loc, *builder, temp);
1270+
mlir::Value isAllocated = builder->genIsNotNullAddr(loc, addr);
1271+
builder->genIfThen(loc, isAllocated)
1272+
.genThen([&]() { copyData(lhs, rhs); })
1273+
.end();
12831274
} else {
1284-
// Non ALLOCATABLE/POINTER variable. Simple DATA copy.
12851275
copyData(lhs, rhs);
12861276
}
12871277
}

flang/lib/Lower/OpenMP/DataSharingProcessor.cpp

Lines changed: 3 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -132,54 +132,9 @@ void DataSharingProcessor::copyFirstPrivateSymbol(
132132
}
133133

134134
void DataSharingProcessor::copyLastPrivateSymbol(
135-
const semantics::Symbol *sym,
136-
[[maybe_unused]] mlir::OpBuilder::InsertPoint *lastPrivIP) {
137-
if (sym->test(semantics::Symbol::Flag::OmpLastPrivate)) {
138-
bool allocatable = semantics::IsAllocatable(sym->GetUltimate());
139-
if (!allocatable) {
140-
converter.copyHostAssociateVar(*sym, lastPrivIP);
141-
return;
142-
}
143-
144-
// copyHostAssociateVar doesn't work properly if the privatised copy was
145-
// reallocated (e.g. by assignment): it will only copy if the ultimate
146-
// symbol was already allocated, and it only copies data so any reallocated
147-
// lengths etc are lost
148-
149-
// 1) Fetch the original copy of the variable.
150-
assert(sym->has<Fortran::semantics::HostAssocDetails>() &&
151-
"No host-association found");
152-
const Fortran::semantics::Symbol &hsym = sym->GetUltimate();
153-
Fortran::lower::SymbolBox hsb = symTable->lookupOneLevelUpSymbol(hsym);
154-
assert(hsb && "Host symbol box not found");
155-
156-
// 2) Fetch the copied one that will mask the original.
157-
Fortran::lower::SymbolBox sb = symTable->shallowLookupSymbol(sym);
158-
assert(sb && "Host-associated symbol box not found");
159-
assert(hsb.getAddr() != sb.getAddr() &&
160-
"Host and associated symbol boxes are the same");
161-
162-
// 3) Perform the assignment.
163-
fir::FirOpBuilder &builder = converter.getFirOpBuilder();
164-
mlir::Location loc = converter.genLocation(sym->name());
165-
mlir::OpBuilder::InsertPoint insPt = builder.saveInsertionPoint();
166-
if (lastPrivIP && lastPrivIP->isSet())
167-
builder.restoreInsertionPoint(*lastPrivIP);
168-
else
169-
builder.setInsertionPointAfter(sb.getAddr().getDefiningOp());
170-
171-
hlfir::Entity dst{hsb.getAddr()};
172-
hlfir::Entity src{sb.getAddr()};
173-
builder.create<hlfir::AssignOp>(
174-
loc, src, dst, /*isWholeAllocatableAssignment=*/allocatable,
175-
/*keepLhsLengthInAllocatableAssignment=*/false,
176-
/*temporary_lhs=*/false);
177-
178-
if (lastPrivIP && lastPrivIP->isSet() &&
179-
sym->test(Fortran::semantics::Symbol::Flag::OmpLastPrivate)) {
180-
builder.restoreInsertionPoint(insPt);
181-
}
182-
}
135+
const semantics::Symbol *sym, mlir::OpBuilder::InsertPoint *lastPrivIP) {
136+
if (sym->test(semantics::Symbol::Flag::OmpLastPrivate))
137+
converter.copyHostAssociateVar(*sym, lastPrivIP);
183138
}
184139

185140
void DataSharingProcessor::collectOmpObjectListSymbol(

flang/runtime/assign.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -591,7 +591,7 @@ void RTDEF(AssignTemporary)(Descriptor &to, const Descriptor &from,
591591
}
592592
}
593593

594-
Assign(to, from, terminator, PolymorphicLHS);
594+
Assign(to, from, terminator, MaybeReallocate | PolymorphicLHS);
595595
}
596596

597597
void RTDEF(CopyInAssign)(Descriptor &temp, const Descriptor &var,

flang/test/Lower/OpenMP/DelayedPrivatization/equivalence.f90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ subroutine private_common
2222
! CHECK: } copy {
2323
! CHECK: ^bb0(%[[ORIG_PTR:.*]]: ![[X_TYPE]], %[[PRIV_REF:.*]]: ![[X_TYPE]]):
2424
! CHECK: %[[ORIG_VAL:.*]] = fir.load %[[ORIG_PTR]] : !fir.ptr<f32>
25-
! CHECK: hlfir.assign %[[ORIG_VAL]] to %[[PRIV_REF]] temporary_lhs : f32, ![[X_TYPE]]
25+
! CHECK: hlfir.assign %[[ORIG_VAL]] to %[[PRIV_REF]] : f32, ![[X_TYPE]]
2626
! CHECK: omp.yield(%[[PRIV_REF]] : ![[X_TYPE]])
2727
! CHECK: }
2828

flang/test/Lower/OpenMP/copyin-order.f90

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66
!CHECK: %[[THP1:[0-9]+]] = omp.threadprivate %{{[0-9]+}}#1
77
!CHECK: %[[DCL1:[0-9]+]]:2 = hlfir.declare %[[THP1]] {uniq_name = "_QFcopyin_scalar_arrayEx1"}
88
!CHECK: %[[LD1:[0-9]+]] = fir.load %{{[0-9]+}}#0
9-
!CHECK: hlfir.assign %[[LD1]] to %[[DCL1]]#0 temporary_lhs
9+
!CHECK: hlfir.assign %[[LD1]] to %[[DCL1]]#0
1010
!CHECK: %[[THP2:[0-9]+]] = omp.threadprivate %{{[0-9]+}}#1
1111
!CHECK: %[[SHP2:[0-9]+]] = fir.shape %c{{[0-9]+}}
1212
!CHECK: %[[DCL2:[0-9]+]]:2 = hlfir.declare %[[THP2]](%[[SHP2]]) {uniq_name = "_QFcopyin_scalar_arrayEx2"}
13-
!CHECK: hlfir.assign %{{[0-9]+}}#0 to %[[DCL2]]#0 temporary_lhs
13+
!CHECK: hlfir.assign %{{[0-9]+}}#0 to %[[DCL2]]#0
1414
!CHECK: omp.barrier
1515
!CHECK: fir.call @_QPsub1(%[[DCL1]]#1, %[[DCL2]]#1)
1616
!CHECK: omp.terminator

flang/test/Lower/OpenMP/copyin.f90

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@
2121
! CHECK: %[[VAL_11:.*]] = omp.threadprivate %[[VAL_1]]#1 : !fir.ref<i32> -> !fir.ref<i32>
2222
! CHECK: %[[VAL_12:.*]]:2 = hlfir.declare %[[VAL_11]] {uniq_name = "_QFcopyin_scalar_arrayEx1"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>)
2323
! CHECK: %[[VAL_13:.*]] = fir.load %[[VAL_3]]#0 : !fir.ref<i32>
24-
! CHECK: hlfir.assign %[[VAL_13]] to %[[VAL_12]]#0 temporary_lhs : i32, !fir.ref<i32>
24+
! CHECK: hlfir.assign %[[VAL_13]] to %[[VAL_12]]#0 : i32, !fir.ref<i32>
2525
! CHECK: %[[VAL_14:.*]] = omp.threadprivate %[[VAL_7]]#1 : !fir.ref<!fir.array<10xi64>> -> !fir.ref<!fir.array<10xi64>>
2626
! CHECK: %[[VAL_15:.*]] = fir.shape %[[VAL_5]] : (index) -> !fir.shape<1>
2727
! CHECK: %[[VAL_16:.*]]:2 = hlfir.declare %[[VAL_14]](%[[VAL_15]]) {uniq_name = "_QFcopyin_scalar_arrayEx2"} : (!fir.ref<!fir.array<10xi64>>, !fir.shape<1>) -> (!fir.ref<!fir.array<10xi64>>, !fir.ref<!fir.array<10xi64>>)
28-
! CHECK: hlfir.assign %[[VAL_10]]#0 to %[[VAL_16]]#0 temporary_lhs : !fir.ref<!fir.array<10xi64>>, !fir.ref<!fir.array<10xi64>>
28+
! CHECK: hlfir.assign %[[VAL_10]]#0 to %[[VAL_16]]#0 : !fir.ref<!fir.array<10xi64>>, !fir.ref<!fir.array<10xi64>>
2929
! CHECK: omp.barrier
3030
! CHECK: fir.call @_QPsub1(%[[VAL_12]]#1, %[[VAL_16]]#1) fastmath<contract> : (!fir.ref<i32>, !fir.ref<!fir.array<10xi64>>) -> ()
3131
! CHECK: omp.terminator
@@ -61,11 +61,11 @@ subroutine copyin_scalar_array()
6161
! CHECK: omp.parallel {
6262
! CHECK: %[[VAL_13:.*]] = omp.threadprivate %[[VAL_2]]#1 : !fir.ref<!fir.char<1,5>> -> !fir.ref<!fir.char<1,5>>
6363
! CHECK: %[[VAL_14:.*]]:2 = hlfir.declare %[[VAL_13]] typeparams %[[VAL_1]] {uniq_name = "_QFcopyin_char_chararrayEx3"} : (!fir.ref<!fir.char<1,5>>, index) -> (!fir.ref<!fir.char<1,5>>, !fir.ref<!fir.char<1,5>>)
64-
! CHECK: hlfir.assign %[[VAL_4]]#0 to %[[VAL_14]]#0 temporary_lhs : !fir.ref<!fir.char<1,5>>, !fir.ref<!fir.char<1,5>>
64+
! CHECK: hlfir.assign %[[VAL_4]]#0 to %[[VAL_14]]#0 : !fir.ref<!fir.char<1,5>>, !fir.ref<!fir.char<1,5>>
6565
! CHECK: %[[VAL_15:.*]] = omp.threadprivate %[[VAL_9]]#1 : !fir.ref<!fir.array<10x!fir.char<1,5>>> -> !fir.ref<!fir.array<10x!fir.char<1,5>>>
6666
! CHECK: %[[VAL_16:.*]] = fir.shape %[[VAL_7]] : (index) -> !fir.shape<1>
6767
! CHECK: %[[VAL_17:.*]]:2 = hlfir.declare %[[VAL_15]](%[[VAL_16]]) typeparams %[[VAL_6]] {uniq_name = "_QFcopyin_char_chararrayEx4"} : (!fir.ref<!fir.array<10x!fir.char<1,5>>>, !fir.shape<1>, index) -> (!fir.ref<!fir.array<10x!fir.char<1,5>>>, !fir.ref<!fir.array<10x!fir.char<1,5>>>)
68-
! CHECK: hlfir.assign %[[VAL_12]]#0 to %[[VAL_17]]#0 temporary_lhs : !fir.ref<!fir.array<10x!fir.char<1,5>>>, !fir.ref<!fir.array<10x!fir.char<1,5>>>
68+
! CHECK: hlfir.assign %[[VAL_12]]#0 to %[[VAL_17]]#0 : !fir.ref<!fir.array<10x!fir.char<1,5>>>, !fir.ref<!fir.array<10x!fir.char<1,5>>>
6969
! CHECK: omp.barrier
7070
! CHECK: %[[VAL_18:.*]] = fir.emboxchar %[[VAL_14]]#1, %[[VAL_1]] : (!fir.ref<!fir.char<1,5>>, index) -> !fir.boxchar<1>
7171
! CHECK: %[[VAL_19:.*]] = fir.convert %[[VAL_17]]#1 : (!fir.ref<!fir.array<10x!fir.char<1,5>>>) -> !fir.ref<!fir.char<1,5>>
@@ -116,7 +116,7 @@ subroutine copyin_char_chararray()
116116
! CHECK: omp.parallel {
117117
! CHECK: %[[VAL_27:.*]] = omp.threadprivate %[[VAL_17]]#1 : !fir.ref<!fir.type<_QFcopyin_derived_typeTmy_type{t_i:i32,t_arr:!fir.array<5xi32>}>> -> !fir.ref<!fir.type<_QFcopyin_derived_typeTmy_type{t_i:i32,t_arr:!fir.array<5xi32>}>>
118118
! CHECK: %[[VAL_28:.*]]:2 = hlfir.declare %[[VAL_27]] {uniq_name = "_QFcopyin_derived_typeEx5"} : (!fir.ref<!fir.type<_QFcopyin_derived_typeTmy_type{t_i:i32,t_arr:!fir.array<5xi32>}>>) -> (!fir.ref<!fir.type<_QFcopyin_derived_typeTmy_type{t_i:i32,t_arr:!fir.array<5xi32>}>>, !fir.ref<!fir.type<_QFcopyin_derived_typeTmy_type{t_i:i32,t_arr:!fir.array<5xi32>}>>)
119-
! CHECK: hlfir.assign %[[VAL_19]]#0 to %[[VAL_28]]#0 temporary_lhs : !fir.ref<!fir.type<_QFcopyin_derived_typeTmy_type{t_i:i32,t_arr:!fir.array<5xi32>}>>, !fir.ref<!fir.type<_QFcopyin_derived_typeTmy_type{t_i:i32,t_arr:!fir.array<5xi32>}>>
119+
! CHECK: hlfir.assign %[[VAL_19]]#0 to %[[VAL_28]]#0 : !fir.ref<!fir.type<_QFcopyin_derived_typeTmy_type{t_i:i32,t_arr:!fir.array<5xi32>}>>, !fir.ref<!fir.type<_QFcopyin_derived_typeTmy_type{t_i:i32,t_arr:!fir.array<5xi32>}>>
120120
! CHECK: omp.barrier
121121
! CHECK: fir.call @_QPsub3(%[[VAL_28]]#1) fastmath<contract> : (!fir.ref<!fir.type<_QFcopyin_derived_typeTmy_type{t_i:i32,t_arr:!fir.array<5xi32>}>>) -> ()
122122
! CHECK: omp.terminator
@@ -150,7 +150,7 @@ subroutine copyin_derived_type()
150150
! CHECK: %[[VAL_8:.*]] = omp.threadprivate %[[VAL_3]]#1 : !fir.ref<i32> -> !fir.ref<i32>
151151
! CHECK: %[[VAL_9:.*]]:2 = hlfir.declare %[[VAL_8]] {uniq_name = "_QFcombined_parallel_worksharing_loopEx6"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>)
152152
! CHECK: %[[VAL_10:.*]] = fir.load %[[VAL_5]]#0 : !fir.ref<i32>
153-
! CHECK: hlfir.assign %[[VAL_10]] to %[[VAL_9]]#0 temporary_lhs : i32, !fir.ref<i32>
153+
! CHECK: hlfir.assign %[[VAL_10]] to %[[VAL_9]]#0 : i32, !fir.ref<i32>
154154

155155
! CHECK: omp.barrier
156156

@@ -194,7 +194,7 @@ subroutine combined_parallel_worksharing_loop()
194194
! CHECK: %[[VAL_4:.*]] = omp.threadprivate %[[VAL_1]]#1 : !fir.ref<i32> -> !fir.ref<i32>
195195
! CHECK: %[[VAL_5:.*]]:2 = hlfir.declare %[[VAL_4]] {uniq_name = "_QFcombined_parallel_sectionsEx7"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>)
196196
! CHECK: %[[VAL_6:.*]] = fir.load %[[VAL_3]]#0 : !fir.ref<i32>
197-
! CHECK: hlfir.assign %[[VAL_6]] to %[[VAL_5]]#0 temporary_lhs : i32, !fir.ref<i32>
197+
! CHECK: hlfir.assign %[[VAL_6]] to %[[VAL_5]]#0 : i32, !fir.ref<i32>
198198
! CHECK: omp.barrier
199199
! CHECK: omp.sections {
200200
! CHECK: omp.section {
@@ -247,7 +247,7 @@ subroutine combined_parallel_sections()
247247
! CHECK: %[[VAL_18:.*]] = fir.convert %[[VAL_17]] : (!fir.ref<i8>) -> !fir.ref<i32>
248248
! CHECK: %[[VAL_19:.*]]:2 = hlfir.declare %[[VAL_18]] {uniq_name = "_QFcommon_1Ex"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>)
249249
! CHECK: %[[VAL_20:.*]] = fir.load %[[VAL_11]]#0 : !fir.ref<i32>
250-
! CHECK: hlfir.assign %[[VAL_20]] to %[[VAL_19]]#0 temporary_lhs : i32, !fir.ref<i32>
250+
! CHECK: hlfir.assign %[[VAL_20]] to %[[VAL_19]]#0 : i32, !fir.ref<i32>
251251
! CHECK: omp.barrier
252252
! CHECK: omp.sections {
253253
! CHECK: omp.section {
@@ -318,9 +318,9 @@ subroutine common_1()
318318
! CHECK: %[[VAL_30:.*]] = fir.convert %[[VAL_29]] : (!fir.ref<i8>) -> !fir.ref<i32>
319319
! CHECK: %[[VAL_31:.*]]:2 = hlfir.declare %[[VAL_30]] {uniq_name = "_QFcommon_2Ey"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>)
320320
! CHECK: %[[VAL_32:.*]] = fir.load %[[VAL_13]]#0 : !fir.ref<i32>
321-
! CHECK: hlfir.assign %[[VAL_32]] to %[[VAL_26]]#0 temporary_lhs : i32, !fir.ref<i32>
321+
! CHECK: hlfir.assign %[[VAL_32]] to %[[VAL_26]]#0 : i32, !fir.ref<i32>
322322
! CHECK: %[[VAL_33:.*]] = fir.load %[[VAL_18]]#0 : !fir.ref<i32>
323-
! CHECK: hlfir.assign %[[VAL_33]] to %[[VAL_31]]#0 temporary_lhs : i32, !fir.ref<i32>
323+
! CHECK: hlfir.assign %[[VAL_33]] to %[[VAL_31]]#0 : i32, !fir.ref<i32>
324324
! CHECK: omp.barrier
325325

326326
! CHECK: %[[VAL_19:.*]] = fir.alloca i32 {bindc_name = "i", pinned, {{.*}}}

flang/test/Lower/OpenMP/copyprivate.f90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
!CHECK-NEXT: %[[DST:.*]]:2 = hlfir.declare %[[ARG0]] {uniq_name = "_copy_i32_dst"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>)
3636
!CHECK-NEXT: %[[SRC:.*]]:2 = hlfir.declare %[[ARG1]] {uniq_name = "_copy_i32_src"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>)
3737
!CHECK-NEXT: %[[SRC_VAL:.*]] = fir.load %[[SRC]]#0 : !fir.ref<i32>
38-
!CHECK-NEXT: hlfir.assign %[[SRC_VAL]] to %[[DST]]#0 temporary_lhs : i32, !fir.ref<i32>
38+
!CHECK-NEXT: hlfir.assign %[[SRC_VAL]] to %[[DST]]#0 : i32, !fir.ref<i32>
3939
!CHECK-NEXT: return
4040
!CHECK-NEXT: }
4141

flang/test/Lower/OpenMP/copyprivate2.f90

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,9 @@
2424
!CHECK-NEXT: %[[SRC:.*]]:2 = hlfir.declare %[[ARG1]] {fortran_attrs = #fir.var_attrs<allocatable>,
2525
!CHECK-SAME: uniq_name = "_copy_box_heap_Uxi32_src"} : (!fir.ref<!fir.box<!fir.heap<!fir.array<?xi32>>>>) ->
2626
!CHECK-SAME: (!fir.ref<!fir.box<!fir.heap<!fir.array<?xi32>>>>, !fir.ref<!fir.box<!fir.heap<!fir.array<?xi32>>>>)
27-
!CHECK-NEXT: %[[DST_BOX:.*]] = fir.load %[[DST]]#0 : !fir.ref<!fir.box<!fir.heap<!fir.array<?xi32>>>>
28-
!CHECK: fir.if %{{.*}} {
29-
!CHECK-NEXT: %[[SRC_BOX:.*]] = fir.load %[[SRC]]#0 : !fir.ref<!fir.box<!fir.heap<!fir.array<?xi32>>>>
30-
!CHECK-NEXT: hlfir.assign %[[SRC_BOX]] to %[[DST_BOX]] temporary_lhs : !fir.box<!fir.heap<!fir.array<?xi32>>>,
31-
!CHECK-SAME: !fir.box<!fir.heap<!fir.array<?xi32>>>
32-
!CHECK-NEXT: }
27+
!CHECK-NEXT: %[[SRC_BOX:.*]] = fir.load %[[SRC]]#0 : !fir.ref<!fir.box<!fir.heap<!fir.array<?xi32>>>>
28+
!CHECK-NEXT: hlfir.assign %[[SRC_BOX]] to %[[DST]]#0 realloc : !fir.box<!fir.heap<!fir.array<?xi32>>>,
29+
!CHECK-SAME: !fir.box<!fir.heap<!fir.array<?xi32>>>
3330
!CHECK-NEXT: return
3431
!CHECK-NEXT: }
3532

flang/test/Lower/OpenMP/default-clause-byref.f90

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
!CHECK: } copy {
1616
!CHECK: ^bb0(%[[ORIG_W:.*]]: !fir.ref<i32>, %[[PRIV_W:.*]]: !fir.ref<i32>):
1717
!CHECK: %[[ORIG_W_VAL:.*]] = fir.load %[[ORIG_W]]
18-
!CHECK: hlfir.assign %[[ORIG_W_VAL]] to %[[PRIV_W]] temporary_lhs
18+
!CHECK: hlfir.assign %[[ORIG_W_VAL]] to %[[PRIV_W]]
1919
!CHECK: omp.yield(%[[PRIV_W]] : !fir.ref<i32>)
2020
!CHECK: }
2121

@@ -27,7 +27,7 @@
2727
!CHECK: } copy {
2828
!CHECK: ^bb0(%[[ORIG_Y:.*]]: !fir.ref<i32>, %[[PRIV_Y:.*]]: !fir.ref<i32>):
2929
!CHECK: %[[ORIG_Y_VAL:.*]] = fir.load %[[ORIG_Y]]
30-
!CHECK: hlfir.assign %[[ORIG_Y_VAL]] to %[[PRIV_Y]] temporary_lhs
30+
!CHECK: hlfir.assign %[[ORIG_Y_VAL]] to %[[PRIV_Y]]
3131
!CHECK: omp.yield(%[[PRIV_Y]] : !fir.ref<i32>)
3232
!CHECK: }
3333

@@ -60,7 +60,7 @@
6060
!CHECK: } copy {
6161
!CHECK: ^bb0(%[[ORIG_X:.*]]: !fir.ref<i32>, %[[PRIV_X:.*]]: !fir.ref<i32>):
6262
!CHECK: %[[ORIG_X_VAL:.*]] = fir.load %[[ORIG_X]]
63-
!CHECK: hlfir.assign %[[ORIG_X_VAL]] to %[[PRIV_X]] temporary_lhs
63+
!CHECK: hlfir.assign %[[ORIG_X_VAL]] to %[[PRIV_X]]
6464
!CHECK: omp.yield(%[[PRIV_X]] : !fir.ref<i32>)
6565
!CHECK: }
6666

flang/test/Lower/OpenMP/delayed-privatization-allocatable-array.f90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ subroutine delayed_privatization_private(var1, l1)
6161

6262
! CHECK-NEXT: fir.if %[[COPY_COND]] {
6363
! CHECK-NEXT: %[[PRIV_ORIG_ARG_VAL:.*]] = fir.load %[[PRIV_ORIG_ARG]]
64-
! CHECK-NEXT: hlfir.assign %[[PRIV_ORIG_ARG_VAL]] to %[[PRIV_BASE_VAL]] temporary_lhs
64+
! CHECK-NEXT: hlfir.assign %[[PRIV_ORIG_ARG_VAL]] to %[[PRIV_PRIV_ARG]] realloc
6565
! CHECK-NEXT: }
6666
! CHECK-NEXT: omp.yield
6767
! CHECK-NEXT: }

flang/test/Lower/OpenMP/delayed-privatization-allocatable-firstprivate.f90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ subroutine delayed_privatization_allocatable
3535
! CHECK-NEXT: %[[ORIG_BASE_VAL:.*]] = fir.load %[[PRIV_ORIG_ARG]]
3636
! CHECK-NEXT: %[[ORIG_BASE_ADDR:.*]] = fir.box_addr %[[ORIG_BASE_VAL]]
3737
! CHECK-NEXT: %[[ORIG_BASE_LD:.*]] = fir.load %[[ORIG_BASE_ADDR]]
38-
! CHECK-NEXT: hlfir.assign %[[ORIG_BASE_LD]] to %[[PRIV_BASE_BOX]] temporary_lhs
38+
! CHECK-NEXT: hlfir.assign %[[ORIG_BASE_LD]] to %[[PRIV_PRIV_ARG]] realloc
3939
! CHECK-NEXT: }
4040

4141
! RUN: %flang -c -emit-llvm -fopenmp -mmlir --openmp-enable-delayed-privatization \

0 commit comments

Comments
 (0)