Skip to content

[flang][openmp] Don't mark loop variables with explicit DSA as predetermined #68723

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion flang/lib/Semantics/resolve-directives.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1542,7 +1542,10 @@ void OmpAttributeVisitor::ResolveSeqLoopIndexInParallelOrTaskConstruct(
}
if (auto *symbol{ResolveOmp(iv, Symbol::Flag::OmpPrivate, targetIt->scope)}) {
targetIt++;
symbol->set(Symbol::Flag::OmpPreDetermined);
// If this object already had a DSA then it is not predetermined
if (!IsObjectWithDSA(*symbol)) {
symbol->set(Symbol::Flag::OmpPreDetermined);
}
iv.symbol = symbol; // adjust the symbol within region
for (auto it{dirContext_.rbegin()}; it != targetIt; ++it) {
AddToContextObjectWithDSA(*symbol, Symbol::Flag::OmpPrivate, *it);
Expand Down
6 changes: 3 additions & 3 deletions flang/test/Lower/OpenMP/FIR/parallel-private-clause-fixes.f90
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
! CHECK: %[[VAL_1:.*]] = fir.alloca i32 {bindc_name = "j", uniq_name = "_QFmultiple_private_fixEj"}
! CHECK: %[[VAL_2:.*]] = fir.alloca i32 {bindc_name = "x", uniq_name = "_QFmultiple_private_fixEx"}
! CHECK: omp.parallel {
! CHECK: %[[PRIV_J:.*]] = fir.alloca i32 {bindc_name = "j", pinned
! CHECK: %[[PRIV_I:.*]] = fir.alloca i32 {adapt.valuebyref, pinned
! CHECK: %[[PRIV_X:.*]] = fir.alloca i32 {bindc_name = "x", pinned
! CHECK-DAG: %[[PRIV_J:.*]] = fir.alloca i32 {bindc_name = "j", pinned
! CHECK-DAG: %[[PRIV_I:.*]] = fir.alloca i32 {adapt.valuebyref, pinned
! CHECK-DAG: %[[PRIV_X:.*]] = fir.alloca i32 {bindc_name = "x", pinned
! CHECK: %[[ONE:.*]] = arith.constant 1 : i32
! CHECK: %[[VAL_3:.*]] = fir.load %[[VAL_4:.*]] : !fir.ref<i32>
! CHECK: %[[VAL_5:.*]] = arith.constant 1 : i32
Expand Down
9 changes: 9 additions & 0 deletions flang/test/Semantics/OpenMP/do05-positivecase.f90
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,13 @@ program omp_do
!$omp end do
!$omp end parallel

!$omp parallel private(i)
!DEF: /omp_do/OtherConstruct3/i (OmpPrivate) HostAssoc INTEGER(4)
do i=1,10
!$omp single
print *, "hello"
!$omp end single
end do
!$omp end parallel

end program omp_do
4 changes: 2 additions & 2 deletions flang/test/Semantics/OpenMP/symbol08.f90
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ subroutine test_pardo
do j=6,10
!REF: /test_pardo/a
a(1,1,1) = 0.
!DEF: /test_pardo/OtherConstruct1/k (OmpPrivate, OmpPreDetermined) HostAssoc INTEGER(4)
!DEF: /test_pardo/OtherConstruct1/k (OmpPrivate) HostAssoc INTEGER(4)
do k=11,15
!REF: /test_pardo/a
!REF: /test_pardo/OtherConstruct1/k
Expand All @@ -91,7 +91,7 @@ subroutine test_taskloop
!$omp taskloop private(j)
!DEF: /test_taskloop/OtherConstruct1/i (OmpPrivate, OmpPreDetermined) HostAssoc INTEGER(4)
do i=1,5
!DEF: /test_taskloop/OtherConstruct1/j (OmpPrivate, OmpPreDetermined) HostAssoc INTEGER(4)
!DEF: /test_taskloop/OtherConstruct1/j (OmpPrivate) HostAssoc INTEGER(4)
!REF: /test_taskloop/OtherConstruct1/i
do j=1,i
!REF: /test_taskloop/a
Expand Down