Skip to content

Conversation

@wangzpgi
Copy link
Contributor

@wangzpgi wangzpgi commented Dec 4, 2025

The OpenACC cache directive is not yet fully implemented. Add a TODO to emit a clear "not yet implemented" error during lowering.

@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

@llvm/pr-subscribers-openacc

Author: Zhen Wang (wangzpgi)

Changes

The OpenACC cache directive is not yet fully implemented. Add a TODO to emit a clear "not yet implemented" error during lowering.


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

3 Files Affected:

  • (modified) flang/lib/Lower/OpenACC.cpp (+2)
  • (added) flang/test/Lower/OpenACC/Todo/acc-cache.f90 (+15)
  • (modified) flang/test/Lower/OpenACC/acc-loop.f90 (-9)
diff --git a/flang/lib/Lower/OpenACC.cpp b/flang/lib/Lower/OpenACC.cpp
index 69c3300ba4390..5a548f4fcf435 100644
--- a/flang/lib/Lower/OpenACC.cpp
+++ b/flang/lib/Lower/OpenACC.cpp
@@ -4787,6 +4787,8 @@ 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) {
diff --git a/flang/test/Lower/OpenACC/Todo/acc-cache.f90 b/flang/test/Lower/OpenACC/Todo/acc-cache.f90
new file mode 100644
index 0000000000000..8b81e876ed2c9
--- /dev/null
+++ b/flang/test/Lower/OpenACC/Todo/acc-cache.f90
@@ -0,0 +1,15 @@
+! RUN: %not_todo_cmd bbc -fopenacc -emit-hlfir %s -o - 2>&1 | FileCheck %s
+
+! CHECK: not yet implemented: OpenACC cache directive
+
+subroutine test_cache()
+  integer, parameter :: n = 10
+  real, dimension(n) :: a, b
+  integer :: i
+
+  !$acc loop
+  do i = 1, n
+    !$acc cache(b)
+    a(i) = b(i)
+  end do
+end subroutine
diff --git a/flang/test/Lower/OpenACC/acc-loop.f90 b/flang/test/Lower/OpenACC/acc-loop.f90
index 6adf06ad9cd53..ed87cf76038b5 100644
--- a/flang/test/Lower/OpenACC/acc-loop.f90
+++ b/flang/test/Lower/OpenACC/acc-loop.f90
@@ -359,15 +359,6 @@ program acc_loop
 ! CHECK:        acc.yield
 ! CHECK-NEXT: } attributes {inclusiveUpperbound = array<i1: true>, independent = [#acc.device_type<none>]}
 
-  !$acc loop
-  DO i = 1, n
-    !$acc cache(b)
-    a(i) = b(i)
-  END DO
-
-! CHECK: %[[CACHE:.*]] = acc.cache varPtr(%{{.*}} : !fir.ref<!fir.array<10xf32>>) -> !fir.ref<!fir.array<10xf32>> {name = "b"}
-! CHECK: acc.loop {{.*}} cache(%[[CACHE]] : !fir.ref<!fir.array<10xf32>>)
-
   !$acc loop
   do 100 i=0, n
   100 continue

@razvanlupusoru razvanlupusoru changed the title [flang][OpenACC] Add TODO for cache directive lowering [flang][acc] Add TODO for cache directive lowering Dec 4, 2025
@wangzpgi wangzpgi enabled auto-merge (squash) December 4, 2025 06:25
@wangzpgi wangzpgi merged commit 6c73f5e into llvm:main Dec 4, 2025
10 checks passed
const Fortran::parser::OpenACCCacheConstruct &cacheConstruct) {
fir::FirOpBuilder &builder = converter.getFirOpBuilder();
mlir::Location loc = converter.genLocation(cacheConstruct.source);
TODO(loc, "OpenACC cache directive");
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we keep the code after the TODO?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The PR was auto-merged before I saw your comment. I will clean up in a separate PR. Thanks.

kcloudy0717 pushed a commit to kcloudy0717/llvm-project that referenced this pull request Dec 4, 2025
The OpenACC cache directive is not yet fully implemented. Add a TODO to
emit a clear "not yet implemented" error during lowering.
@wangzpgi wangzpgi deleted the acctodo branch December 4, 2025 19:51
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