Closed
Description
According to the OpenMP specification, Loop iteration variables inside parallel, teams, or task generating constructs are private in the innermost such construct that encloses the loop.
In the following example:
subroutine test()
integer :: x
!$omp task
do i = 1, 10
x = 1
end do
!$omp end task
end subroutine
The loop iteration variable i
must be treated as private
to task. However, the current behavior treats i
as firstprivate
, which is incorrect.
Here is the generated FIR which treats the variable i
as firstprivate
: Godbolt link
omp.private {type = firstprivate} @_QFtestEx_firstprivate_i32 : i32 copy {
^bb0(%arg0: !fir.ref<i32>, %arg1: !fir.ref<i32>):
%0 = fir.load %arg0 : !fir.ref<i32>
hlfir.assign %0 to %arg1 : i32, !fir.ref<i32>
omp.yield(%arg1 : !fir.ref<i32>)
}