[flang-commits] [flang] [flang][OpenMP] Fix construct privatization in default clause (PR #72510)

via flang-commits flang-commits at lists.llvm.org
Tue Feb 20 10:55:55 PST 2024


================
@@ -426,14 +425,10 @@ void DataSharingProcessor::collectSymbols(
                              /*collectSymbols=*/true,
                              /*collectHostAssociatedSymbols=*/true);
   for (Fortran::lower::pft::Evaluation &e : eval.getNestedEvaluations()) {
-    if (e.hasNestedEvaluations())
+    if (e.hasNestedEvaluations() && !e.isConstruct())
----------------
NimishMishra wrote:

Hello @kiranchandramohan,

        I  re-looked at the possibility of handling the entire default clause at one place. For instance, I checked whether we can handle it completely during lowering. One possible way:

1. Use a function similar to `collectSymbolSet` with a bool `checkFlag`, such that the function checks symbol flag iff `checkFlag = True`, otherwise it simply adds the symbol to the symbol list.

2. Given any OpenMP context, all symbols encountered in the same context can then be collected through `checkFlag = True`. In other words, any symbol in the same region where `default(private)` is specified should only collect symbols with the `private` data-sharing attribute. However, any symbol in a nested region can be collected irrespective of the specified flag on that symbol.

This approach, unfortunately, does not work without the symbol modifications we currently do in semantics.

For your question on handling OpenMP and non OpenMP constructs in semantics itself, currently, both are being handled. It's just that while lowering, for nested OpenMP constructs, we need to collect host-associated symbols as well. For non-OpenMP constructs, we skip host-associated symbols.

I tried a few variations in which to simply this (use a single list `defaultSymbols` instead of two lists: `defaultSymbols` and `symbolsInNestedRegions`). But so far, nothing concrete has come up...

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


More information about the flang-commits mailing list