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

Leandro Lupori via flang-commits flang-commits at lists.llvm.org
Fri Feb 2 05:41:39 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())
----------------
luporl wrote:

I had a hard time trying to understand how `collectSymbols()` work.
This is how I understand it:
- First, all symbols used in `eval` that match `flag` are collected into `defaultSymbols`, including host associated symbols
   (why host associated symbols need to be collected? To look at the outer scope? But if the symbol in the outer scope  matches the default DSA, does anything need to be done?)
- For each evaluation that is a direct child of `eval`:
  - If the evaluation has children and is not a Fortran construct (such as if, do, etc)
    - Add the symbols used in it, that match `flag`, to `symbolsInNestedRegions`, skipping host associated symbols
      (because otherwise symbols from the top `eval` level could also be collected?)
- Later, in `defaultPrivatize`, `symbolsInNestedRegions` are excluded from `defaultSymbols`, presumably because each nested region will handle them appropriately. Then, the remaining symbols are privatized, with some exceptions, such as procedures.

Is my understanding correct?

It would be nice to add a brief comment to `collectSymbols`, explaining what it does.

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


More information about the flang-commits mailing list