[PATCH] D92638: [Flang][openmp]Fix crash in OpenMP semantic check( bug 48308)
sameeran joshi via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 4 00:06:55 PST 2020
sameeranjoshi created this revision.
sameeranjoshi added reviewers: kiranchandramohan, clementval, kiranktp, tskeith, klausler.
Herald added subscribers: guansong, yaxunl.
sameeranjoshi requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added a subscriber: sstefan1.
Herald added a project: LLVM.
Fixes the bug reported in https://bugs.llvm.org/show_bug.cgi?id=48308
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D92638
Files:
flang/lib/Semantics/resolve-directives.cpp
flang/test/Semantics/bug48308.f90
Index: flang/test/Semantics/bug48308.f90
===================================================================
--- /dev/null
+++ flang/test/Semantics/bug48308.f90
@@ -0,0 +1,28 @@
+! RUN: %S/test_errors.sh %s %t %f18 -fopenmp
+
+subroutine bug48308(x,i)
+ real :: x(:)
+ integer :: i
+ !$omp parallel firstprivate(i)
+ do while (i>0)
+ x(i) = i
+ i = i - 1
+ end do
+ !$omp end parallel
+end subroutine
+
+subroutine s1(x,i)
+ real :: x(:)
+ integer :: i
+ !$omp parallel firstprivate(i)
+ do i = 10, 1, -1
+ x(i) = i
+ end do
+ !$omp end parallel
+
+ !$omp parallel firstprivate(i)
+ do concurrent (i = 1:10:1)
+ x(i) = i
+ end do
+ !$omp end parallel
+end subroutine
Index: flang/lib/Semantics/resolve-directives.cpp
===================================================================
--- flang/lib/Semantics/resolve-directives.cpp
+++ flang/lib/Semantics/resolve-directives.cpp
@@ -875,17 +875,25 @@
}
}
-// 2.15.1.1 Data-sharing Attribute Rules - Predetermined
+// [OMP-4.5]2.15.1.1 Data-sharing Attribute Rules - Predetermined
// - A loop iteration variable for a sequential loop in a parallel
// or task generating construct is private in the innermost such
// construct that encloses the loop
+// Loop iteration variables are not well defined for DD WHILE loop
+// in OpenMP-5.0 standard
+// Use of DO CONCURRENT inside OpenMP construct is unspecified behavior
+// as per OpenMP-5.0
+// In above both cases we skip the privatization of iteration variables
+// TODO:[OpenMP 5.1] DO CONCURRENT indices are private
bool OmpAttributeVisitor::Pre(const parser::DoConstruct &x) {
- if (!dirContext_.empty() && GetContext().withinConstruct) {
- if (const auto &iv{GetLoopIndex(x)}; iv.symbol) {
- if (!iv.symbol->test(Symbol::Flag::OmpPreDetermined)) {
- ResolveSeqLoopIndexInParallelOrTaskConstruct(iv);
- } else {
- // TODO: conflict checks with explicitly determined DSA
+ if (x.IsDoNormal()) {
+ if (!dirContext_.empty() && GetContext().withinConstruct) {
+ if (const auto &iv{GetLoopIndex(x)}; iv.symbol) {
+ if (!iv.symbol->test(Symbol::Flag::OmpPreDetermined)) {
+ ResolveSeqLoopIndexInParallelOrTaskConstruct(iv);
+ } else {
+ // TODO: conflict checks with explicitly determined DSA
+ }
}
}
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D92638.309470.patch
Type: text/x-patch
Size: 2358 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201204/87612a02/attachment.bin>
More information about the llvm-commits
mailing list