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

Kiran Chandramohan via flang-commits flang-commits at lists.llvm.org
Sun Feb 4 14:46:33 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())
----------------
kiranchandramohan wrote:

I was trying to understand the need to distinguish between OpenMP and non-OpenMP constructs for collecting symbols recursively.  Particularly in cases where the variable on which a default applies is only visible inside the nested OpenMP construct. Consider the following example : 

```
program mn
  call sb1()
contains
 subroutine sb1()
   integer :: x
   x = 20
   !$omp parallel default(private)
   !$omp critical
   x = 30
   !$omp end critical
   !$omp end parallel
   print *, x
 end subroutine
end program
```

But the following example with nested parallel works. I am assuming the semantics code is creating symbols here. Is that the reason? 
If so, why not handle everything (nested openmp and nested non-openmp constructs) in the frontend? What is the split between semantics and the code here?
```
program mn
  call sb1()
contains
 subroutine sb1()
   integer :: x
   x = 20
   !$omp parallel default(private)
   !$omp parallel 
   x = 30
   !$omp end parallel
   !$omp end parallel
   print *, x
 end subroutine
end program
```


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


More information about the flang-commits mailing list