[flang-commits] [flang] [Flang][OpenMP] Fix copyin allocatable lowering to MLIR (PR #122097)
via flang-commits
flang-commits at lists.llvm.org
Wed Jan 8 06:01:31 PST 2025
https://github.com/jeanPerier commented:
The patch makes sense for that direction (original item allocated, thread copy unallocated), but I think the logic is probably broken in the other direction too (original item unallocated, copy allocated).
The requirement for copyin in OpenMP spec says that _"If the original list item does not
have the POINTER attribute but has the allocation status of unallocated, each copy will have the same status."_
So the copy should be unallocated in the else case if it allocated.
Example:
```
subroutine allocatable4()
use omp_lib, only: omp_get_thread_num
integer, allocatable, save :: a
!$omp threadprivate(a)
!$omp parallel
allocate(a)
!$omp end parallel
deallocate(a)
!$omp parallel copyin(a)
print *, omp_get_thread_num(), allocated(a)
!$omp end parallel
end subroutine
call allocatable4()
end
```
This should print (in any order):
```
0 F
3 F
1 F
2 F
```
But I think it will print `T` with flang outside of the main thread after this patch (and would crash before the patch).
https://github.com/llvm/llvm-project/pull/122097
More information about the flang-commits
mailing list