• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; REQUIRES: object-emission
2; RUN: llc -mtriple=x86_64-unknown-linux-gnu -filetype=obj < %s | llvm-dwarfdump -v - | \
3; RUN:    FileCheck --check-prefix=DEFAULT --check-prefix=BOTH %s
4; RUN: llc -mtriple=x86_64-unknown-linux-gnu -filetype=obj -generate-type-units < %s |  \
5; RUN:    llvm-dwarfdump -v - | FileCheck --check-prefix=TYPEUNITS --check-prefix=BOTH %s
6;
7; Check that we generate the DWARF v5 string offsets section correctly when we
8; have multiple compile and type units. All units share one contribution to
9; the string offsets section.
10;
11; Constructed from the following sources with
12; clang -gdwarf-5 -emit-llvm -S a.cpp
13; clang -gdwarf-5 -emit-llvm -S b.cpp
14; clang -gdwarf-5 -emit-llvm -S c.cpp
15; llvm-link a.ll b.ll c.ll -o test.bc
16; llvm-dis test.bc -o test.ll
17;
18; a.cpp:
19; enum E1 {a, b, c};
20; E1 glob1;
21;
22; b.cpp:
23; enum E2 {d, e, f};
24; E2 glob2;
25;
26; c.cpp:
27; enum E3 {g, h, i};
28; E3 glob3;
29;
30; Check that all 3 compile units have the correct DW_AT_str_offsets_base attributes
31; with the correct offsets. Check that strings referenced by compile units 2 and 3
32; are displayed correctly.
33;
34; CU 1
35; BOTH:        .debug_info contents:
36; BOTH-NOT:    .contents:
37; BOTH:        DW_TAG_compile_unit
38; BOTH-NOT:    {{DW_TAG|NULL}}
39; BOTH:        DW_AT_str_offsets_base [DW_FORM_sec_offset] (0x[[CU1_STROFF:[0-9a-f]+]])
40;
41; CU 2
42; BOTH-NOT:    contents:
43; BOTH:        DW_TAG_compile_unit
44; BOTH-NOT:    {{DW_TAG|NULL}}
45; BOTH:        DW_AT_str_offsets_base [DW_FORM_sec_offset] (0x[[CU1_STROFF]])
46; BOTH-NOT:    NULL
47; BOTH:        DW_TAG_variable
48; BOTH-NOT:    {{DW_TAG|NULL}}
49; BOTH:        DW_AT_name [DW_FORM_strx1] ( indexed (00000009) string = "glob2")
50;
51; CU 3
52; BOTH-NOT:    contents:
53; BOTH:        DW_TAG_compile_unit
54; BOTH-NOT:    {{DW_TAG|NULL}}
55; BOTH:        DW_AT_str_offsets_base [DW_FORM_sec_offset] (0x[[CU1_STROFF]])
56; BOTH-NOT:    NULL
57; BOTH:        DW_TAG_variable
58; BOTH-NOT:    {{DW_TAG|NULL}}
59; BOTH:        DW_AT_name [DW_FORM_strx1] ( indexed (0000000f) string = "glob3")
60;
61; Verify that all 3 type units have the proper DW_AT_str_offsets_base attribute.
62; TYPEUNITS:      .debug_types contents:
63; TYPEUNITS-NOT:  contents:
64; TYPEUNITS:      DW_TAG_type_unit
65; TYPEUNITS-NOT:  {{DW_TAG|NULL}}
66; TYPEUNITS:      DW_AT_str_offsets_base [DW_FORM_sec_offset] (0x[[CU1_STROFF]])
67; TYPEUNITS-NOT:  NULL
68; TYPEUNITS:      DW_TAG_enumerator
69; TYPEUNITS-NOT:  NULL
70; TYPEUNITS:      DW_TAG_enumerator
71; TYPEUNITS-NOT:  {{DW_TAG|NULL}}
72; TYPEUNITS:      DW_AT_name [DW_FORM_strx1] ( indexed (00000005) string = "b")
73; TYPEUNITS-NOT:  contents:
74; TYPEUNITS:      DW_TAG_type_unit
75; TYPEUNITS-NOT:  {{DW_TAG|NULL}}
76; TYPEUNITS:      DW_AT_str_offsets_base [DW_FORM_sec_offset] (0x[[CU1_STROFF]])
77; TYPEUNITS-NOT:  NULL
78; TYPEUNITS:      DW_TAG_enumeration_type
79; TYPEUNITS:      DW_AT_name [DW_FORM_strx1] ( indexed (0000000d) string = "E2")
80; TYPEUNITS-NOT:  contents:
81; TYPEUNITS:      DW_TAG_type_unit
82; TYPEUNITS-NOT:  {{DW_TAG|NULL}}
83; TYPEUNITS:      DW_AT_str_offsets_base [DW_FORM_sec_offset] (0x[[CU1_STROFF]])
84; TYPEUNITS-NOT:  NULL
85; TYPEUNITS:      DW_TAG_enumeration_type
86; TYPEUNITS:      DW_AT_name [DW_FORM_strx1] ( indexed (00000013) string = "E3")
87;
88; Extract the offset of a string to verify that it is referenced in the string
89; offsets section.
90; BOTH:           .debug_str contents:
91; BOTH-NOT:       contents:
92; BOTH:           0x[[GLOB2OFF:[0-9a-f]+]]: "glob2"
93;
94; Check the .debug_str_offsets section header and make sure the referenced string
95; has the correct offset.
96; BOTH:           .debug_str_offsets contents:
97; BOTH-NEXT:      0x00000000: Contribution size = 84, Format = DWARF32, Version = 5
98; BOTH-NEXT:      0x[[CU1_STROFF]]:
99; BOTH-NEXT:      {{.*:}}
100; BOTH-NEXT:      {{.*:}}
101; BOTH-NEXT:      {{.*:}}
102; BOTH-NEXT:      {{.*:}}
103; BOTH-NEXT:      {{.*:}}
104; BOTH-NEXT:      {{.*:}}
105; BOTH-NEXT:      {{.*:}}
106; BOTH-NEXT:      {{.*:}}
107; The string with index 9 should be "glob2"
108; BOTH-NEXT:      {{.*:}} [[GLOB2OFF]]
109;
110; ModuleID = 'test.bc'
111source_filename = "llvm-link"
112
113@glob1 = global i32 0, align 4, !dbg !0
114@glob2 = global i32 0, align 4, !dbg !11
115@glob3 = global i32 0, align 4, !dbg !22
116
117!llvm.dbg.cu = !{!2, !13, !24}
118!llvm.ident = !{!33, !33, !33}
119!llvm.module.flags = !{!34, !35, !36}
120
121!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
122!1 = distinct !DIGlobalVariable(name: "glob1", scope: !2, file: !3, line: 2, type: !5, isLocal: false, isDefinition: true)
123!2 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !3, producer: "clang version 7.0.0 (trunk 322415)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, globals: !10)
124!3 = !DIFile(filename: "a1.cpp", directory: "/home/test", checksumkind: CSK_MD5, checksum: "2ca3eeed18355d6ebbae671eafda5aae")
125!4 = !{!5}
126!5 = distinct !DICompositeType(tag: DW_TAG_enumeration_type, name: "E1", file: !3, line: 1, size: 32, elements: !6, identifier: "_ZTS2E1")
127!6 = !{!7, !8, !9}
128!7 = !DIEnumerator(name: "a", value: 0)
129!8 = !DIEnumerator(name: "b", value: 1)
130!9 = !DIEnumerator(name: "c", value: 2)
131!10 = !{!0}
132!11 = !DIGlobalVariableExpression(var: !12, expr: !DIExpression())
133!12 = distinct !DIGlobalVariable(name: "glob2", scope: !13, file: !14, line: 2, type: !16, isLocal: false, isDefinition: true)
134!13 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !14, producer: "clang version 7.0.0 (trunk 322415)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !15, globals: !21)
135!14 = !DIFile(filename: "b.cpp", directory: "/home/test", checksumkind: CSK_MD5, checksum: "0e254f89617ecb6c4e5473546a99435c")
136!15 = !{!16}
137!16 = distinct !DICompositeType(tag: DW_TAG_enumeration_type, name: "E2", file: !14, line: 1, size: 32, elements: !17, identifier: "_ZTS2E2")
138!17 = !{!18, !19, !20}
139!18 = !DIEnumerator(name: "d", value: 0)
140!19 = !DIEnumerator(name: "e", value: 1)
141!20 = !DIEnumerator(name: "f", value: 2)
142!21 = !{!11}
143!22 = !DIGlobalVariableExpression(var: !23, expr: !DIExpression())
144!23 = distinct !DIGlobalVariable(name: "glob3", scope: !24, file: !25, line: 2, type: !27, isLocal: false, isDefinition: true)
145!24 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !25, producer: "clang version 7.0.0 (trunk 322415)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !26, globals: !32)
146!25 = !DIFile(filename: "c.cpp", directory: "/home/test", checksumkind: CSK_MD5, checksum: "7835aaaa683fa09d295adef0e934d392")
147!26 = !{!27}
148!27 = distinct !DICompositeType(tag: DW_TAG_enumeration_type, name: "E3", file: !25, line: 1, size: 32, elements: !28, identifier: "_ZTS2E3")
149!28 = !{!29, !30, !31}
150!29 = !DIEnumerator(name: "g", value: 0)
151!30 = !DIEnumerator(name: "h", value: 1)
152!31 = !DIEnumerator(name: "i", value: 2)
153!32 = !{!22}
154!33 = !{!"clang version 7.0.0 (trunk 322415)"}
155!34 = !{i32 2, !"Dwarf Version", i32 5}
156!35 = !{i32 2, !"Debug Info Version", i32 3}
157!36 = !{i32 1, !"wchar_size", i32 4}
158