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

via flang-commits flang-commits at lists.llvm.org
Wed Jan 3 03:44:29 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:

@kiranchandramohan I was on leave mainly for past few days; sorry about the delayed response.

So we maintain two lists: `defaultSymbols` and `symbolsInNestedRegions`. For non-constructs like OpenMP, we would not like to collected the host associated symbols for nested regions (thereby `collectHostAssociatedSymbols = false`). They can be handled as the `default` clause may be in their respective nested blocks. This was the earlier design.

However, for non-OpenMP constructs, the handling is different. This is because even though the inner construct has a block region (like OpenMP constructs do), all privatization of variables in the nested construct needs to happen in the outer OpenMP construct. Hence, we do not need to populate the `symbolsInNestedRegions` list. Otherwise, no privatization will happen, leading to incorrect results.

That said, if you think so, I can relook the design of the lists once. It has been quite some time when we implemented the default clause. So maybe, we can think of improving this lowering flow once. What are your suggestions?

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


More information about the flang-commits mailing list