[flang-commits] [flang] [flang][OpenMP] Initialize allocatable members of derived types (PR #120295)

Leandro Lupori via flang-commits flang-commits at lists.llvm.org
Fri Jan 10 10:09:13 PST 2025


================
@@ -165,8 +182,8 @@ bool DataSharingProcessor::needBarrier() {
   // variables.
   // Emit implicit barrier for linear clause. Maybe on somewhere else.
   for (const semantics::Symbol *sym : allPrivatizedSymbols) {
-    if (sym->test(semantics::Symbol::Flag::OmpFirstPrivate) &&
-        sym->test(semantics::Symbol::Flag::OmpLastPrivate))
+    if (sym->test(semantics::Symbol::Flag::OmpLastPrivate) &&
+        (sym->test(semantics::Symbol::Flag::OmpFirstPrivate) || callsInitClone))
----------------
luporl wrote:

This will likely affect performance, but it is certainly better than having hard-to-debug race conditions.
I'm OK with it as a temporary fix.

Later, we could rename `callsInitClone` to `needsBarrier` and set it whenever a given operation may modify a variable that is also read by other threads.

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


More information about the flang-commits mailing list