[flang-commits] [flang] [flang][cuda] Do not add contiguity check with ignore_tkr(c) is present (PR #160363)

Valentin Clement バレンタイン クレメン via flang-commits flang-commits at lists.llvm.org
Tue Sep 23 11:43:29 PDT 2025


https://github.com/clementval created https://github.com/llvm/llvm-project/pull/160363

None

>From 2c2edeeb72762bf7612a5a92ae895bdc5b126483 Mon Sep 17 00:00:00 2001
From: Valentin Clement <clementval at gmail.com>
Date: Tue, 23 Sep 2025 11:42:54 -0700
Subject: [PATCH] [flang][cuda] Do not add contiguity check with ignore_tkr(c)
 is present

---
 flang/lib/Lower/ConvertCall.cpp              |  2 ++
 flang/test/Lower/CUDA/cuda-runtime-check.cuf | 25 ++++++++++++++++----
 2 files changed, 22 insertions(+), 5 deletions(-)

diff --git a/flang/lib/Lower/ConvertCall.cpp b/flang/lib/Lower/ConvertCall.cpp
index a5a954a5ccea5..fb72040f9ea14 100644
--- a/flang/lib/Lower/ConvertCall.cpp
+++ b/flang/lib/Lower/ConvertCall.cpp
@@ -571,6 +571,8 @@ Fortran::lower::genCallOpAndResult(
         !cuf::isCUDADeviceContext(builder.getRegion())) {
       for (auto [oper, arg] :
            llvm::zip(operands, caller.getPassedArguments())) {
+        if (arg.testTKR(Fortran::common::IgnoreTKR::Contiguous))
+          continue;
         if (auto boxTy = mlir::dyn_cast<fir::BaseBoxType>(oper.getType())) {
           const Fortran::semantics::Symbol *sym = caller.getDummySymbol(arg);
           if (sym && Fortran::evaluate::IsCUDADeviceSymbol(*sym))
diff --git a/flang/test/Lower/CUDA/cuda-runtime-check.cuf b/flang/test/Lower/CUDA/cuda-runtime-check.cuf
index 1aa95ec0ff405..02bb593db7305 100644
--- a/flang/test/Lower/CUDA/cuda-runtime-check.cuf
+++ b/flang/test/Lower/CUDA/cuda-runtime-check.cuf
@@ -16,6 +16,10 @@ contains
     call foo(a(1:10,1:10:2))
   end subroutine
 
+! CHECK-LABEL: func.func @_QMsection_testPtest_host()
+! CHECK: fir.call @_FortranACUFDescriptorCheckSection
+! CHECK: fir.call @_QMsection_testPfoo
+
   attributes(device) subroutine zoo(a)
     real, device, dimension(:,:) :: a
   end subroutine
@@ -25,12 +29,23 @@ contains
     allocate(a(10,10))
     call zoo(a(1:10,1:10:2))
   end subroutine
-end module
-
-! CHECK-LABEL: func.func @_QMsection_testPtest_host()
-! CHECK: fir.call @_FortranACUFDescriptorCheckSection
-! CHECK: fir.call @_QMsection_testPfoo
 
 ! CHECK-LABEL: func.func @_QMsection_testPtest_device()
 ! CHECK-NOT: fir.call @_FortranACUFDescriptorCheckSection
 ! CHECK: fir.call @_QMsection_testPzoo
+
+  subroutine ignore(a)
+    real, device, dimension(:,:) :: a
+    !dir$ ignore_tkr(c) a
+  end subroutine
+
+  subroutine test_host2()
+    real, device, allocatable, dimension(:,:) :: a
+    allocate(a(10,10))
+    call ignore(a(1:10,1:10:2))
+  end subroutine
+
+! CHECK-LABEL: func.func @_QMsection_testPtest_host2()
+! CHECK-NOT: fir.call @_FortranACUFDescriptorCheckSection
+! CHECK: fir.call @_QMsection_testPignore
+end module



More information about the flang-commits mailing list