brintos

brintos / llvm-project-archived public Read only

0
0
Text · 4.1 KiB · 72b7a78 Raw
117 lines · plain
1! RUN: %flang_fc1 -emit-llvm -debug-info-kind=standalone %s -o - | FileCheck  %s2 3! Test that debug metadata for derived types is not duplicated more than needed4! when emitting debug info with non trivial cycles.5 6 7! In the type graph below, G has a back edge to B, and F to D.8! This causes C to be in the middle of B cycle, and E to be9! both in B and D cycles.10! C and E are used in several contexts, under B, under D, and outside11! of it to test how metadata is generated for them.12!13! Without "local caching" of C and E when generating mlir::LLVM::DITypeAttr14! for such derived types, many duplicate llvm metadata for the derived types15! would be emitted, while with the right duplication of mlir::LLVM::DITypeAttr,16! a lot more duplicate llvm IR metadata ends up emitted (19 DICompositeType17! vs 71 before the patch that added this test).18!19!20!  A -> B -> C -> D -> E -> F -> G -> B21!  |    |         |         |22!  |    |         |         | -> D23!  |    |         |24!  |    |         | -> H -> E25!  |    |26!  |    | -> I -> E27!  |         | -> C28!  |29!  | -> C30!  | -> E31 32subroutine type_cycles_caching()33  type g34    type(b), pointer :: c_b35  end type36  type f37    type(g) :: c_b38    type(d), pointer :: c_d39  end type40  type e41    type(f) :: c_f42  end type43    type h44      ! Can reuse metadata of type(e) under 'd'.45      type(e) :: c_e46    end type47  type d48    type(e) :: c_e49    type(h) :: c_h50  end type51  type c52    type(d) :: c_d53  end type54    type i55      ! Cannot reuse metadata of type(e) under 'd'.56      type(e) :: c_e57      ! Can reuse metadata of type(c) under 'b'.58      type(c) :: c_c59    end type60  type b61    type(c) :: c_c62    type(i) :: c_i63  end type64  type a65    type(b) :: c_b66    ! Cannot reuse metadata of type(c) under 'b'67    type(c) :: c_c68    ! Cannot reuse metadata of type(e) under 'd', nor the one under 'b'69    type(e) :: c_e70  end type71  type(a) :: xa72  ! Can reuse metadata of type(c) for xa%c_c73  type(c) :: xc74  ! Can reuse metadata of type(c) for xa%c_e75  type(e) :: xe76  call bar(xa, xc, xe)77end subroutine78 79! CHECK: distinct !DICompositeType(tag: DW_TAG_structure_type, name: "a",80! CHECK-NOT: distinct !DICompositeType81! CHECK: distinct !DICompositeType(tag: DW_TAG_structure_type, name: "b",82! CHECK-NOT: distinct !DICompositeType83! CHECK: distinct !DICompositeType(tag: DW_TAG_structure_type, name: "c",84! CHECK-NOT: distinct !DICompositeType85! CHECK: distinct !DICompositeType(tag: DW_TAG_structure_type, name: "d",86! CHECK-NOT: distinct !DICompositeType87! CHECK: distinct !DICompositeType(tag: DW_TAG_structure_type, name: "e",88! CHECK-NOT: distinct !DICompositeType89! CHECK: distinct !DICompositeType(tag: DW_TAG_structure_type, name: "f",90! CHECK-NOT: distinct !DICompositeType91! CHECK: distinct !DICompositeType(tag: DW_TAG_structure_type, name: "g",92! CHECK-NOT: distinct !DICompositeType93! CHECK: distinct !DICompositeType(tag: DW_TAG_structure_type, name: "h",94! CHECK-NOT: distinct !DICompositeType95! CHECK: distinct !DICompositeType(tag: DW_TAG_structure_type, name: "i",96! CHECK-NOT: distinct !DICompositeType97! CHECK: distinct !DICompositeType(tag: DW_TAG_structure_type, name: "e"98! CHECK-NOT: distinct !DICompositeType99! CHECK: distinct !DICompositeType(tag: DW_TAG_structure_type, name: "f"100! CHECK-NOT: distinct !DICompositeType101! CHECK: distinct !DICompositeType(tag: DW_TAG_structure_type, name: "c"102! CHECK-NOT: distinct !DICompositeType103! CHECK: distinct !DICompositeType(tag: DW_TAG_structure_type, name: "d"104! CHECK-NOT: distinct !DICompositeType105! CHECK: distinct !DICompositeType(tag: DW_TAG_structure_type, name: "e"106! CHECK-NOT: distinct !DICompositeType107! CHECK: distinct !DICompositeType(tag: DW_TAG_structure_type, name: "f"108! CHECK-NOT: distinct !DICompositeType109! CHECK: distinct !DICompositeType(tag: DW_TAG_structure_type, name: "g"110! CHECK-NOT: distinct !DICompositeType111! CHECK: distinct !DICompositeType(tag: DW_TAG_structure_type, name: "h"112! CHECK-NOT: distinct !DICompositeType113! CHECK: distinct !DICompositeType(tag: DW_TAG_structure_type, name: "e"114! CHECK-NOT: distinct !DICompositeType115! CHECK: distinct !DICompositeType(tag: DW_TAG_structure_type, name: "f"116! CHECK-NOT: distinct !DICompositeType117