[flang-commits] [flang] [mlir] [mlir][OpenMP][flang] make private variable allocation implicit in omp.private (PR #124019)
Leandro Lupori via flang-commits
flang-commits at lists.llvm.org
Fri Jan 24 12:33:09 PST 2025
================
@@ -488,44 +502,33 @@ void DataSharingProcessor::doPrivatize(const semantics::Symbol *sym,
mlir::OpBuilder::InsertionGuard guard(firOpBuilder);
firOpBuilder.setInsertionPointToStart(moduleOp.getBody());
auto result = firOpBuilder.create<mlir::omp::PrivateClauseOp>(
- symLoc, uniquePrivatizerName, symType,
+ symLoc, uniquePrivatizerName, allocType,
isFirstPrivate ? mlir::omp::DataSharingClauseType::FirstPrivate
: mlir::omp::DataSharingClauseType::Private);
fir::ExtendedValue symExV = converter.getSymbolExtendedValue(*sym);
lower::SymMapScope outerScope(symTable);
- // Populate the `alloc` region.
- {
- mlir::Region &allocRegion = result.getAllocRegion();
- mlir::Block *allocEntryBlock = firOpBuilder.createBlock(
- &allocRegion, /*insertPt=*/{}, symType, symLoc);
-
- firOpBuilder.setInsertionPointToEnd(allocEntryBlock);
-
- fir::ExtendedValue localExV =
- hlfir::translateToExtendedValue(
- symLoc, firOpBuilder, hlfir::Entity{allocRegion.getArgument(0)},
- /*contiguousHint=*/
- evaluate::IsSimplyContiguous(*sym, converter.getFoldingContext()))
- .first;
-
- symTable.addSymbol(*sym, localExV);
- lower::SymMapScope innerScope(symTable);
- cloneSymbol(sym);
- mlir::Value cloneAddr = symTable.shallowLookupSymbol(*sym).getAddr();
- mlir::Type cloneType = cloneAddr.getType();
-
- // A `convert` op is required for variables that are storage associated
- // via `equivalence`. The problem is that these variables are declared as
- // `fir.ptr`s while their privatized storage is declared as `fir.ref`,
- // therefore we convert to proper symbol type.
- mlir::Value yieldedValue =
- (symType == cloneType) ? cloneAddr
- : firOpBuilder.createConvert(
- cloneAddr.getLoc(), symType, cloneAddr);
-
- firOpBuilder.create<mlir::omp::YieldOp>(hsb.getAddr().getLoc(),
- yieldedValue);
+ // Populate the `init` region.
+ const bool needsInitialization =
+ !fir::isa_trivial(allocType) ||
+ Fortran::lower::hasDefaultInitialization(sym->GetUltimate();
----------------
luporl wrote:
There is a closing parentheses missing here.
https://github.com/llvm/llvm-project/pull/124019
More information about the flang-commits
mailing list