[flang-commits] [flang] 9fdf2c7 - [flang][cuda] Call runtime initialize for derived type with device components (#157914)
via flang-commits
flang-commits at lists.llvm.org
Wed Sep 10 11:20:00 PDT 2025
Author: Valentin Clement (バレンタイン クレメン)
Date: 2025-09-10T18:19:56Z
New Revision: 9fdf2c7105972f16137bfc74456617dd4669febe
URL: https://github.com/llvm/llvm-project/commit/9fdf2c7105972f16137bfc74456617dd4669febe
DIFF: https://github.com/llvm/llvm-project/commit/9fdf2c7105972f16137bfc74456617dd4669febe.diff
LOG: [flang][cuda] Call runtime initialize for derived type with device components (#157914)
Added:
Modified:
flang/lib/Lower/ConvertVariable.cpp
flang/test/Lower/CUDA/cuda-allocatable-device.cuf
Removed:
################################################################################
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