Skip to content

Commit 0741209

Browse files
authored
[flang][OpenMP] Guard lastprivate scoping on DO (#157760)
Add HLFIR FileCheck ensuring `lastprivate(v)` on an `omp do` is realized as privatization on the inner wsloop and not on the enclosing `omp parallel`. This matches OpenMP semantics and prevents regressions. - No `private(v)` at `omp.parallel` - `omp.wsloop ... private(...)` present Unable to reproduce #157035 on current main; this test documents the expected lowering. p.s- do refer to [delayed-privatization](https://lists.llvm.org/pipermail/mlir-commits/2025-January/088206.html?utm_source=chatgpt.com) <img width="2940" height="1912" alt="image" src="https://github.com/user-attachments/assets/5c3a0656-fe0a-4bd5-be98-b626a7a719c1" />
1 parent 95d5d98 commit 0741209

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
! RUN: %flang_fc1 -fopenmp -emit-hlfir %s -o - | FileCheck %s
2+
3+
program p
4+
type y3; integer, allocatable :: x; end type
5+
type(y3) :: v
6+
integer :: s, n, i
7+
s = 1; n = 10
8+
allocate(v%x); v%x = 0
9+
!$omp parallel
10+
if (.not. allocated(v%x)) print *, '101', allocated(v%x)
11+
!$omp do schedule(dynamic) lastprivate(v)
12+
do i = s, n
13+
v%x = i
14+
end do
15+
!$omp end do
16+
!$omp end parallel
17+
end program
18+
19+
! CHECK: omp.parallel {
20+
! CHECK-NOT: private(
21+
! CHECK: omp.wsloop
22+
! CHECK-SAME: private(

0 commit comments

Comments
 (0)