[Flang][OpenMP] DO CONCURRENT device conversion aborts on arrays with nested derived-type components
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
### Description
Flang aborts while converting a valid `DO CONCURRENT` loop to OpenMP device constructs when an array element contains a component whose type is another derived type.
The conversion reaches the following `TODO` while inspecting the nested derived-type component:
https://github.com/llvm/llvm-project/blob/6120eb5267a8643dd399f8858b6c92f23a846551/flang/lib/Optimizer/OpenMP/DoConcurrentConversion.cpp#L599-L627
### Reproducer
```fortran
program 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
if (any(a%member%x /= [1, 2, 3, 4])) error stop 1
end program
```
### Command
```console
flang -c -fopenmp -fdo-concurrent-to-openmp=device \
--offload-arch=gfx908 nested-derived.f90
```
### Result
```text
error: loc("nested-derived.f90":12:20): ../llvm-project/flang/lib/Optimizer/OpenMP/DoConcurrentConversion.cpp:615: not yet implemented: Nested record types are not supported yet.
LLVM ERROR: aborting
```
The reproducer uses no allocatable or pointer components and no procedure calls.
The abort happens at compile time, so reproducing it needs no GPU. The same reproducer compiles successfully with `-fdo-concurrent-to-openmp=host`.
### Expected behavior
Flang should map nested derived-type components or emit an unsupported-feature diagnostic. The compiler should not abort with `LLVM ERROR`.
### Version
The failure was reproduced with Flang 24.0.0git at `00890d9f885989008a8cb5cf5f5335f6f385dbd4` while compiling for AMDGPU. The permalinks above point at upstream commit `6120eb5267a8643dd399f8858b6c92f23a846551`, which still contains the same `TODO`.
### Motivation
The portability study [Portability of Fortran's `do concurrent` on GPUs II](https://arxiv.org/abs/2608.20586) names MAS as its next target beyond POT3D. MAS is a larger application that uses derived types. The paper does not establish whether MAS uses nested derived types. The minimal case still exposes a general device-conversion gap.
Contributor guide
Research direction
Start in flang/lib/Optimizer/OpenMP/DoConcurrentConversion.cpp at the TODO around lines 599-627, then compile the provided nested-derived.f90 reproducer with the device conversion command. Trace how nested derived-type components are inspected; done means the device conversion handles the case or emits an unsupported-feature diagnostic without aborting.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- fortran
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100