Skip to content

Commit c1e2a9c

Browse files
authored
[flang][OpenMP] Only privaize pre-determined symbols when defined the evaluation. (#154070)
Fixes a regression uncovered by Fujitsu test 0686_0024.f90. In particular, verifies that a pre-determined symbol is only privatized by its defining evaluation (e.g. the loop for which the symbol was marked as pre-determined).
1 parent cfe5975 commit c1e2a9c

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

flang/lib/Lower/OpenMP/DataSharingProcessor.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -571,7 +571,8 @@ void DataSharingProcessor::collectSymbols(
571571
if (collectPreDetermined) {
572572
// Similar to implicit symbols, collect pre-determined symbols only if
573573
// they are not defined by a nested `DeclarationConstruct`
574-
return !visitor.isSymbolDefineByNestedDeclaration(sym) &&
574+
return visitor.isSymbolDefineBy(sym, eval) &&
575+
!visitor.isSymbolDefineByNestedDeclaration(sym) &&
575576
sym->test(semantics::Symbol::Flag::OmpPreDetermined);
576577
}
577578

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
! Fixes a regression uncovered by Fujitsu test 0686_0024.f90. In particular,
2+
! verifies that a pre-determined symbol is only privatized by its defining
3+
! evaluation (e.g. the loop for which the symbol was marked as pre-determined).
4+
5+
! RUN: %flang_fc1 -emit-hlfir -fopenmp %s -o - | FileCheck %s
6+
7+
subroutine privatize_predetermined_when_defined_by_eval
8+
integer::i,ii
9+
integer::j
10+
11+
!$omp parallel
12+
!$omp do lastprivate(ii)
13+
do i=1,10
14+
do ii=1,10
15+
enddo
16+
enddo
17+
18+
!$omp do
19+
do j=1,ii
20+
enddo
21+
!$omp end parallel
22+
end subroutine
23+
24+
! Verify that nothing is privatized by the `omp.parallel` op.
25+
! CHECK: omp.parallel {
26+
27+
! Verify that `i` and `ii` are privatized by the first loop.
28+
! CHECK: omp.wsloop private(@{{.*}}ii_private_i32 %{{.*}}#0 -> %{{.*}}, @{{.*}}i_private_i32 %2#0 -> %{{.*}} : {{.*}}) {
29+
! CHECK: }
30+
31+
! Verify that `j` is privatized by the second loop.
32+
! CHECK: omp.wsloop private(@{{.*}}j_private_i32 %{{.*}}#0 -> %{{.*}} : {{.*}}) {
33+
! CHECK: }
34+
35+
! CHECK: }

0 commit comments

Comments
 (0)