Skip to content

Conversation

clementval
Copy link
Contributor

No description provided.

@clementval clementval requested a review from wangzpgi September 23, 2025 18:43
@llvmbot llvmbot added flang Flang issues not falling into any other category flang:fir-hlfir labels Sep 23, 2025
@llvmbot
Copy link
Member

llvmbot commented Sep 23, 2025

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

Author: Valentin Clement (バレンタイン クレメン) (clementval)

Changes

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

2 Files Affected:

  • (modified) flang/lib/Lower/ConvertCall.cpp (+2)
  • (modified) flang/test/Lower/CUDA/cuda-runtime-check.cuf (+20-5)
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

@clementval clementval enabled auto-merge (squash) September 23, 2025 18:59
@clementval clementval merged commit 6d0f1e0 into llvm:main Sep 23, 2025
12 checks passed
@clementval clementval deleted the cuf_ignore_tkr_c branch September 23, 2025 20:05
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants