[flang-commits] [flang] a6c02ed - [flang][openacc] Keep CYCLE check for compute and data construct (#73897)
via flang-commits
flang-commits at lists.llvm.org
Wed Nov 29 21:34:18 PST 2023
Author: Valentin Clement (バレンタイン クレメン)
Date: 2023-11-29T21:34:12-08:00
New Revision: a6c02edd6eac476523b5c73f29619a7a9e054872
URL: https://github.com/llvm/llvm-project/commit/a6c02edd6eac476523b5c73f29619a7a9e054872
DIFF: https://github.com/llvm/llvm-project/commit/a6c02edd6eac476523b5c73f29619a7a9e054872.diff
LOG: [flang][openacc] Keep CYCLE check for compute and data construct (#73897)
Unlike mentioned in #73839, some OpenACC construct still need the cycle
branching check to be performed. This patch adds a list of construct
where the check is not needed (loop and combined construct) and add
tests to check where it is still needed.
Added:
Modified:
flang/lib/Semantics/check-directive-structure.h
flang/test/Semantics/OpenACC/acc-data.f90
flang/test/Semantics/OpenACC/acc-kernels.f90
flang/test/Semantics/OpenACC/acc-parallel.f90
flang/test/Semantics/OpenACC/acc-serial.f90
Removed:
################################################################################
diff --git a/flang/lib/Semantics/check-directive-structure.h b/flang/lib/Semantics/check-directive-structure.h
index 7965fb595ff1bab..84240b87f47ec4b 100644
--- a/flang/lib/Semantics/check-directive-structure.h
+++ b/flang/lib/Semantics/check-directive-structure.h
@@ -79,7 +79,17 @@ template <typename D> class NoBranchingEnforce {
break;
}
} else if constexpr (std::is_same_v<D, llvm::acc::Directive>) {
- return; // OpenACC construct do not need check for unlabelled CYCLES
+ switch ((llvm::acc::Directive)currentDirective_) {
+ // exclude loop directives which do not need a check for unlabelled
+ // CYCLES
+ case llvm::acc::Directive::ACCD_loop:
+ case llvm::acc::Directive::ACCD_kernels_loop:
+ case llvm::acc::Directive::ACCD_parallel_loop:
+ case llvm::acc::Directive::ACCD_serial_loop:
+ return;
+ default:
+ break;
+ }
}
CheckConstructNameBranching("CYCLE");
}
diff --git a/flang/test/Semantics/OpenACC/acc-data.f90 b/flang/test/Semantics/OpenACC/acc-data.f90
index 8d801ebb30f4eca..84eb72825b34cd3 100644
--- a/flang/test/Semantics/OpenACC/acc-data.f90
+++ b/flang/test/Semantics/OpenACC/acc-data.f90
@@ -187,6 +187,19 @@ program openacc_data_validity
!$acc data copy(aa) device_type(default) wait
!$acc end data
+ do i = 1, 100
+ !$acc data copy(aa)
+ !ERROR: CYCLE to construct outside of DATA construct is not allowed
+ if (i == 10) cycle
+ !$acc end data
+ end do
+
+ !$acc data copy(aa)
+ do i = 1, 100
+ if (i == 10) cycle
+ end do
+ !$acc end data
+
end program openacc_data_validity
module mod1
diff --git a/flang/test/Semantics/OpenACC/acc-kernels.f90 b/flang/test/Semantics/OpenACC/acc-kernels.f90
index de220f7c7ddf7cf..8a209040a779361 100644
--- a/flang/test/Semantics/OpenACC/acc-kernels.f90
+++ b/flang/test/Semantics/OpenACC/acc-kernels.f90
@@ -144,4 +144,17 @@ program openacc_kernels_validity
end do
!$acc end kernels
+ do i = 1, 100
+ !$acc kernels
+ !ERROR: CYCLE to construct outside of KERNELS construct is not allowed
+ if (i == 10) cycle
+ !$acc end kernels
+ end do
+
+ !$acc kernels
+ do i = 1, 100
+ if (i == 10) cycle
+ end do
+ !$acc end kernels
+
end program openacc_kernels_validity
diff --git a/flang/test/Semantics/OpenACC/acc-parallel.f90 b/flang/test/Semantics/OpenACC/acc-parallel.f90
index 0e8d240d019983f..c87d321593ddf3d 100644
--- a/flang/test/Semantics/OpenACC/acc-parallel.f90
+++ b/flang/test/Semantics/OpenACC/acc-parallel.f90
@@ -142,4 +142,17 @@ program openacc_parallel_validity
end do
!$acc end parallel
+ do i = 1, 100
+ !$acc parallel
+ !ERROR: CYCLE to construct outside of PARALLEL construct is not allowed
+ if (i == 10) cycle
+ !$acc end parallel
+ end do
+
+ !$acc parallel
+ do i = 1, 100
+ if (i == 10) cycle
+ end do
+ !$acc end parallel
+
end program openacc_parallel_validity
diff --git a/flang/test/Semantics/OpenACC/acc-serial.f90 b/flang/test/Semantics/OpenACC/acc-serial.f90
index db4cd7689435c7f..a23daecce8dd350 100644
--- a/flang/test/Semantics/OpenACC/acc-serial.f90
+++ b/flang/test/Semantics/OpenACC/acc-serial.f90
@@ -166,4 +166,17 @@ program openacc_serial_validity
end do
!$acc end serial
+ do i = 1, 100
+ !$acc serial
+ !ERROR: CYCLE to construct outside of SERIAL construct is not allowed
+ if (i == 10) cycle
+ !$acc end serial
+ end do
+
+ !$acc serial
+ do i = 1, 100
+ if (i == 10) cycle
+ end do
+ !$acc end serial
+
end program openacc_serial_validity
More information about the flang-commits
mailing list