[flang-commits] [flang] [flang][cuda] Fix false positive in host intrinsic with device var (PR #174300)
Valentin Clement バレンタイン クレメン via flang-commits
flang-commits at lists.llvm.org
Sat Jan 3 16:04:14 PST 2026
https://github.com/clementval created https://github.com/llvm/llvm-project/pull/174300
#174025 was too strict and make couple of downstream testing fail. Relax the check to skip allowed intrinsics.
>From 366400e755c37e7a4839dd4c8eebcbc8a98a73f6 Mon Sep 17 00:00:00 2001
From: Valentin Clement <clementval at gmail.com>
Date: Sat, 3 Jan 2026 16:01:20 -0800
Subject: [PATCH] [flang][cuda] Fix false positive in host intrinsic with
device var
---
flang/lib/Semantics/check-call.cpp | 21 +++++----------------
flang/test/Semantics/cuf23.cuf | 5 +++++
2 files changed, 10 insertions(+), 16 deletions(-)
diff --git a/flang/lib/Semantics/check-call.cpp b/flang/lib/Semantics/check-call.cpp
index 6ea89a5ca74a2..0cccd32acba3d 100644
--- a/flang/lib/Semantics/check-call.cpp
+++ b/flang/lib/Semantics/check-call.cpp
@@ -341,11 +341,8 @@ static bool DefersSameTypeParameters(
// List of intrinsics that are skipped when checking for device actual
// arguments.
static const llvm::StringSet<> cudaSkippedIntrinsics = {"__builtin_c_devloc",
- "__builtin_c_f_pointer", "__builtin_c_loc", "loc", "present"};
-// List of intrinsics that can have a device actual argument if it is an
-// allocatable or pointer.
-static const llvm::StringSet<> cudaAllowedIntrinsics = {
- "allocated", "associated", "kind", "lbound", "shape", "size", "ubound"};
+ "__builtin_c_f_pointer", "__builtin_c_loc", "allocated", "associated",
+ "kind", "lbound", "loc", "present", "shape", "size", "ubound"};
static void CheckExplicitDataArg(const characteristics::DummyDataObject &dummy,
const std::string &dummyName, evaluate::Expr<evaluate::SomeType> &actual,
@@ -1156,17 +1153,9 @@ static void CheckExplicitDataArg(const characteristics::DummyDataObject &dummy,
actualDataAttr = actualObject->cudaDataAttr();
}
if (actualDataAttr && *actualDataAttr == common::CUDADataAttr::Device) {
- // Allocatable or pointer with device attribute have their descriptor in
- // managed memory. It is allowed to pass them to some inquiry
- // intrinsics.
- if (!actualLastSymbol || !IsAllocatableOrPointer(*actualLastSymbol) ||
- (IsAllocatableOrPointer(*actualLastSymbol) &&
- !cudaAllowedIntrinsics.contains(intrinsic->name))) {
- messages.Say(
- "Actual argument %s associated with host intrinsic %s is on the device"_err_en_US,
- actualLastSymbol ? actualLastSymbol->name() : "",
- intrinsic->name);
- }
+ messages.Say(
+ "Actual argument %s associated with host intrinsic %s is on the device"_err_en_US,
+ actualLastSymbol ? actualLastSymbol->name() : "", intrinsic->name);
}
}
}
diff --git a/flang/test/Semantics/cuf23.cuf b/flang/test/Semantics/cuf23.cuf
index 759a1c4e588b9..2d7b70c021d0c 100644
--- a/flang/test/Semantics/cuf23.cuf
+++ b/flang/test/Semantics/cuf23.cuf
@@ -69,5 +69,10 @@ subroutine intrinsic_error_skipped(ws)
else
p = loc(ws(1))
end if
+end subroutine
+subroutine intrinsic_error_size(n)
+ integer :: n, x
+ real(8), device :: d(n,n)
+ x = size(d,dim=1) ! ok
end subroutine
More information about the flang-commits
mailing list