[flang-commits] [flang] [flang][OpenMP] Fix copyprivate semantic checks (PR #95799)

Leandro Lupori via flang-commits flang-commits at lists.llvm.org
Fri Jun 21 08:04:29 PDT 2024


================
@@ -2540,6 +2541,32 @@ void ResolveOmpTopLevelParts(
   });
 }
 
+static bool IsSymbolInCommonBlock(const Symbol &symbol) {
+  // If there are many symbols in common blocks, going through them all can be
+  // slow. A possible optimization is to add an OmpInCommonBlock flag to
+  // Symbol, to make it possible to quickly test if a given symbol is in a
+  // common block.
+  for (const auto &cb : symbol.owner().commonBlocks()) {
+    if (IsCommonBlockContaining(cb.second.get(), symbol)) {
+      return true;
+    }
+  }
+  return false;
+}
+
+static bool IsSymbolPredeterminedAsPrivate(const Symbol &symbol) {
----------------
luporl wrote:

Loop indices are handled by other parts of the OmpAttributeVisitor, that should run before this check and set the OmpPrivate flag in the corresponding symbols. However, I'm seeing some strange behaviors with the copyprivate check in some cases. I'll investigate it further and add some more tests.

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


More information about the flang-commits mailing list