-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[flang][OpenMP] Move handling of OpenMP symbol flags to OpenMP.cpp #75523
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[flang][OpenMP] Move handling of OpenMP symbol flags to OpenMP.cpp #75523
Conversation
The function `instantiateVariable` in Bridge.cpp has the following code: ``` if (var.getSymbol().test( Fortran::semantics::Symbol::Flag::OmpThreadprivate)) Fortran::lower::genThreadprivateOp(*this, var); if (var.getSymbol().test( Fortran::semantics::Symbol::Flag::OmpDeclareTarget)) Fortran::lower::genDeclareTargetIntGlobal(*this, var); ``` Implement `handleOpenMPSymbolProperties` in OpenMP.cpp, move the above code there, and have `instantiateVariable` call this function instead. This would further separate OpenMP-related details into OpenMP.cpp.
@llvm/pr-subscribers-flang-openmp @llvm/pr-subscribers-flang-fir-hlfir Author: Krzysztof Parzyszek (kparzysz) ChangesThe function
Implement This would further separate OpenMP-related details into OpenMP.cpp. Full diff: https://github.com/llvm/llvm-project/pull/75523.diff 3 Files Affected:
diff --git a/flang/include/flang/Lower/OpenMP.h b/flang/include/flang/Lower/OpenMP.h
index c9162761a08d54..a6ea26ee949fe7 100644
--- a/flang/include/flang/Lower/OpenMP.h
+++ b/flang/include/flang/Lower/OpenMP.h
@@ -56,6 +56,8 @@ void genOpenMPConstruct(AbstractConverter &, semantics::SemanticsContext &,
pft::Evaluation &, const parser::OpenMPConstruct &);
void genOpenMPDeclarativeConstruct(AbstractConverter &, pft::Evaluation &,
const parser::OpenMPDeclarativeConstruct &);
+void handleOpenMPSymbolProperties(AbstractConverter &converter,
+ const pft::Variable &var);
int64_t getCollapseValue(const Fortran::parser::OmpClauseList &clauseList);
void genThreadprivateOp(AbstractConverter &, const pft::Variable &);
void genDeclareTargetIntGlobal(AbstractConverter &, const pft::Variable &);
diff --git a/flang/lib/Lower/Bridge.cpp b/flang/lib/Lower/Bridge.cpp
index 6ca910d2696742..1ec242fafc5b6d 100644
--- a/flang/lib/Lower/Bridge.cpp
+++ b/flang/lib/Lower/Bridge.cpp
@@ -4244,13 +4244,7 @@ class FirConverter : public Fortran::lower::AbstractConverter {
Fortran::lower::AggregateStoreMap &storeMap) {
Fortran::lower::instantiateVariable(*this, var, localSymbols, storeMap);
if (var.hasSymbol()) {
- if (var.getSymbol().test(
- Fortran::semantics::Symbol::Flag::OmpThreadprivate))
- Fortran::lower::genThreadprivateOp(*this, var);
-
- if (var.getSymbol().test(
- Fortran::semantics::Symbol::Flag::OmpDeclareTarget))
- Fortran::lower::genDeclareTargetIntGlobal(*this, var);
+ handleOpenMPSymbolProperties(*this, var);
}
}
diff --git a/flang/lib/Lower/OpenMP.cpp b/flang/lib/Lower/OpenMP.cpp
index 12b8ea82884d9d..9a798e641d1267 100644
--- a/flang/lib/Lower/OpenMP.cpp
+++ b/flang/lib/Lower/OpenMP.cpp
@@ -3483,6 +3483,19 @@ void Fortran::lower::genOpenMPDeclarativeConstruct(
ompDeclConstruct.u);
}
+void Fortran::lower::handleOpenMPSymbolProperties(
+ Fortran::lower::AbstractConverter &converter,
+ const Fortran::lower::pft::Variable &var) {
+ assert(var.hasSymbol() && "Expecting Symbol");
+ const Fortran::semantics::Symbol &sym = var.getSymbol();
+
+ if (sym.test(Fortran::semantics::Symbol::Flag::OmpThreadprivate))
+ Fortran::lower::genThreadprivateOp(converter, var);
+
+ if (sym.test(Fortran::semantics::Symbol::Flag::OmpDeclareTarget))
+ Fortran::lower::genDeclareTargetIntGlobal(converter, var);
+}
+
int64_t Fortran::lower::getCollapseValue(
const Fortran::parser::OmpClauseList &clauseList) {
for (const Fortran::parser::OmpClause &clause : clauseList.v) {
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LG.
flang/lib/Lower/Bridge.cpp
Outdated
if (var.getSymbol().test( | ||
Fortran::semantics::Symbol::Flag::OmpDeclareTarget)) | ||
Fortran::lower::genDeclareTargetIntGlobal(*this, var); | ||
handleOpenMPSymbolProperties(*this, var); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The braces are probably not required anymore.
Not sure about the name. If there is no better alternative, please document what the function does in the header.
The function
instantiateVariable
in Bridge.cpp has the following code:Implement
handleOpenMPSymbolProperties
in OpenMP.cpp, move the above code there, and haveinstantiateVariable
call this function instead.This would further separate OpenMP-related details into OpenMP.cpp.