[flang-commits] [flang] [flang][debug] Support TupleType. (PR #113917)

via flang-commits flang-commits at lists.llvm.org
Tue Oct 29 02:56:44 PDT 2024


https://github.com/jeanPerier commented:

These tuple types are used in three contexts:
- in the runtime to implement C struct like types (IO cookie, derived type bindings...)
- to implement the host link of internal procedures (I actually do not know if DWARF needs to know something specific here).
- to implement target ABIs for BIND(C) types and COMPLEX passed in registers.

The last case actually means that the type of functions returning complex may actually not match the dwarf types generated by other compilers for:

```
complex(8) function foo(z) bind(c)
  complex(8), value :: z
  foo = z
end function
```

classic flang generates:
```
!11 = !DIBasicType(tag: DW_TAG_base_type, name: "double complex", size: 128, align: 64, encoding: DW_ATE_complex_float)
!12 = !{ !11, !11 }
!13 = !DISubroutineType(types: !12)
```

And flang will generate:
```
!5 = !DISubroutineType(cc: DW_CC_normal, types: !6)
!6 = !{!7, !10, !10}
!7 = distinct !DICompositeType(tag: DW_TAG_structure_type, scope: !1, file: !2, size: 128, elements: !8)
!8 = !{!9, !11}
!9 = !DIDerivedType(tag: DW_TAG_member, baseType: !10, size: 64, align: 64)
!10 = !DIBasicType(name: "real", size: 64, encoding: DW_ATE_float)
!11 = !DIDerivedType(tag: DW_TAG_member, baseType: !10, size: 64, align: 64, offset: 64)
```

We likely need a solution to keep the dwarf at the Fortran level here.
Maybe the debug info pass should be run before the target rewrite pass. This can be tested in another patch though.

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


More information about the flang-commits mailing list