blob: df86576462e0e360b91fdebcb15a159aae1c5f0b [file] [log] [blame]
Eric Christopher67646432013-07-26 17:02:41 +00001; REQUIRES: object-emission
2
David Blaikie409dd9c2013-11-19 23:08:21 +00003; RUN: llc %s -o %t -filetype=obj -O0 -generate-type-units -generate-odr-hash -mtriple=x86_64-unknown-linux-gnu
David Blaikie8a263cb2013-11-26 00:22:37 +00004; RUN: llvm-dwarfdump %t | FileCheck %s
5
Eric Christopher67646432013-07-26 17:02:41 +00006; Generated from:
Eric Christopher67646432013-07-26 17:02:41 +00007; struct bar {};
Eric Christophere414ece2013-07-29 23:53:08 +00008
Eric Christopher67646432013-07-26 17:02:41 +00009; struct bar b;
Eric Christophere414ece2013-07-29 23:53:08 +000010
Eric Christopher67646432013-07-26 17:02:41 +000011; void foo(void) {
12; struct baz {};
13; baz b;
14; }
Eric Christophere414ece2013-07-29 23:53:08 +000015
Eric Christopher67646432013-07-26 17:02:41 +000016; namespace echidna {
17; namespace capybara {
18; namespace mongoose {
19; class fluffy {
20; int a;
21; int b;
22; };
Eric Christophere414ece2013-07-29 23:53:08 +000023
Eric Christopher67646432013-07-26 17:02:41 +000024; fluffy animal;
25; }
26; }
27; }
Eric Christophere414ece2013-07-29 23:53:08 +000028
Eric Christopher67646432013-07-26 17:02:41 +000029; namespace {
Eric Christophere414ece2013-07-29 23:53:08 +000030; struct walrus {
31; walrus() {}
32; };
Eric Christopher67646432013-07-26 17:02:41 +000033; }
Eric Christophere414ece2013-07-29 23:53:08 +000034
Eric Christopher67646432013-07-26 17:02:41 +000035; walrus w;
Eric Christophere414ece2013-07-29 23:53:08 +000036
Eric Christopherd853ea32013-07-29 23:53:05 +000037; struct wombat {
38; struct {
Eric Christophere414ece2013-07-29 23:53:08 +000039; int a;
40; int b;
Eric Christopherd853ea32013-07-29 23:53:05 +000041; } a_b;
42; };
Eric Christophere414ece2013-07-29 23:53:08 +000043
Eric Christopherd853ea32013-07-29 23:53:05 +000044; wombat wom;
Eric Christopher67646432013-07-26 17:02:41 +000045
David Blaikie8a263cb2013-11-26 00:22:37 +000046; CHECK-LABEL: .debug_info contents:
47
Eric Christopherd853ea32013-07-29 23:53:05 +000048; Check that we generate a hash for bar and the value.
David Blaikie409dd9c2013-11-19 23:08:21 +000049; CHECK-LABEL: DW_AT_GNU_odr_signature [DW_FORM_data8] (0x200520c0d5b90eff)
Eric Christopher67646432013-07-26 17:02:41 +000050; CHECK: DW_TAG_structure_type
51; CHECK-NEXT: debug_str{{.*}}"bar"
David Blaikie409dd9c2013-11-19 23:08:21 +000052
53; Check that we generate a hash for fluffy and the value.
54; CHECK-LABEL: DW_AT_GNU_odr_signature [DW_FORM_data8] (0x9a0124d5a0c21c52)
Eric Christopher67646432013-07-26 17:02:41 +000055; CHECK: DW_TAG_namespace
56; CHECK-NEXT: debug_str{{.*}}"echidna"
57; CHECK: DW_TAG_namespace
58; CHECK-NEXT: debug_str{{.*}}"capybara"
59; CHECK: DW_TAG_namespace
60; CHECK-NEXT: debug_str{{.*}}"mongoose"
61; CHECK: DW_TAG_class_type
62; CHECK-NEXT: debug_str{{.*}}"fluffy"
Eric Christopherd853ea32013-07-29 23:53:05 +000063
Eric Christophere414ece2013-07-29 23:53:08 +000064; We emit no hash for walrus since the type is contained in an anonymous
65; namespace and won't violate any ODR-ness.
David Blaikie409dd9c2013-11-19 23:08:21 +000066; CHECK: DW_TAG_type_unit
67; CHECK-NOT: NULL
68; CHECK-NOT: DW_AT_GNU_odr_signature
Eric Christophere414ece2013-07-29 23:53:08 +000069; CHECK: DW_TAG_structure_type
70; CHECK-NEXT: debug_str{{.*}}"walrus"
71; CHECK-NEXT: DW_AT_byte_size
72; CHECK-NEXT: DW_AT_decl_file
73; CHECK-NEXT: DW_AT_decl_line
Eric Christophere414ece2013-07-29 23:53:08 +000074; CHECK: DW_TAG_subprogram
75
David Blaikie409dd9c2013-11-19 23:08:21 +000076
Eric Christopherd853ea32013-07-29 23:53:05 +000077; Check that we generate a hash for wombat and the value, but not for the
78; anonymous type contained within.
David Blaikie409dd9c2013-11-19 23:08:21 +000079; CHECK: DW_TAG_type_unit
Eric Christopherd853ea32013-07-29 23:53:05 +000080; CHECK: DW_TAG_structure_type
David Blaikie409dd9c2013-11-19 23:08:21 +000081; The signature for the outer 'wombat' type - this can be FileChecked once the
82; type units are moved to their own section with the full type unit header
83; including the signature
84; CHECK: DW_AT_signature [DW_FORM_ref_sig8] (0x73776f130648b986)
Eric Christopherd853ea32013-07-29 23:53:05 +000085; CHECK: DW_TAG_structure_type
David Blaikie409dd9c2013-11-19 23:08:21 +000086; CHECK-NOT: DW_AT_name
87; CHECK-NOT: DW_AT_GNU_odr_signature
Eric Christopherd853ea32013-07-29 23:53:05 +000088; CHECK: DW_TAG_member
89; CHECK-NEXT: debug_str{{.*}}"a"
David Blaikie409dd9c2013-11-19 23:08:21 +000090; CHECK-LABEL: DW_AT_GNU_odr_signature [DW_FORM_data8] (0x685bcc220141e9d7)
Eric Christopher67646432013-07-26 17:02:41 +000091; CHECK: DW_TAG_structure_type
David Blaikie409dd9c2013-11-19 23:08:21 +000092; CHECK-NEXT: debug_str{{.*}}"wombat"
Eric Christopherd853ea32013-07-29 23:53:05 +000093
David Blaikiefd1eff52013-11-26 19:14:34 +000094; Use the unit size as a rough hash/identifier for the unit we're dealing with
95; it happens to be unambiguous at the moment, but it's hardly ideal.
David Blaikie8a263cb2013-11-26 00:22:37 +000096; CHECK-LABEL: .debug_pubtypes contents:
David Blaikiefd1eff52013-11-26 19:14:34 +000097; Don't emit pubtype entries for type DIEs in the compile unit that just indirect to a type unit.
98; CHECK-NEXT: unit_size = 0x00000174
99; CHECK-NEXT: Offset Name
100; Type unit for 'bar'
101; CHECK-NEXT: unit_size = 0x0000001f
102; CHECK-NEXT: Offset Name
103; CHECK-NEXT: "bar"
104; CHECK-NEXT: unit_size = 0x00000059
105; CHECK-NEXT: Offset Name
106; CHECK-NEXT: "int"
107; CHECK-NEXT: "echidna::capybara::mongoose::fluffy"
108; CHECK-NEXT: unit_size = 0x0000002f
109; CHECK-NEXT: Offset Name
110; CHECK-NEXT: "walrus"
111; CHECK-NEXT: unit_size = 0x0000003f
112; CHECK-NEXT: Offset Name
113; CHECK-NEXT: "int"
114; CHECK-NEXT: unit_size = 0x00000036
115; CHECK-NEXT: Offset Name
116; CHECK-NEXT: "wombat"
David Blaikie8a263cb2013-11-26 00:22:37 +0000117
Eric Christopher67646432013-07-26 17:02:41 +0000118%struct.bar = type { i8 }
119%"class.echidna::capybara::mongoose::fluffy" = type { i32, i32 }
Eric Christophere414ece2013-07-29 23:53:08 +0000120%"struct.<anonymous namespace>::walrus" = type { i8 }
Eric Christopherd853ea32013-07-29 23:53:05 +0000121%struct.wombat = type { %struct.anon }
122%struct.anon = type { i32, i32 }
Eric Christopher67646432013-07-26 17:02:41 +0000123%struct.baz = type { i8 }
124
125@b = global %struct.bar zeroinitializer, align 1
126@_ZN7echidna8capybara8mongoose6animalE = global %"class.echidna::capybara::mongoose::fluffy" zeroinitializer, align 4
Eric Christophere414ece2013-07-29 23:53:08 +0000127@w = internal global %"struct.<anonymous namespace>::walrus" zeroinitializer, align 1
Eric Christopherd853ea32013-07-29 23:53:05 +0000128@wom = global %struct.wombat zeroinitializer, align 4
Eric Christophere414ece2013-07-29 23:53:08 +0000129@llvm.global_ctors = appending global [1 x { i32, void ()* }] [{ i32, void ()* } { i32 65535, void ()* @_GLOBAL__I_a }]
130
131@_ZN12_GLOBAL__N_16walrusC1Ev = alias internal void (%"struct.<anonymous namespace>::walrus"*)* @_ZN12_GLOBAL__N_16walrusC2Ev
Eric Christopher67646432013-07-26 17:02:41 +0000132
133; Function Attrs: nounwind uwtable
134define void @_Z3foov() #0 {
135entry:
136 %b = alloca %struct.baz, align 1
David Blaikieba8125d2013-11-01 22:29:28 +0000137 call void @llvm.dbg.declare(metadata !{%struct.baz* %b}, metadata !44), !dbg !46
138 ret void, !dbg !47
Eric Christopher67646432013-07-26 17:02:41 +0000139}
140
141; Function Attrs: nounwind readnone
142declare void @llvm.dbg.declare(metadata, metadata) #1
143
Eric Christophere414ece2013-07-29 23:53:08 +0000144define internal void @__cxx_global_var_init() section ".text.startup" {
145entry:
David Blaikieba8125d2013-11-01 22:29:28 +0000146 call void @_ZN12_GLOBAL__N_16walrusC1Ev(%"struct.<anonymous namespace>::walrus"* @w), !dbg !48
147 ret void, !dbg !48
Eric Christophere414ece2013-07-29 23:53:08 +0000148}
149
150; Function Attrs: nounwind uwtable
151define internal void @_ZN12_GLOBAL__N_16walrusC2Ev(%"struct.<anonymous namespace>::walrus"* %this) unnamed_addr #0 align 2 {
152entry:
153 %this.addr = alloca %"struct.<anonymous namespace>::walrus"*, align 8
154 store %"struct.<anonymous namespace>::walrus"* %this, %"struct.<anonymous namespace>::walrus"** %this.addr, align 8
David Blaikieba8125d2013-11-01 22:29:28 +0000155 call void @llvm.dbg.declare(metadata !{%"struct.<anonymous namespace>::walrus"** %this.addr}, metadata !49), !dbg !51
Eric Christophere414ece2013-07-29 23:53:08 +0000156 %this1 = load %"struct.<anonymous namespace>::walrus"** %this.addr
David Blaikieba8125d2013-11-01 22:29:28 +0000157 ret void, !dbg !52
Eric Christophere414ece2013-07-29 23:53:08 +0000158}
159
160define internal void @_GLOBAL__I_a() section ".text.startup" {
161entry:
David Blaikieba8125d2013-11-01 22:29:28 +0000162 call void @__cxx_global_var_init(), !dbg !53
163 ret void, !dbg !53
Eric Christophere414ece2013-07-29 23:53:08 +0000164}
165
David Blaikieba8125d2013-11-01 22:29:28 +0000166attributes #0 = { nounwind uwtable "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
Eric Christopher67646432013-07-26 17:02:41 +0000167attributes #1 = { nounwind readnone }
168
169!llvm.dbg.cu = !{!0}
Manman Ren409558f2013-11-22 21:49:45 +0000170!llvm.module.flags = !{!42, !54}
David Blaikieba8125d2013-11-01 22:29:28 +0000171!llvm.ident = !{!43}
Eric Christopher67646432013-07-26 17:02:41 +0000172
David Blaikieba8125d2013-11-01 22:29:28 +0000173!0 = metadata !{i32 786449, metadata !1, i32 4, metadata !"clang version 3.4 ", i1 false, metadata !"", i32 0, metadata !2, metadata !3, metadata !20, metadata !37, metadata !2, metadata !""} ; [ DW_TAG_compile_unit ] [/tmp/dbginfo/bar.cpp] [DW_LANG_C_plus_plus]
174!1 = metadata !{metadata !"bar.cpp", metadata !"/tmp/dbginfo"}
Eric Christopher67646432013-07-26 17:02:41 +0000175!2 = metadata !{i32 0}
David Blaikieba8125d2013-11-01 22:29:28 +0000176!3 = metadata !{metadata !4, metadata !5, metadata !13, metadata !16}
177!4 = metadata !{i32 786451, metadata !1, null, metadata !"bar", i32 1, i64 8, i64 8, i32 0, i32 0, null, metadata !2, i32 0, null, null, metadata !"_ZTS3bar"} ; [ DW_TAG_structure_type ] [bar] [line 1, size 8, align 8, offset 0] [def] [from ]
178!5 = metadata !{i32 786434, metadata !1, metadata !6, metadata !"fluffy", i32 13, i64 64, i64 32, i32 0, i32 0, null, metadata !9, i32 0, null, null, metadata !"_ZTSN7echidna8capybara8mongoose6fluffyE"} ; [ DW_TAG_class_type ] [fluffy] [line 13, size 64, align 32, offset 0] [def] [from ]
179!6 = metadata !{i32 786489, metadata !1, metadata !7, metadata !"mongoose", i32 12} ; [ DW_TAG_namespace ] [mongoose] [line 12]
180!7 = metadata !{i32 786489, metadata !1, metadata !8, metadata !"capybara", i32 11} ; [ DW_TAG_namespace ] [capybara] [line 11]
181!8 = metadata !{i32 786489, metadata !1, null, metadata !"echidna", i32 10} ; [ DW_TAG_namespace ] [echidna] [line 10]
182!9 = metadata !{metadata !10, metadata !12}
183!10 = metadata !{i32 786445, metadata !1, metadata !"_ZTSN7echidna8capybara8mongoose6fluffyE", metadata !"a", i32 14, i64 32, i64 32, i64 0, i32 1, metadata !11} ; [ DW_TAG_member ] [a] [line 14, size 32, align 32, offset 0] [private] [from int]
184!11 = metadata !{i32 786468, null, null, metadata !"int", i32 0, i64 32, i64 32, i64 0, i32 0, i32 5} ; [ DW_TAG_base_type ] [int] [line 0, size 32, align 32, offset 0, enc DW_ATE_signed]
185!12 = metadata !{i32 786445, metadata !1, metadata !"_ZTSN7echidna8capybara8mongoose6fluffyE", metadata !"b", i32 15, i64 32, i64 32, i64 32, i32 1, metadata !11} ; [ DW_TAG_member ] [b] [line 15, size 32, align 32, offset 32] [private] [from int]
186!13 = metadata !{i32 786451, metadata !1, null, metadata !"wombat", i32 31, i64 64, i64 32, i32 0, i32 0, null, metadata !14, i32 0, null, null, metadata !"_ZTS6wombat"} ; [ DW_TAG_structure_type ] [wombat] [line 31, size 64, align 32, offset 0] [def] [from ]
187!14 = metadata !{metadata !15}
188!15 = metadata !{i32 786445, metadata !1, metadata !"_ZTS6wombat", metadata !"a_b", i32 35, i64 64, i64 32, i64 0, i32 0, metadata !"_ZTSN6wombatUt_E"} ; [ DW_TAG_member ] [a_b] [line 35, size 64, align 32, offset 0] [from _ZTSN6wombatUt_E]
189!16 = metadata !{i32 786451, metadata !1, metadata !"_ZTS6wombat", metadata !"", i32 32, i64 64, i64 32, i32 0, i32 0, null, metadata !17, i32 0, null, null, metadata !"_ZTSN6wombatUt_E"} ; [ DW_TAG_structure_type ] [line 32, size 64, align 32, offset 0] [def] [from ]
190!17 = metadata !{metadata !18, metadata !19}
191!18 = metadata !{i32 786445, metadata !1, metadata !"_ZTSN6wombatUt_E", metadata !"a", i32 33, i64 32, i64 32, i64 0, i32 0, metadata !11} ; [ DW_TAG_member ] [a] [line 33, size 32, align 32, offset 0] [from int]
192!19 = metadata !{i32 786445, metadata !1, metadata !"_ZTSN6wombatUt_E", metadata !"b", i32 34, i64 32, i64 32, i64 32, i32 0, metadata !11} ; [ DW_TAG_member ] [b] [line 34, size 32, align 32, offset 32] [from int]
193!20 = metadata !{metadata !21, metadata !25, metadata !26, metadata !35}
194!21 = metadata !{i32 786478, metadata !1, metadata !22, metadata !"foo", metadata !"foo", metadata !"_Z3foov", i32 5, metadata !23, i1 false, i1 true, i32 0, i32 0, null, i32 256, i1 false, void ()* @_Z3foov, null, null, metadata !2, i32 5} ; [ DW_TAG_subprogram ] [line 5] [def] [foo]
195!22 = metadata !{i32 786473, metadata !1} ; [ DW_TAG_file_type ] [/tmp/dbginfo/bar.cpp]
196!23 = metadata !{i32 786453, i32 0, null, metadata !"", i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !24, i32 0, null, null, null} ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ]
197!24 = metadata !{null}
198!25 = metadata !{i32 786478, metadata !1, metadata !22, metadata !"__cxx_global_var_init", metadata !"__cxx_global_var_init", metadata !"", i32 29, metadata !23, i1 true, i1 true, i32 0, i32 0, null, i32 256, i1 false, void ()* @__cxx_global_var_init, null, null, metadata !2, i32 29} ; [ DW_TAG_subprogram ] [line 29] [local] [def] [__cxx_global_var_init]
199!26 = metadata !{i32 786478, metadata !1, metadata !27, metadata !"walrus", metadata !"walrus", metadata !"_ZN12_GLOBAL__N_16walrusC2Ev", i32 25, metadata !31, i1 true, i1 true, i32 0, i32 0, null, i32 256, i1 false, void (%"struct.<anonymous namespace>::walrus"*)* @_ZN12_GLOBAL__N_16walrusC2Ev, null, metadata !30, metadata !2, i32 25} ; [ DW_TAG_subprogram ] [line 25] [local] [def] [walrus]
200!27 = metadata !{i32 786451, metadata !1, metadata !28, metadata !"walrus", i32 24, i64 8, i64 8, i32 0, i32 0, null, metadata !29, i32 0, null, null, null} ; [ DW_TAG_structure_type ] [walrus] [line 24, size 8, align 8, offset 0] [def] [from ]
201!28 = metadata !{i32 786489, metadata !1, null, metadata !"", i32 23} ; [ DW_TAG_namespace ] [line 23]
202!29 = metadata !{metadata !30}
203!30 = metadata !{i32 786478, metadata !1, metadata !27, metadata !"walrus", metadata !"walrus", metadata !"", i32 25, metadata !31, i1 false, i1 false, i32 0, i32 0, null, i32 256, i1 false, null, null, i32 0, metadata !34, i32 25} ; [ DW_TAG_subprogram ] [line 25] [walrus]
204!31 = metadata !{i32 786453, i32 0, null, metadata !"", i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !32, i32 0, null, null, null} ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ]
205!32 = metadata !{null, metadata !33}
206!33 = metadata !{i32 786447, null, null, metadata !"", i32 0, i64 64, i64 64, i64 0, i32 1088, metadata !27} ; [ DW_TAG_pointer_type ] [line 0, size 64, align 64, offset 0] [artificial] [from walrus]
207!34 = metadata !{i32 786468}
208!35 = metadata !{i32 786478, metadata !1, metadata !22, metadata !"", metadata !"", metadata !"_GLOBAL__I_a", i32 25, metadata !36, i1 true, i1 true, i32 0, i32 0, null, i32 64, i1 false, void ()* @_GLOBAL__I_a, null, null, metadata !2, i32 25} ; [ DW_TAG_subprogram ] [line 25] [local] [def]
209!36 = metadata !{i32 786453, i32 0, null, metadata !"", i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !2, i32 0, null, null, null} ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ]
210!37 = metadata !{metadata !38, metadata !39, metadata !40, metadata !41}
211!38 = metadata !{i32 786484, i32 0, null, metadata !"b", metadata !"b", metadata !"", metadata !22, i32 3, metadata !4, i32 0, i32 1, %struct.bar* @b, null} ; [ DW_TAG_variable ] [b] [line 3] [def]
212!39 = metadata !{i32 786484, i32 0, metadata !6, metadata !"animal", metadata !"animal", metadata !"_ZN7echidna8capybara8mongoose6animalE", metadata !22, i32 18, metadata !5, i32 0, i32 1, %"class.echidna::capybara::mongoose::fluffy"* @_ZN7echidna8capybara8mongoose6animalE, null} ; [ DW_TAG_variable ] [animal] [line 18] [def]
213!40 = metadata !{i32 786484, i32 0, null, metadata !"w", metadata !"w", metadata !"", metadata !22, i32 29, metadata !27, i32 1, i32 1, %"struct.<anonymous namespace>::walrus"* @w, null} ; [ DW_TAG_variable ] [w] [line 29] [local] [def]
214!41 = metadata !{i32 786484, i32 0, null, metadata !"wom", metadata !"wom", metadata !"", metadata !22, i32 38, metadata !13, i32 0, i32 1, %struct.wombat* @wom, null} ; [ DW_TAG_variable ] [wom] [line 38] [def]
215!42 = metadata !{i32 2, metadata !"Dwarf Version", i32 4}
216!43 = metadata !{metadata !"clang version 3.4 "}
217!44 = metadata !{i32 786688, metadata !21, metadata !"b", metadata !22, i32 7, metadata !45, i32 0, i32 0} ; [ DW_TAG_auto_variable ] [b] [line 7]
218!45 = metadata !{i32 786451, metadata !1, metadata !21, metadata !"baz", i32 6, i64 8, i64 8, i32 0, i32 0, null, metadata !2, i32 0, null, null, null} ; [ DW_TAG_structure_type ] [baz] [line 6, size 8, align 8, offset 0] [def] [from ]
219!46 = metadata !{i32 7, i32 0, metadata !21, null}
220!47 = metadata !{i32 8, i32 0, metadata !21, null} ; [ DW_TAG_imported_declaration ]
221!48 = metadata !{i32 29, i32 0, metadata !25, null}
222!49 = metadata !{i32 786689, metadata !26, metadata !"this", null, i32 16777216, metadata !50, i32 1088, i32 0} ; [ DW_TAG_arg_variable ] [this] [line 0]
223!50 = metadata !{i32 786447, null, null, metadata !"", i32 0, i64 64, i64 64, i64 0, i32 0, metadata !27} ; [ DW_TAG_pointer_type ] [line 0, size 64, align 64, offset 0] [from walrus]
224!51 = metadata !{i32 0, i32 0, metadata !26, null}
225!52 = metadata !{i32 25, i32 0, metadata !26, null}
226!53 = metadata !{i32 25, i32 0, metadata !35, null}
Manman Ren409558f2013-11-22 21:49:45 +0000227!54 = metadata !{i32 1, metadata !"Debug Info Version", i32 1}