[all-commits] [llvm/llvm-project] d07dc7: [flang][debug] Support derived types. (#99476)

Abid Qadeer via All-commits all-commits at lists.llvm.org
Tue Aug 27 02:31:11 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: d07dc73bcfcd4026b956eb08b770ff0c47546b66
      https://github.com/llvm/llvm-project/commit/d07dc73bcfcd4026b956eb08b770ff0c47546b66
  Author: Abid Qadeer <haqadeer at amd.com>
  Date:   2024-08-27 (Tue, 27 Aug 2024)

  Changed paths:
    M flang/include/flang/Optimizer/Dialect/FIRType.h
    M flang/lib/Optimizer/CodeGen/Target.cpp
    M flang/lib/Optimizer/Dialect/FIRType.cpp
    M flang/lib/Optimizer/Transforms/AddDebugInfo.cpp
    M flang/lib/Optimizer/Transforms/DebugTypeGenerator.cpp
    M flang/lib/Optimizer/Transforms/DebugTypeGenerator.h
    M flang/lib/Optimizer/Transforms/LoopVersioning.cpp
    A flang/test/Integration/debug-cyclic-derived-type.f90
    A flang/test/Transforms/debug-derived-type-1.fir

  Log Message:
  -----------
  [flang][debug] Support derived types. (#99476)

This PR adds initial debug support for derived type. It handles
`RecordType` and generates appropriate `DICompositeTypeAttr`. The
`TypeInfoOp` is used to get information about the parent and location of
the derived type.

We use `getTypeSizeAndAlignment` to get the size and alignment of the
components of the derived types. This function needed a few changes to
be suitable to be used here:

1. The `getTypeSizeAndAlignment` errored out on unsupported type which
would not work with incremental way we are building debug support. A new
variant of this function has been that returns an std::optional. The original
function has been renamed to `getTypeSizeAndAlignmentOrCrash` as it
will call `TODO()` for unsupported types.

2. The Character type was returning size of just element and not the
whole string which has been fixed.

The testcase checks for offsets of the components which had to be
hardcoded in the test. So the testcase is currently enabled on x86_64.

With this PR in place, this is how the debugging of derived types look
like:

```
type :: t_date
    integer :: year, month, day
  end type

  type :: t_address
    integer :: house_number
  end type
  type, extends(t_address) :: t_person
    character(len=20) name
  end type
  type, extends(t_person)  :: t_employee
    type(t_date) :: hired_date
    real :: monthly_salary
  end type
  type(t_employee) :: employee

(gdb) p employee
$1 = ( t_person = ( t_address = ( house_number = 1 ), name = 'John', ' ' <repeats 16 times> ), hired_date = ( year = 2020, month = 1, day = 20 ), monthly_salary = 3.1400001 )
```



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list