[flang-commits] [flang] 2cbd4fc - [flang] Support export/import OpenMP Threadprivate Flag
via flang-commits
flang-commits at lists.llvm.org
Fri Apr 8 22:53:54 PDT 2022
Author: Peixin-Qiao
Date: 2022-04-09T13:52:31+08:00
New Revision: 2cbd4fc4424a88573ee03e2f1dce345f7826e662
URL: https://github.com/llvm/llvm-project/commit/2cbd4fc4424a88573ee03e2f1dce345f7826e662
DIFF: https://github.com/llvm/llvm-project/commit/2cbd4fc4424a88573ee03e2f1dce345f7826e662.diff
LOG: [flang] Support export/import OpenMP Threadprivate Flag
The information about OpenMP/OpenACC declarative directives in modules
should be carried in export mod files. This supports export OpenMP
Threadprivate directive and import OpenMP declarative directives.
Reviewed By: kiranchandramohan
Differential Revision: https://reviews.llvm.org/D120396
Added:
flang/test/Semantics/modfile47.f90
Modified:
flang/lib/Semantics/mod-file.cpp
Removed:
################################################################################
diff --git a/flang/lib/Semantics/mod-file.cpp b/flang/lib/Semantics/mod-file.cpp
index 10d56b2c75eaf..1148af802d07c 100644
--- a/flang/lib/Semantics/mod-file.cpp
+++ b/flang/lib/Semantics/mod-file.cpp
@@ -322,7 +322,12 @@ void ModFileWriter::PutSymbol(
},
[](const HostAssocDetails &) {},
[](const MiscDetails &) {},
- [&](const auto &) { PutEntity(decls_, symbol); },
+ [&](const auto &) {
+ PutEntity(decls_, symbol);
+ if (symbol.test(Symbol::Flag::OmpThreadprivate)) {
+ decls_ << "!$omp threadprivate(" << symbol.name() << ")\n";
+ }
+ },
},
symbol.details());
}
@@ -925,6 +930,7 @@ Scope *ModFileReader::Read(const SourceName &name,
parser::Options options;
options.isModuleFile = true;
options.features.Enable(common::LanguageFeature::BackslashEscapes);
+ options.features.Enable(common::LanguageFeature::OpenMP);
if (!isIntrinsic.value_or(false)) {
options.searchDirectories = context_.searchDirectories();
// If a directory is in both lists, the intrinsic module directory
diff --git a/flang/test/Semantics/modfile47.f90 b/flang/test/Semantics/modfile47.f90
new file mode 100644
index 0000000000000..4d268d8616855
--- /dev/null
+++ b/flang/test/Semantics/modfile47.f90
@@ -0,0 +1,35 @@
+! RUN: %python %S/test_modfile.py %s %flang_fc1 -fopenmp
+! Check correct modfile generation for OpenMP threadprivate directive.
+
+module m
+ implicit none
+ type :: my_type(kind_param, len_param)
+ integer, KIND :: kind_param
+ integer, LEN :: len_param
+ integer :: t_i
+ integer :: t_arr(10)
+ end type
+ type(my_type(kind_param=2, len_param=4)) :: t
+ real, dimension(3) :: thrtest
+ real :: x
+ common /blk/ x
+
+ !$omp threadprivate(thrtest, t, /blk/)
+end
+
+!Expect: m.mod
+!module m
+!type::my_type(kind_param,len_param)
+!integer(4),kind::kind_param
+!integer(4),len::len_param
+!integer(4)::t_i
+!integer(4)::t_arr(1_8:10_8)
+!end type
+!type(my_type(kind_param=2_4,len_param=4_4))::t
+!!$omp threadprivate(t)
+!real(4)::thrtest(1_8:3_8)
+!!$omp threadprivate(thrtest)
+!real(4)::x
+!!$omp threadprivate(x)
+!common/blk/x
+!end
More information about the flang-commits
mailing list