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

via flang-commits flang-commits at lists.llvm.org
Tue Sep 23 12:02:08 PDT 2025


Author: Valentin Clement (バレンタイン クレメン)
Date: 2025-09-23T19:02:04Z
New Revision: 6d0f1e0346d1f88f90492869b17c0dd7cf677172

URL: https://github.com/llvm/llvm-project/commit/6d0f1e0346d1f88f90492869b17c0dd7cf677172
DIFF: https://github.com/llvm/llvm-project/commit/6d0f1e0346d1f88f90492869b17c0dd7cf677172.diff

LOG: [flang][cuda] Do not add contiguity check with ignore_tkr(c) is present (#160363)

Added: 
    

Modified: 
    flang/lib/Lower/ConvertCall.cpp
    flang/test/Lower/CUDA/cuda-runtime-check.cuf

Removed: 
    


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