[flang-commits] [flang] [flang][OpenACC] Add TODO for cache directive lowering (PR #170608)

via flang-commits flang-commits at lists.llvm.org
Wed Dec 3 22:16:17 PST 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-openacc

Author: Zhen Wang (wangzpgi)

<details>
<summary>Changes</summary>

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
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

``````````

</details>


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


More information about the flang-commits mailing list