[flang-commits] [flang] [Flang][OpenMP] Make implicitly captured scalars fully firstprivatized (PR #147442)

Leandro Lupori via flang-commits flang-commits at lists.llvm.org
Tue Jul 8 13:04:27 PDT 2025


================
@@ -2297,6 +2298,34 @@ static bool IsSymbolStaticStorageDuration(const Symbol &symbol) {
       (ultSym.flags().test(Symbol::Flag::InCommonBlock));
 }
 
+static bool IsTargetCaptureImplicitlyFirstPrivatizeable(
+    const Symbol &symbol, const Symbol::Flags &dsa) {
+  // if we're associated with any other flags we skip implicit privitization
+  // for now. If we're an allocatable, pointer or declare target, we're not
+  // implicitly firstprivitizeable under OpenMP restrictions.
+  // TODO: Relax restriction as we progress privitization and further
+  // investigate the flags we can intermix with.
+  if (!dsa.none() || !symbol.flags().none() ||
----------------
luporl wrote:

It's possible that other flags not related to DSA may be set.
If you want to consider only DSA and data-mapping related flags, you can use:
`(dsa & (dataSharingAttributeFlags | dataMappingAttributeFlags)).none()`

Note that `dataMappingAttributeFlags` would need to be moved from OmpAttributeVisitor::ResolveOmpObject() to OmpAttributeVisitor.

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


More information about the flang-commits mailing list