Skip to content

Conversation

@wangzpgi
Copy link
Contributor

@wangzpgi wangzpgi commented Dec 4, 2025

Remove unreachable code after the TODO in the acc cache directive lowering function.

@wangzpgi wangzpgi self-assigned this Dec 4, 2025
@llvmbot llvmbot added flang Flang issues not falling into any other category flang:fir-hlfir openacc labels Dec 4, 2025
@llvmbot
Copy link
Member

llvmbot commented Dec 4, 2025

@llvm/pr-subscribers-flang-fir-hlfir

Author: Zhen Wang (wangzpgi)

Changes

Remove unreachable code after the TODO in the acc cache directive lowering function.


Full diff: https://github.com/llvm/llvm-project/pull/170729.diff

1 Files Affected:

  • (modified) flang/lib/Lower/OpenACC.cpp (-31)
diff --git a/flang/lib/Lower/OpenACC.cpp b/flang/lib/Lower/OpenACC.cpp
index 5a548f4fcf435..50b08cea12004 100644
--- a/flang/lib/Lower/OpenACC.cpp
+++ b/flang/lib/Lower/OpenACC.cpp
@@ -4786,39 +4786,8 @@ static void
 genACC(Fortran::lower::AbstractConverter &converter,
        Fortran::semantics::SemanticsContext &semanticsContext,
        const Fortran::parser::OpenACCCacheConstruct &cacheConstruct) {
-  fir::FirOpBuilder &builder = converter.getFirOpBuilder();
   mlir::Location loc = converter.genLocation(cacheConstruct.source);
   TODO(loc, "OpenACC cache directive");
-  auto loopOp = builder.getRegion().getParentOfType<mlir::acc::LoopOp>();
-  auto crtPos = builder.saveInsertionPoint();
-  if (loopOp) {
-    builder.setInsertionPoint(loopOp);
-    Fortran::lower::StatementContext stmtCtx;
-    llvm::SmallVector<mlir::Value> cacheOperands;
-    const Fortran::parser::AccObjectListWithModifier &listWithModifier =
-        std::get<Fortran::parser::AccObjectListWithModifier>(cacheConstruct.t);
-    const auto &accObjectList =
-        std::get<Fortran::parser::AccObjectList>(listWithModifier.t);
-    const auto &modifier =
-        std::get<std::optional<Fortran::parser::AccDataModifier>>(
-            listWithModifier.t);
-
-    mlir::acc::DataClause dataClause = mlir::acc::DataClause::acc_cache;
-    if (modifier &&
-        (*modifier).v == Fortran::parser::AccDataModifier::Modifier::ReadOnly)
-      dataClause = mlir::acc::DataClause::acc_cache_readonly;
-    genDataOperandOperations<mlir::acc::CacheOp>(
-        accObjectList, converter, semanticsContext, stmtCtx, cacheOperands,
-        dataClause,
-        /*structured=*/true, /*implicit=*/false,
-        /*async=*/{}, /*asyncDeviceTypes=*/{}, /*asyncOnlyDeviceTypes=*/{},
-        /*setDeclareAttr*/ false);
-    loopOp.getCacheOperandsMutable().append(cacheOperands);
-  } else {
-    llvm::report_fatal_error(
-        "could not find loop to attach OpenACC cache information.");
-  }
-  builder.restoreInsertionPoint(crtPos);
 }
 
 mlir::Value Fortran::lower::genOpenACCConstruct(

@llvmbot
Copy link
Member

llvmbot commented Dec 4, 2025

@llvm/pr-subscribers-openacc

Author: Zhen Wang (wangzpgi)

Changes

Remove unreachable code after the TODO in the acc cache directive lowering function.


Full diff: https://github.com/llvm/llvm-project/pull/170729.diff

1 Files Affected:

  • (modified) flang/lib/Lower/OpenACC.cpp (-31)
diff --git a/flang/lib/Lower/OpenACC.cpp b/flang/lib/Lower/OpenACC.cpp
index 5a548f4fcf435..50b08cea12004 100644
--- a/flang/lib/Lower/OpenACC.cpp
+++ b/flang/lib/Lower/OpenACC.cpp
@@ -4786,39 +4786,8 @@ static void
 genACC(Fortran::lower::AbstractConverter &converter,
        Fortran::semantics::SemanticsContext &semanticsContext,
        const Fortran::parser::OpenACCCacheConstruct &cacheConstruct) {
-  fir::FirOpBuilder &builder = converter.getFirOpBuilder();
   mlir::Location loc = converter.genLocation(cacheConstruct.source);
   TODO(loc, "OpenACC cache directive");
-  auto loopOp = builder.getRegion().getParentOfType<mlir::acc::LoopOp>();
-  auto crtPos = builder.saveInsertionPoint();
-  if (loopOp) {
-    builder.setInsertionPoint(loopOp);
-    Fortran::lower::StatementContext stmtCtx;
-    llvm::SmallVector<mlir::Value> cacheOperands;
-    const Fortran::parser::AccObjectListWithModifier &listWithModifier =
-        std::get<Fortran::parser::AccObjectListWithModifier>(cacheConstruct.t);
-    const auto &accObjectList =
-        std::get<Fortran::parser::AccObjectList>(listWithModifier.t);
-    const auto &modifier =
-        std::get<std::optional<Fortran::parser::AccDataModifier>>(
-            listWithModifier.t);
-
-    mlir::acc::DataClause dataClause = mlir::acc::DataClause::acc_cache;
-    if (modifier &&
-        (*modifier).v == Fortran::parser::AccDataModifier::Modifier::ReadOnly)
-      dataClause = mlir::acc::DataClause::acc_cache_readonly;
-    genDataOperandOperations<mlir::acc::CacheOp>(
-        accObjectList, converter, semanticsContext, stmtCtx, cacheOperands,
-        dataClause,
-        /*structured=*/true, /*implicit=*/false,
-        /*async=*/{}, /*asyncDeviceTypes=*/{}, /*asyncOnlyDeviceTypes=*/{},
-        /*setDeclareAttr*/ false);
-    loopOp.getCacheOperandsMutable().append(cacheOperands);
-  } else {
-    llvm::report_fatal_error(
-        "could not find loop to attach OpenACC cache information.");
-  }
-  builder.restoreInsertionPoint(crtPos);
 }
 
 mlir::Value Fortran::lower::genOpenACCConstruct(

Copy link
Contributor

@clementval clementval left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. You can add [NFC] in your commit title since this does not change the way things work now.

Copy link
Contributor

@razvanlupusoru razvanlupusoru left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! I was debating whether to ask to remove the follow-up code in your initial PR. I was torn since TODO is not meant to be permanent.

@wangzpgi wangzpgi enabled auto-merge (squash) December 4, 2025 19:46
@wangzpgi wangzpgi changed the title [flang] [acc] Remove dead code after acc cache directive TODO [flang] [acc] [NFC] Remove dead code after acc cache directive TODO Dec 4, 2025
@wangzpgi
Copy link
Contributor Author

wangzpgi commented Dec 4, 2025

Thank you! I was debating whether to ask to remove the follow-up code in your initial PR. I was torn since TODO is not meant to be permanent.

I can understand that's a good reason to debate.

@wangzpgi wangzpgi merged commit edbf154 into llvm:main Dec 4, 2025
8 of 9 checks passed
honeygoyal pushed a commit to honeygoyal/llvm-project that referenced this pull request Dec 9, 2025
…70729)

Remove unreachable code after the TODO in the acc cache directive
lowering function.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

flang:fir-hlfir flang Flang issues not falling into any other category openacc

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants