[flang-commits] [flang] [mlir] [flang][OpenMP] Lower allocator-backed storage for allocate clauses (PR #211621)
Tom Eccles via flang-commits
flang-commits at lists.llvm.org
Fri Jul 24 07:00:25 PDT 2026
================
@@ -3498,6 +3285,59 @@ genParallelOp(lower::AbstractConverter &converter, lower::SymMap &symTable,
assert((!enableDelayedPrivatization || dsp) &&
"expected valid DataSharingProcessor");
+ if (!clauseOps.allocateVars.empty()) {
+ llvm::DenseMap<const semantics::Symbol *, int64_t> privateSlots;
+ for (auto [index, object] : llvm::enumerate(args.priv.objects)) {
+ const semantics::Symbol *symbol = object.sym();
+ if (!symbol)
+ TODO(loc, "ALLOCATE clause private item without a semantic symbol");
+ const semantics::Symbol *ultimate = &symbol->GetUltimate();
+ if (!privateSlots.try_emplace(ultimate, index).second)
+ TODO(loc, "ALLOCATE clause item has multiple private storage slots");
+ }
+
+ llvm::DenseSet<const semantics::Symbol *> allocateSymbols;
+ for (const Clause &clause : item->clauses) {
+ if (clause.id != llvm::omp::Clause::OMPC_allocate)
+ continue;
+ const auto &allocate = std::get<clause::Allocate>(clause.u);
+ const auto &objects = std::get<ObjectList>(allocate.t);
+ for (const Object &object : objects) {
+ const semantics::Symbol *symbol = object.sym();
+ if (!symbol)
+ TODO(loc, "ALLOCATE clause item without a semantic symbol");
+ const semantics::Symbol *ultimate = &symbol->GetUltimate();
+ if (!allocateSymbols.insert(ultimate).second)
+ TODO(loc, "ALLOCATE clause item appears more than once");
+
+ auto privateSlot = privateSlots.find(ultimate);
+ if (privateSlot == privateSlots.end())
+ TODO(loc, "ALLOCATE clause item has no private storage slot");
+
+ auto type = evaluate::DynamicType::From(*ultimate);
+ bool supportedDataSharing =
+ symbol->test(semantics::Symbol::Flag::OmpPrivate) ||
+ symbol->test(semantics::Symbol::Flag::OmpFirstPrivate);
+ bool supportedType =
+ ultimate->Rank() == 0 &&
+ !semantics::IsAllocatableOrPointer(*ultimate) && type &&
+ type->category() != common::TypeCategory::Derived &&
+ !type->RequiresDescriptor() &&
+ !type->HasDeferredOrAssumedTypeParameter();
+ if (!supportedDataSharing || !supportedType)
+ TODO(loc,
+ "ALLOCATE clause currently supports only fixed-size intrinsic "
+ "scalar PRIVATE or FIRSTPRIVATE items");
----------------
tblah wrote:
This looks like a correct usage of TODO
https://github.com/llvm/llvm-project/pull/211621
More information about the flang-commits
mailing list