[flang-commits] [flang] [llvm] [Flang][OpenMP] Support nested derived types in DO CONCURRENT device conversion (PR #218963)

Arth Srivastava via flang-commits flang-commits at lists.llvm.org
Tue Sep 8 14:02:46 PDT 2026


================
@@ -0,0 +1,69 @@
+! Regression test for https://github.com/llvm/llvm-project/issues/218760
+! The DO CONCURRENT -> OpenMP device conversion used to abort on arrays
+! whose element type contains a nested derived-type component. Verify that
+! a nested derived type with no allocatable members does not require an
+! implicit mapper and converts successfully, while a nested derived type
+! with allocatable members properly generates implicit mappers.
+
+! RUN: %flang_fc1 -emit-hlfir -fopenmp -fdo-concurrent-to-openmp=device %s -o - \
+! RUN:   | FileCheck %s
+
+module nested_alloc_mod
+  implicit none
+  type :: inner_alloc_t
+    real, allocatable :: values(:)
+  end type
+
+  type :: outer_alloc_t
+    type(inner_alloc_t) :: inner
+  end type
+end module nested_alloc_mod
+
+! CHECK-DAG: omp.declare_mapper @[[INNER_MAPPER:.*inner_alloc_t.*]] : !fir.type<{{.*}}inner_alloc_t{{.*}}>
+! CHECK-DAG: omp.declare_mapper @[[OUTER_MAPPER:.*outer_alloc_t.*]] : !fir.type<{{.*}}outer_alloc_t{{.*}}>
+
+subroutine nested_derived()
+  implicit none
+
+  type :: inner_t
+    integer :: x
+  end type
+
+  type :: outer_t
+    type(inner_t) :: member
+  end type
+
+  type(outer_t) :: a(4)
+  integer :: i
+
+  do concurrent (i = 1:4)
+    a(i)%member%x = i
+  end do
+end subroutine
+
+! CHECK-LABEL: func.func @{{.*}}nested_derived()
+! CHECK:   %[[ARR_A:.*]]:2 = hlfir.declare {{.*}} {uniq_name = "{{.*}}a"}
+! CHECK:   omp.map.info var_ptr(%[[ARR_A]]#1 : {{.*}}) map_clauses(implicit, tofrom) capture(ByRef) {{.*}} name("{{.*}}a")
----------------
Blazearth wrote:

Done in commit `5799721`. The `CHECK-NOT: mapper(` is now placed between the `omp.map.info` prefix and `CHECK-SAME: name("{{.*}}a")`, ensuring any mapper on that same line is caught. Verified with `llvm-lit`.


https://github.com/llvm/llvm-project/pull/218963


More information about the flang-commits mailing list