[flang-commits] [flang] [llvm] [mlir] [flang][mlir][OpenMP] Add support for COPYPRIVATE (PR #73128)

Leandro Lupori via flang-commits flang-commits at lists.llvm.org
Fri Mar 8 12:20:39 PST 2024


luporl wrote:

It seems to me the problem is the threadprivate variable not being lowered as such inside subroutine `foo`, but the original `i` variable is being used instead.

I was able to make `copyprivate` work with the test program by manually adding `omp.threadprivate` to `foo`'s generated FIR.

And the following test program, that doesn't use `copyprivate` nor `single`, also shows the same behavior:

```
program main
  implicit none
  integer, save :: i = 0
  !$omp threadprivate(i)

  !$omp parallel
  call foo
  !$omp critical
  print *, i
  !$omp end critical
  !$omp end parallel

contains
  subroutine foo()
    i = 1
  end subroutine
end program
```

The issue also happens if I wrap the `i = 1` inside a `parallel` directive.
I'll create a new issue for this.

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


More information about the flang-commits mailing list