[flang-commits] [flang] [flang][OpenMP] Fix privatization when critical is present (PR #94441)

Kareem Ergawy via flang-commits flang-commits at lists.llvm.org
Wed Jun 5 02:37:01 PDT 2024


================
@@ -262,6 +262,15 @@ void DataSharingProcessor::insertLastPrivateCompare(mlir::Operation *op) {
   }
 }
 
+static bool mayHavePrivatizations(const lower::pft::Evaluation &eval) {
----------------
ergawy wrote:

Maybe we should instead update the `OMPConstructSymbolVisitor` as such:
```diff
diff --git a/flang/lib/Lower/OpenMP/DataSharingProcessor.h b/flang/lib/Lower/OpenMP/DataSharingProcessor
.h
index 80a956de35ba..d1f440f841c0 100644
--- a/flang/lib/Lower/OpenMP/DataSharingProcessor.h
+++ b/flang/lib/Lower/OpenMP/DataSharingProcessor.h
@@ -44,7 +44,9 @@ private:
     void Post(const T &) {}
 
     bool Pre(const parser::OpenMPConstruct &omp) {
-      currentConstruct = &omp;
+      if (!std::holds_alternative<parser::OpenMPCriticalConstruct>(omp.u))
+        currentConstruct = &omp;
+
       return true;
     }
```

This way we keep the active construct tracking logic in one place (i.e. the visitor) and don't have to add a new function or a new check in `collectSymbolsInNestedRegions(...)`.

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


More information about the flang-commits mailing list