Skip to content

Commit f35e2d8

Browse files
authored
[flang][openmp] Don't mark loop variables with explicit DSA as predetermined (#68723)
This patch fixes a bug where loop variables are always marked as predetermined even when they have an explicit data sharing attribute specified.
1 parent 37441f1 commit f35e2d8

File tree

4 files changed

+18
-6
lines changed

4 files changed

+18
-6
lines changed

flang/lib/Semantics/resolve-directives.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1542,7 +1542,10 @@ void OmpAttributeVisitor::ResolveSeqLoopIndexInParallelOrTaskConstruct(
15421542
}
15431543
if (auto *symbol{ResolveOmp(iv, Symbol::Flag::OmpPrivate, targetIt->scope)}) {
15441544
targetIt++;
1545-
symbol->set(Symbol::Flag::OmpPreDetermined);
1545+
// If this object already had a DSA then it is not predetermined
1546+
if (!IsObjectWithDSA(*symbol)) {
1547+
symbol->set(Symbol::Flag::OmpPreDetermined);
1548+
}
15461549
iv.symbol = symbol; // adjust the symbol within region
15471550
for (auto it{dirContext_.rbegin()}; it != targetIt; ++it) {
15481551
AddToContextObjectWithDSA(*symbol, Symbol::Flag::OmpPrivate, *it);

flang/test/Lower/OpenMP/FIR/parallel-private-clause-fixes.f90

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
! CHECK: %[[VAL_1:.*]] = fir.alloca i32 {bindc_name = "j", uniq_name = "_QFmultiple_private_fixEj"}
88
! CHECK: %[[VAL_2:.*]] = fir.alloca i32 {bindc_name = "x", uniq_name = "_QFmultiple_private_fixEx"}
99
! CHECK: omp.parallel {
10-
! CHECK: %[[PRIV_J:.*]] = fir.alloca i32 {bindc_name = "j", pinned
11-
! CHECK: %[[PRIV_I:.*]] = fir.alloca i32 {adapt.valuebyref, pinned
12-
! CHECK: %[[PRIV_X:.*]] = fir.alloca i32 {bindc_name = "x", pinned
10+
! CHECK-DAG: %[[PRIV_J:.*]] = fir.alloca i32 {bindc_name = "j", pinned
11+
! CHECK-DAG: %[[PRIV_I:.*]] = fir.alloca i32 {adapt.valuebyref, pinned
12+
! CHECK-DAG: %[[PRIV_X:.*]] = fir.alloca i32 {bindc_name = "x", pinned
1313
! CHECK: %[[ONE:.*]] = arith.constant 1 : i32
1414
! CHECK: %[[VAL_3:.*]] = fir.load %[[VAL_4:.*]] : !fir.ref<i32>
1515
! CHECK: %[[VAL_5:.*]] = arith.constant 1 : i32

flang/test/Semantics/OpenMP/do05-positivecase.f90

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,13 @@ program omp_do
3333
!$omp end do
3434
!$omp end parallel
3535

36+
!$omp parallel private(i)
37+
!DEF: /omp_do/OtherConstruct3/i (OmpPrivate) HostAssoc INTEGER(4)
38+
do i=1,10
39+
!$omp single
40+
print *, "hello"
41+
!$omp end single
42+
end do
43+
!$omp end parallel
44+
3645
end program omp_do

flang/test/Semantics/OpenMP/symbol08.f90

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ subroutine test_pardo
6767
do j=6,10
6868
!REF: /test_pardo/a
6969
a(1,1,1) = 0.
70-
!DEF: /test_pardo/OtherConstruct1/k (OmpPrivate, OmpPreDetermined) HostAssoc INTEGER(4)
70+
!DEF: /test_pardo/OtherConstruct1/k (OmpPrivate) HostAssoc INTEGER(4)
7171
do k=11,15
7272
!REF: /test_pardo/a
7373
!REF: /test_pardo/OtherConstruct1/k
@@ -91,7 +91,7 @@ subroutine test_taskloop
9191
!$omp taskloop private(j)
9292
!DEF: /test_taskloop/OtherConstruct1/i (OmpPrivate, OmpPreDetermined) HostAssoc INTEGER(4)
9393
do i=1,5
94-
!DEF: /test_taskloop/OtherConstruct1/j (OmpPrivate, OmpPreDetermined) HostAssoc INTEGER(4)
94+
!DEF: /test_taskloop/OtherConstruct1/j (OmpPrivate) HostAssoc INTEGER(4)
9595
!REF: /test_taskloop/OtherConstruct1/i
9696
do j=1,i
9797
!REF: /test_taskloop/a

0 commit comments

Comments
 (0)