[flang-commits] [flang] [flang][cuda] Call runtime initialize for derived type with device components (PR #157914)
Valentin Clement バレンタイン クレメン via flang-commits
flang-commits at lists.llvm.org
Wed Sep 10 10:57:50 PDT 2025
https://github.com/clementval created https://github.com/llvm/llvm-project/pull/157914
None
>From 79e0dd2e709bbfd55af5e703b3db18b61a140f23 Mon Sep 17 00:00:00 2001
From: Valentin Clement <clementval at gmail.com>
Date: Wed, 10 Sep 2025 10:57:17 -0700
Subject: [PATCH] [flang][cuda] Call runtime initialize for derived type with
device components
---
flang/lib/Lower/ConvertVariable.cpp | 3 ++-
flang/test/Lower/CUDA/cuda-allocatable-device.cuf | 8 ++++++++
2 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/flang/lib/Lower/ConvertVariable.cpp b/flang/lib/Lower/ConvertVariable.cpp
index b1cd14c56969a..ccfde16ce2c32 100644
--- a/flang/lib/Lower/ConvertVariable.cpp
+++ b/flang/lib/Lower/ConvertVariable.cpp
@@ -842,7 +842,8 @@ void Fortran::lower::defaultInitializeAtRuntime(
Fortran::semantics::DeclTypeSpec::Category::TypeDerived &&
!mlir::isa<fir::SequenceType>(symTy) &&
!sym.test(Fortran::semantics::Symbol::Flag::OmpPrivate) &&
- !sym.test(Fortran::semantics::Symbol::Flag::OmpFirstPrivate)) {
+ !sym.test(Fortran::semantics::Symbol::Flag::OmpFirstPrivate) &&
+ !Fortran::semantics::HasCUDAComponent(sym)) {
std::string globalName = fir::NameUniquer::doGenerated(
(converter.mangleName(*declTy->AsDerived()) + fir::kNameSeparator +
fir::kDerivedTypeInitSuffix)
diff --git a/flang/test/Lower/CUDA/cuda-allocatable-device.cuf b/flang/test/Lower/CUDA/cuda-allocatable-device.cuf
index aed52e7f0f49d..57c588e5beafa 100644
--- a/flang/test/Lower/CUDA/cuda-allocatable-device.cuf
+++ b/flang/test/Lower/CUDA/cuda-allocatable-device.cuf
@@ -12,3 +12,11 @@ end module
! CHECK-LABEL: fir.global linkonce_odr @_QMmE.c.device_array
! CHECK: fir.insert_value %{{.*}}, %c6{{.*}}, ["genre"
! CHECK: fir.insert_value %{{.*}}, %c5{{.*}}, ["genre"
+
+program main
+ use m
+ type(device_array) :: local
+end
+
+! CHECK-LABEL: func.func @_QQmain()
+! CHECK: fir.call @_FortranAInitialize
More information about the flang-commits
mailing list