[flang-commits] [flang] [acc][flang] lowering of acc declare on COMMON variables (PR #163676)
via flang-commits
flang-commits at lists.llvm.org
Wed Oct 15 18:41:35 PDT 2025
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff origin/main HEAD --extensions cpp -- flang/lib/Lower/OpenACC.cpp --diff_from_common_commit
``````````
:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/flang/lib/Lower/OpenACC.cpp b/flang/lib/Lower/OpenACC.cpp
index f2afc75b7..93a8ea24b 100644
--- a/flang/lib/Lower/OpenACC.cpp
+++ b/flang/lib/Lower/OpenACC.cpp
@@ -3402,7 +3402,6 @@ genACCHostDataOp(Fortran::lower::AbstractConverter &converter,
fir::FirOpBuilder &builder = converter.getFirOpBuilder();
-
for (const Fortran::parser::AccClause &clause : accClauseList.v) {
mlir::Location clauseLocation = converter.genLocation(clause.source);
if (const auto *ifClause =
@@ -4145,13 +4144,11 @@ static void createDeclareGlobalOp(mlir::OpBuilder &modBuilder,
// Small helper to emit a constructor/destructor pair for a given global
// declare Entry/Exit Op combination.
template <typename EntryOp, typename ExitOp>
-static void emitCtorDtorPair(mlir::OpBuilder &modBuilder,
- fir::FirOpBuilder &builder,
- mlir::Location operandLocation,
- fir::GlobalOp globalOp,
- mlir::acc::DataClause clause,
- std::stringstream &asFortran,
- const std::string &ctorName) {
+static void
+emitCtorDtorPair(mlir::OpBuilder &modBuilder, fir::FirOpBuilder &builder,
+ mlir::Location operandLocation, fir::GlobalOp globalOp,
+ mlir::acc::DataClause clause, std::stringstream &asFortran,
+ const std::string &ctorName) {
createDeclareGlobalOp<mlir::acc::GlobalConstructorOp, EntryOp,
mlir::acc::DeclareEnterOp, ExitOp>(
modBuilder, builder, operandLocation, globalOp, clause, ctorName,
@@ -4159,10 +4156,11 @@ static void emitCtorDtorPair(mlir::OpBuilder &modBuilder,
std::stringstream dtorName;
dtorName << globalOp.getSymName().str() << "_acc_dtor";
- createDeclareGlobalOp<mlir::acc::GlobalDestructorOp, mlir::acc::GetDevicePtrOp,
- mlir::acc::DeclareExitOp, ExitOp>(
- modBuilder, builder, operandLocation, globalOp, clause, dtorName.str(),
- /*implicit=*/false, asFortran);
+ createDeclareGlobalOp<mlir::acc::GlobalDestructorOp,
+ mlir::acc::GetDevicePtrOp, mlir::acc::DeclareExitOp,
+ ExitOp>(modBuilder, builder, operandLocation, globalOp,
+ clause, dtorName.str(),
+ /*implicit=*/false, asFortran);
}
template <typename EntryOp>
@@ -4356,8 +4354,7 @@ genDeclareInFunction(Fortran::lower::AbstractConverter &converter,
// Inline helper to emit module-level declare for COMMON symbols in a clause.
auto emitCommonGlobal = [&](const Fortran::parser::AccObject &obj,
- mlir::acc::DataClause clause,
- auto emitCtorDtor) {
+ mlir::acc::DataClause clause, auto emitCtorDtor) {
Fortran::semantics::Symbol &sym = getSymbolFromAccObject(obj);
if (!(sym.detailsIf<Fortran::semantics::CommonBlockDetails>() ||
Fortran::semantics::FindCommonBlockContaining(sym)))
@@ -4416,7 +4413,8 @@ genDeclareInFunction(Fortran::lower::AbstractConverter &converter,
const auto &accObjectList =
std::get<Fortran::parser::AccObjectList>(listWithModifier.t);
for (const auto &obj : accObjectList.v) {
- emitCommonGlobal(obj, mlir::acc::DataClause::acc_create,
+ emitCommonGlobal(
+ obj, mlir::acc::DataClause::acc_create,
[&](mlir::OpBuilder &modBuilder, mlir::Location operandLocation,
fir::GlobalOp globalOp, mlir::acc::DataClause clause,
std::stringstream &asFortran, const std::string &ctorName) {
@@ -4449,7 +4447,8 @@ genDeclareInFunction(Fortran::lower::AbstractConverter &converter,
const auto ©inObjs =
std::get<Fortran::parser::AccObjectList>(listWithModifier.t);
for (const auto &obj : copyinObjs.v) {
- emitCommonGlobal(obj, mlir::acc::DataClause::acc_copyin,
+ emitCommonGlobal(
+ obj, mlir::acc::DataClause::acc_copyin,
[&](mlir::OpBuilder &modBuilder, mlir::Location operandLocation,
fir::GlobalOp globalOp, mlir::acc::DataClause clause,
std::stringstream &asFortran, const std::string &ctorName) {
@@ -4475,7 +4474,8 @@ genDeclareInFunction(Fortran::lower::AbstractConverter &converter,
const auto &accObjectList =
std::get<Fortran::parser::AccObjectList>(listWithModifier.t);
for (const auto &obj : accObjectList.v) {
- emitCommonGlobal(obj, mlir::acc::DataClause::acc_copyout,
+ emitCommonGlobal(
+ obj, mlir::acc::DataClause::acc_copyout,
[&](mlir::OpBuilder &modBuilder, mlir::Location operandLocation,
fir::GlobalOp globalOp, mlir::acc::DataClause clause,
std::stringstream &asFortran, const std::string &ctorName) {
@@ -4504,16 +4504,17 @@ genDeclareInFunction(Fortran::lower::AbstractConverter &converter,
std::get_if<Fortran::parser::AccClause::Link>(&clause.u)) {
const auto &linkObjs = linkClause->v;
for (const auto &obj : linkObjs.v) {
- emitCommonGlobal(obj, mlir::acc::DataClause::acc_declare_link,
+ emitCommonGlobal(
+ obj, mlir::acc::DataClause::acc_declare_link,
[&](mlir::OpBuilder &modBuilder, mlir::Location operandLocation,
fir::GlobalOp globalOp, mlir::acc::DataClause clause,
std::stringstream &asFortran, const std::string &ctorName) {
- createDeclareGlobalOp<mlir::acc::GlobalConstructorOp,
- mlir::acc::DeclareLinkOp,
- mlir::acc::DeclareEnterOp,
- mlir::acc::DeclareLinkOp>(modBuilder,
- builder, operandLocation, globalOp, clause, ctorName,
- /*implicit=*/false, asFortran);
+ createDeclareGlobalOp<
+ mlir::acc::GlobalConstructorOp, mlir::acc::DeclareLinkOp,
+ mlir::acc::DeclareEnterOp, mlir::acc::DeclareLinkOp>(
+ modBuilder, builder, operandLocation, globalOp, clause,
+ ctorName,
+ /*implicit=*/false, asFortran);
});
}
genDeclareDataOperandOperations<mlir::acc::DeclareLinkOp,
@@ -4526,14 +4527,15 @@ genDeclareInFunction(Fortran::lower::AbstractConverter &converter,
&clause.u)) {
const auto &devResObjs = deviceResidentClause->v;
for (const auto &obj : devResObjs.v) {
- emitCommonGlobal(obj,
- mlir::acc::DataClause::acc_declare_device_resident,
+ emitCommonGlobal(
+ obj, mlir::acc::DataClause::acc_declare_device_resident,
[&](mlir::OpBuilder &modBuilder, mlir::Location operandLocation,
fir::GlobalOp globalOp, mlir::acc::DataClause clause,
std::stringstream &asFortran, const std::string &ctorName) {
emitCtorDtorPair<mlir::acc::DeclareDeviceResidentOp,
- mlir::acc::DeleteOp>(modBuilder, builder,
- operandLocation, globalOp, clause, asFortran, ctorName);
+ mlir::acc::DeleteOp>(
+ modBuilder, builder, operandLocation, globalOp, clause,
+ asFortran, ctorName);
});
}
auto crtDataStart = dataClauseOperands.size();
``````````
</details>
https://github.com/llvm/llvm-project/pull/163676
More information about the flang-commits
mailing list