[flang-commits] [flang] dc0dcab - [flang][OpenMP] Allow flush of common block (#139528)
via flang-commits
flang-commits at lists.llvm.org
Mon May 19 01:26:55 PDT 2025
Author: Tom Eccles
Date: 2025-05-19T09:26:52+01:00
New Revision: dc0dcab397ae3de38141e1995e4b4e5e3bb98660
URL: https://github.com/llvm/llvm-project/commit/dc0dcab397ae3de38141e1995e4b4e5e3bb98660
DIFF: https://github.com/llvm/llvm-project/commit/dc0dcab397ae3de38141e1995e4b4e5e3bb98660.diff
LOG: [flang][OpenMP] Allow flush of common block (#139528)
I think this was denied by accident in
https://github.com/llvm/llvm-project/commit/68180d8d16f07db8200dfce7bae26a80c43ebc5e.
Flush of a common block is allowed by the standard on my reading. It is
not allowed by classic-flang but is supported by gfortran and ifx.
This doesn't need any lowering changes. The LLVM translation ignores the
flush argument list because the openmp runtime library doesn't support
flushing specific data.
Depends upon https://github.com/llvm/llvm-project/pull/139522. Ignore
the first commit in this PR.
Added:
flang/test/Lower/OpenMP/flush-common.f90
Modified:
flang/lib/Semantics/check-omp-structure.cpp
Removed:
flang/test/Semantics/OpenMP/flush04.f90
################################################################################
diff --git a/flang/lib/Semantics/check-omp-structure.cpp b/flang/lib/Semantics/check-omp-structure.cpp
index 5ae4bc29b72f7..c6c4fdf8a8198 100644
--- a/flang/lib/Semantics/check-omp-structure.cpp
+++ b/flang/lib/Semantics/check-omp-structure.cpp
@@ -2303,9 +2303,15 @@ void OmpStructureChecker::Enter(const parser::OpenMPFlushConstruct &x) {
void OmpStructureChecker::Leave(const parser::OpenMPFlushConstruct &x) {
auto &flushList{std::get<std::optional<parser::OmpArgumentList>>(x.v.t)};
+ auto isVariableListItemOrCommonBlock{[this](const Symbol &sym) {
+ return IsVariableListItem(sym) ||
+ sym.detailsIf<semantics::CommonBlockDetails>();
+ }};
+
if (flushList) {
for (const parser::OmpArgument &arg : flushList->v) {
- if (auto *sym{GetArgumentSymbol(arg)}; sym && !IsVariableListItem(*sym)) {
+ if (auto *sym{GetArgumentSymbol(arg)};
+ sym && !isVariableListItemOrCommonBlock(*sym)) {
context_.Say(arg.source,
"FLUSH argument must be a variable list item"_err_en_US);
}
diff --git a/flang/test/Lower/OpenMP/flush-common.f90 b/flang/test/Lower/OpenMP/flush-common.f90
new file mode 100644
index 0000000000000..7656141dcb295
--- /dev/null
+++ b/flang/test/Lower/OpenMP/flush-common.f90
@@ -0,0 +1,13 @@
+! RUN: %flang_fc1 -fopenmp -emit-hlfir -o - %s | FileCheck %s
+
+! Regression test to ensure that the name /c/ in the flush argument list is
+! resolved to the common block symbol and common blocks are allowed in the
+! flush argument list.
+
+! CHECK: %[[GLBL:.*]] = fir.address_of({{.*}}) : !fir.ref<!fir.array<4xi8>>
+ common /c/ x
+ real :: x
+! CHECK: omp.flush(%[[GLBL]] : !fir.ref<!fir.array<4xi8>>)
+ !$omp flush(/c/)
+end
+
diff --git a/flang/test/Semantics/OpenMP/flush04.f90 b/flang/test/Semantics/OpenMP/flush04.f90
deleted file mode 100644
index ffc2273b692dc..0000000000000
--- a/flang/test/Semantics/OpenMP/flush04.f90
+++ /dev/null
@@ -1,11 +0,0 @@
-! RUN: %python %S/../test_errors.py %s %flang_fc1 -fopenmp
-
-! Regression test to ensure that the name /c/ in the flush argument list is
-! resolved to the common block symbol.
-
- common /c/ x
- real :: x
-!ERROR: FLUSH argument must be a variable list item
- !$omp flush(/c/)
-end
-
More information about the flang-commits
mailing list