[flang-commits] [flang] [llvm] [flang][OpenMP] Try to unify induction var privatization for OMP regions. (PR #91116)

Kareem Ergawy via flang-commits flang-commits at lists.llvm.org
Tue May 14 21:23:48 PDT 2024


================
@@ -330,25 +353,46 @@ void DataSharingProcessor::collectSymbols(
   converter.collectSymbolSet(eval, allSymbols, flag,
                              /*collectSymbols=*/true,
                              /*collectHostAssociatedSymbols=*/true);
+
   llvm::SetVector<const Fortran::semantics::Symbol *> symbolsInNestedRegions;
   collectSymbolsInNestedRegions(eval, flag, symbolsInNestedRegions);
   // Filter-out symbols that must not be privatized.
   bool collectImplicit = flag == Fortran::semantics::Symbol::Flag::OmpImplicit;
+  bool collectPreDetermined =
+      flag == Fortran::semantics::Symbol::Flag::OmpPreDetermined;
+
   auto isPrivatizable = [](const Fortran::semantics::Symbol &sym) -> bool {
     return !Fortran::semantics::IsProcedure(sym) &&
            !sym.GetUltimate().has<Fortran::semantics::DerivedTypeDetails>() &&
            !sym.GetUltimate().has<Fortran::semantics::NamelistDetails>() &&
            !Fortran::semantics::IsImpliedDoIndex(sym.GetUltimate());
   };
+
+  auto shouldCollectSymbol = [&](const Fortran::semantics::Symbol *sym) {
+    if (collectImplicit &&
+        sym->test(Fortran::semantics::Symbol::Flag::OmpImplicit) &&
+        !sym->test(Fortran::semantics::Symbol::Flag::OmpPreDetermined))
+      return true;
+
+    if (collectPreDetermined &&
+        sym->test(Fortran::semantics::Symbol::Flag::OmpPreDetermined))
+      return true;
+
+    if (!sym->test(Fortran::semantics::Symbol::Flag::OmpImplicit) &&
+        !sym->test(Fortran::semantics::Symbol::Flag::OmpPreDetermined))
+      return true;
+
+    return false;
----------------
ergawy wrote:

Thanks for the suggestion. Done.

https://github.com/llvm/llvm-project/pull/91116


More information about the flang-commits mailing list