xref: /llvm-project/llvm/test/DebugInfo/X86/debug-names-parents-same-offset.ll (revision 380ac53dfa05792c6f9fd0a4aba542f8c7e5e17c)
1; RUN: llc -mtriple=x86_64 -generate-type-units -dwarf-version=5 -filetype=obj %s -o %t
2; RUN: llvm-dwarfdump -debug-names %t | FileCheck %s
3
4; Two structs that have different names but are structurally identical:
5;    namespace MyNamespace {
6;      struct MyStruct1 {
7;          char c1;
8;      };
9;      struct MyStruct2 {
10;          char c2;
11;      };
12;    } // namespace MyNamespace
13;    MyNamespace::MyStruct1 gv1;
14;    MyNamespace::MyStruct2 gv2;
15
16; Using two TUs, this should produce DIE structures with the same offset.
17; We test that accelerator table generation works with this.
18
19; CHECK:      String: {{.*}} "MyStruct2"
20; CHECK-NEXT:      Entry @ {{.*}} {
21; CHECK-NEXT:        Abbrev: [[ABBREV:0x.*]]
22; CHECK-NEXT:        Tag: DW_TAG_structure_type
23; CHECK-NEXT:        DW_IDX_type_unit: 0x01
24; CHECK-NEXT:        DW_IDX_die_offset: [[DieOffsetStruct:0x.*]]
25; CHECK-NEXT:        DW_IDX_parent: Entry @ [[Parent2:0x.*]]
26; CHECK:      String: {{.*}} "MyNamespace"
27; CHECK-NEXT:      Entry @ [[Parent1:0x.*]] {
28; CHECK-NEXT:        Abbrev: {{.*}}
29; CHECK-NEXT:        Tag: DW_TAG_namespace
30; CHECK-NEXT:        DW_IDX_type_unit: 0x00
31; CHECK-NEXT:        DW_IDX_die_offset: [[DieOffsetNamespace:0x.*]]
32; CHECK-NEXT:        DW_IDX_parent: <parent not indexed>
33; CHECK-NEXT:      }
34; CHECK-NEXT:      Entry @ [[Parent2]] {
35; CHECK-NEXT:        Abbrev: {{.*}}
36; CHECK-NEXT:        Tag: DW_TAG_namespace
37; CHECK-NEXT:        DW_IDX_type_unit: 0x01
38; CHECK-NEXT:        DW_IDX_die_offset: [[DieOffsetNamespace:0x.*]]
39; CHECK-NEXT:        DW_IDX_parent: <parent not indexed>
40; CHECK-NEXT:      }
41; CHECK:      String: {{.*}} "MyStruct1"
42; CHECK-NEXT:      Entry @ {{.*}} {
43; CHECK-NEXT:        Abbrev: [[ABBREV]]
44; CHECK-NEXT:        Tag: DW_TAG_structure_type
45; CHECK-NEXT:        DW_IDX_type_unit: 0x00
46; CHECK-NEXT:        DW_IDX_die_offset: [[DieOffsetStruct:0x.*]]
47; CHECK-NEXT:        DW_IDX_parent: Entry @ [[Parent1]]
48
49
50%"struct.MyNamespace::MyStruct1" = type { i8 }
51%"struct.MyNamespace::MyStruct2" = type { i8 }
52
53@gv1 = dso_local global %"struct.MyNamespace::MyStruct1" zeroinitializer, align 1, !dbg !0
54@gv2 = dso_local global %"struct.MyNamespace::MyStruct2" zeroinitializer, align 1, !dbg !5
55
56!llvm.dbg.cu = !{!2}
57!llvm.module.flags = !{!15, !16, !17, !18, !19}
58!llvm.ident = !{!20}
59
60!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
61!1 = distinct !DIGlobalVariable(name: "gv1", scope: !2, file: !3, line: 10, type: !12, isLocal: false, isDefinition: true)
62!2 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !3, producer: "blah", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, globals: !4, splitDebugInlining: false)
63!3 = !DIFile(filename: "two_tus.cpp", directory: "blah", checksumkind: CSK_MD5, checksum: "69acf04f32811fe7fd35449b58c3f5b1")
64!4 = !{!0, !5}
65!5 = !DIGlobalVariableExpression(var: !6, expr: !DIExpression())
66!6 = distinct !DIGlobalVariable(name: "gv2", scope: !2, file: !3, line: 11, type: !7, isLocal: false, isDefinition: true)
67!7 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "MyStruct2", scope: !8, file: !3, line: 5, size: 8, flags: DIFlagTypePassByValue, elements: !9, identifier: "_ZTSN11MyNamespace9MyStruct2E")
68!8 = !DINamespace(name: "MyNamespace", scope: null)
69!9 = !{!10}
70!10 = !DIDerivedType(tag: DW_TAG_member, name: "c2", scope: !7, file: !3, line: 6, baseType: !11, size: 8)
71!11 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_signed_char)
72!12 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "MyStruct1", scope: !8, file: !3, line: 2, size: 8, flags: DIFlagTypePassByValue, elements: !13, identifier: "_ZTSN11MyNamespace9MyStruct1E")
73!13 = !{!14}
74!14 = !DIDerivedType(tag: DW_TAG_member, name: "c1", scope: !12, file: !3, line: 3, baseType: !11, size: 8)
75!15 = !{i32 7, !"Dwarf Version", i32 5}
76!16 = !{i32 2, !"Debug Info Version", i32 3}
77!17 = !{i32 1, !"wchar_size", i32 4}
78!18 = !{i32 7, !"uwtable", i32 2}
79!19 = !{i32 7, !"frame-pointer", i32 2}
80!20 = !{!"blah"}
81