Skip to content

Commit b1b5faa

Browse files
committed
Don't try to privatize DO CONCURRENT indices either
1 parent 4e291f6 commit b1b5faa

File tree

3 files changed

+11
-23
lines changed

3 files changed

+11
-23
lines changed

flang/lib/Semantics/resolve-directives.cpp

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1777,28 +1777,13 @@ void OmpAttributeVisitor::ResolveSeqLoopIndexInParallelOrTaskConstruct(
17771777
// Use of DO CONCURRENT inside OpenMP construct is unspecified behavior
17781778
// till OpenMP-5.0 standard.
17791779
// In above both cases we skip the privatization of iteration variables.
1780-
// [OpenMP 5.1] DO CONCURRENT indices are private
17811780
bool OmpAttributeVisitor::Pre(const parser::DoConstruct &x) {
17821781
if (!dirContext_.empty() && GetContext().withinConstruct) {
17831782
llvm::SmallVector<const parser::Name *> ivs;
17841783
if (x.IsDoNormal()) {
17851784
const parser::Name *iv{GetLoopIndex(x)};
17861785
if (iv && iv->symbol)
17871786
ivs.push_back(iv);
1788-
} else if (x.IsDoConcurrent()) {
1789-
const Fortran::parser::LoopControl *loopControl = &*x.GetLoopControl();
1790-
const Fortran::parser::LoopControl::Concurrent &concurrent =
1791-
std::get<Fortran::parser::LoopControl::Concurrent>(loopControl->u);
1792-
const Fortran::parser::ConcurrentHeader &concurrentHeader =
1793-
std::get<Fortran::parser::ConcurrentHeader>(concurrent.t);
1794-
const std::list<Fortran::parser::ConcurrentControl> &controls =
1795-
std::get<std::list<Fortran::parser::ConcurrentControl>>(
1796-
concurrentHeader.t);
1797-
for (const auto &control : controls) {
1798-
const parser::Name *iv{&std::get<0>(control.t)};
1799-
if (iv && iv->symbol)
1800-
ivs.push_back(iv);
1801-
}
18021787
}
18031788
ordCollapseLevel--;
18041789
for (auto iv : ivs) {
@@ -1810,9 +1795,6 @@ bool OmpAttributeVisitor::Pre(const parser::DoConstruct &x) {
18101795
if (ordCollapseLevel) {
18111796
if (const auto *details{iv->symbol->detailsIf<HostAssocDetails>()}) {
18121797
const Symbol *tpSymbol = &details->symbol();
1813-
// TODO: DoConcurrent won't capture the following check because a new
1814-
// symbol is declared in ResolveIndexName(), which will not have the
1815-
// OmpThreadprivate flag.
18161798
if (tpSymbol->test(Symbol::Flag::OmpThreadprivate)) {
18171799
context_.Say(iv->source,
18181800
"Loop iteration variable %s is not allowed in THREADPRIVATE."_err_en_US,

flang/test/Semantics/OpenMP/doconcurrent01.f90

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
11
! RUN: %python %S/../test_symbols.py %s %flang_fc1 -fopenmp
22

3-
! OpenMP 5.1.1
4-
! DO Concurrent indices are private
3+
! OpenMP 5.2 5.1.1 Variables Referenced in a Construct
4+
! DO CONCURRENT indices have predetermined private DSA.
5+
!
6+
! As DO CONCURRENT indices are defined in the construct itself, and OpenMP
7+
! directives may not appear in it, they are already private.
8+
! Check that index symbols are not modified.
59

610
!DEF: /private_iv (Subroutine)Subprogram
711
subroutine private_iv
812
!DEF: /private_iv/i ObjectEntity INTEGER(4)
913
integer i
1014
!$omp parallel default(private)
1115
!$omp single
12-
!DEF: /private_iv/OtherConstruct1/i (OmpPrivate, OmpPreDetermined) HostAssoc INTEGER(4)
16+
!DEF: /private_iv/OtherConstruct1/OtherConstruct1/Forall1/i ObjectEntity INTEGER(4)
1317
do concurrent(i=1:2)
1418
end do
1519
!$omp end single

flang/test/Semantics/OpenMP/forall.f90

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22

33
! OpenMP 5.2 5.1.1 Variables Referenced in a Construct
44
! FORALL indices have predetermined private DSA.
5-
! As lowering already makes them private, check that their symbols are not
6-
! modified.
5+
!
6+
! As FORALL indices are defined in the construct itself, and OpenMP
7+
! directives may not appear in it, they are already private.
8+
! Check that index symbols are not modified.
79

810
!DEF: /MainProgram1/a ObjectEntity INTEGER(4)
911
!DEF: /MainProgram1/b ObjectEntity INTEGER(4)

0 commit comments

Comments
 (0)