Issue |
140882
|
Summary |
[Flang][OpenMP][Task] Loop iteration variable treated as firstprivate instead of private in task construct
|
Labels |
flang:openmp
|
Assignees |
|
Reporter |
kaviya2510
|
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:
```fortran
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](https://godbolt.org/z/Pe3Yo9P5Y)
```mlir
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>)
}
```
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs