[flang-commits] [flang] [mlir] [mlir][OpenMP][flang] make private variable allocation implicit in omp.private (PR #124019)
Tom Eccles via flang-commits
flang-commits at lists.llvm.org
Mon Jan 27 03:18:57 PST 2025
================
@@ -371,13 +426,15 @@ void Fortran::lower::omp::populateByRefInitAndCleanupRegions(
}
if (fir::isa_derived(ty)) {
- if (needsInitialization) {
- builder.setInsertionPointToStart(initBlock);
- mlir::Type boxedTy = fir::BoxType::get(ty);
- mlir::Value box =
- builder.create<fir::EmboxOp>(loc, boxedTy, allocatedPrivVarArg);
- fir::runtime::genDerivedTypeInitialize(builder, loc, box);
- }
+ builder.setInsertionPointToStart(initBlock);
+ mlir::Type boxedTy = fir::BoxType::get(ty);
+ mlir::Value newBox =
+ builder.create<fir::EmboxOp>(loc, boxedTy, allocatedPrivVarArg);
+ mlir::Value moldBox = builder.create<fir::EmboxOp>(loc, boxedTy, moldArg);
+ initializeIfDerivedTypeBox(
+ builder, loc, newBox, moldBox, needsInitialization,
+ /*isFirstPrivate=*/kind == DeclOperationKind::FirstPrivate);
----------------
tblah wrote:
Agreed. It is even worse than just derived types, we load `moldArg` to fetch the length parameters whether or not there really are any. That load (and probably these embox operations) get removed by DCE but not before the barriers are created.
https://github.com/llvm/llvm-project/pull/124019
More information about the flang-commits
mailing list