[flang-commits] [flang] [flang][OpenMP] Privatize vars referenced in statement functions (PR #103390)
Tom Eccles via flang-commits
flang-commits at lists.llvm.org
Tue Aug 20 08:21:03 PDT 2024
================
@@ -2075,13 +2084,30 @@ void OmpAttributeVisitor::Post(const parser::Name &name) {
if (found->test(semantics::Symbol::Flag::OmpThreadprivate))
return;
}
- if (!IsPrivatizable(symbol)) {
+
+ std::set<const Symbol *> stmtFunctionSymbols;
+ if (auto *stmtFunction{symbol->detailsIf<semantics::SubprogramDetails>()};
+ stmtFunction && stmtFunction->stmtFunction()) {
+ // Each non-dummy argument from a statement function must be handled too,
+ // as if it was explicitly referenced.
+ semantics::UnorderedSymbolSet symbols{
+ CollectSymbols(stmtFunction->stmtFunction().value())};
+ for (const auto &sym : symbols) {
+ if (!IsStmtFunctionDummy(sym) && IsPrivatizable(&*sym) &&
+ !IsObjectWithDSA(*sym)) {
+ stmtFunctionSymbols.insert(&*sym);
+ }
+ }
+ if (stmtFunctionSymbols.empty()) {
+ return;
+ }
+ } else if (!IsPrivatizable(symbol)) {
return;
}
// Implicitly determined DSAs
// OMP 5.2 5.1.1 - Variables Referenced in a Construct
- Symbol *lastDeclSymbol = nullptr;
+ std::vector<const Symbol *> lastDeclSymbols;
----------------
tblah wrote:
nit: `llvm::SmallVector` is preferred: https://llvm.org/docs/ProgrammersManual.html#vector
https://github.com/llvm/llvm-project/pull/103390
More information about the flang-commits
mailing list