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

via flang-commits flang-commits at lists.llvm.org
Thu May 16 22:27:50 PDT 2024


NimishMishra wrote:

> @NimishMishra Could you remind me why we want to skip collecting symbols in nested OpenMP regions?

Sure @kiranchandramohan. We need to do that since `defaultSymbols` captures both the symbol and its host association. In the nested OpenMP region, we collect the nested symbol (but not the host associations, that is why we set `checkHostAssociatedSymbols = false` in nested regions).

If we don't do this, then privatization fails due to already existing bindings.

```
      std::function<void(const Fortran::semantics::Symbol &, bool)>
          insertSymbols = [&](const Fortran::semantics::Symbol &oriSymbol,
                              bool collectSymbol) {
            if (collectSymbol && oriSymbol.test(flag))
              symbolSet.insert(&oriSymbol);
            else if (checkHostAssociatedSymbols)
              if (const auto *details{
                      oriSymbol
                          .detailsIf<Fortran::semantics::HostAssocDetails>()})
                insertSymbols(details->symbol(), true);
          };
      insertSymbols(sym, collectSymbols);
    };
```

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


More information about the flang-commits mailing list