blob: ffd3fbda080897f3406003bdee428fea504ba750 [file] [log] [blame]
David Blaikiec9ad9192015-10-07 00:04:16 +00001; REQUIRES: object-emission
2
Adrian Prantl7bc1b282017-09-11 22:59:45 +00003; RUN: %llc_dwarf < %s -filetype=obj | llvm-dwarfdump -debug-info - | FileCheck %s
David Blaikiec9ad9192015-10-07 00:04:16 +00004
5; Given the following source, ensure that the decl_line/file is correctly
6; emitted and omitted on definitions if it mismatches/matches the declaration
7
8; struct foo {
9; static void f1() {
10; }
11; static void f2();
12; static void f3();
13; };
14; void foo::f2() {
15; f1(); // just to ensure f1 is emitted
16; }
17; #line 1 "bar.cpp"
18; void foo::f3() {
19; }
20
21; Skip the declarations
22; CHECK: DW_TAG_subprogram
23; CHECK: DW_TAG_subprogram
24; CHECK: DW_TAG_subprogram
25
26; CHECK: DW_TAG_subprogram
27; CHECK-NOT: {{DW_TAG|NULL|DW_AT_decl_file}}
28; CHECK: DW_AT_decl_line {{.*}}7
29; CHECK-NOT: {{DW_TAG|NULL|DW_AT_decl_file}}
30; CHECK: DW_AT_specification {{.*}}f2
31; CHECK-NOT: {{DW_TAG|NULL|DW_AT_decl_file}}
32
33; CHECK: DW_TAG_subprogram
34; CHECK-NOT: {{DW_TAG|NULL|DW_AT_decl_line|DW_AT_decl_file}}
35; CHECK: DW_AT_specification {{.*}}f1
36
37; CHECK: DW_TAG_subprogram
38; CHECK-NOT: {{DW_TAG|NULL}}
39; CHECK: DW_AT_decl_file {{.*}}bar.cpp
40; CHECK-NOT: {{DW_TAG|NULL}}
41; CHECK: DW_AT_decl_line {{.*}}1
42; CHECK-NOT: {{DW_TAG|NULL}}
43; CHECK: DW_AT_specification {{.*}}f3
44
David Blaikiec9ad9192015-10-07 00:04:16 +000045; Function Attrs: uwtable
Peter Collingbourned4bff302015-11-05 22:03:56 +000046define void @_ZN3foo2f2Ev() #0 align 2 !dbg !12 {
David Blaikiec9ad9192015-10-07 00:04:16 +000047entry:
48 call void @_ZN3foo2f1Ev(), !dbg !19
49 ret void, !dbg !20
50}
51
52; Function Attrs: nounwind uwtable
Peter Collingbourned4bff302015-11-05 22:03:56 +000053define linkonce_odr void @_ZN3foo2f1Ev() #1 align 2 !dbg !15 {
David Blaikiec9ad9192015-10-07 00:04:16 +000054entry:
55 ret void, !dbg !21
56}
57
58; Function Attrs: nounwind uwtable
Peter Collingbourned4bff302015-11-05 22:03:56 +000059define void @_ZN3foo2f3Ev() #1 align 2 !dbg !13 {
David Blaikiec9ad9192015-10-07 00:04:16 +000060entry:
61 ret void, !dbg !22
62}
63
Artyom Skrobov444d5442015-11-19 12:24:47 +000064attributes #0 = { uwtable "disable-tail-calls"="false" "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" }
65attributes #1 = { nounwind uwtable "disable-tail-calls"="false" "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" }
David Blaikiec9ad9192015-10-07 00:04:16 +000066
67!llvm.dbg.cu = !{!0}
68!llvm.module.flags = !{!16, !17}
69!llvm.ident = !{!18}
70
Adrian Prantl75819ae2016-04-15 15:57:41 +000071!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 3.8.0 (trunk 249440) (llvm/trunk 249465)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, retainedTypes: !3)
David Blaikiec9ad9192015-10-07 00:04:16 +000072!1 = !DIFile(filename: "def-line.cpp", directory: "/tmp/dbginfo")
73!2 = !{}
74!3 = !{!4}
75!4 = !DICompositeType(tag: DW_TAG_structure_type, name: "foo", file: !1, line: 1, size: 8, align: 8, elements: !5, identifier: "_ZTS3foo")
76!5 = !{!6, !9, !10}
Duncan P. N. Exon Smitha59d3e52016-04-23 21:08:00 +000077!6 = !DISubprogram(name: "f1", linkageName: "_ZN3foo2f1Ev", scope: !4, file: !1, line: 2, type: !7, isLocal: false, isDefinition: false, scopeLine: 2, flags: DIFlagPrototyped, isOptimized: false)
David Blaikiec9ad9192015-10-07 00:04:16 +000078!7 = !DISubroutineType(types: !8)
79!8 = !{null}
Duncan P. N. Exon Smitha59d3e52016-04-23 21:08:00 +000080!9 = !DISubprogram(name: "f2", linkageName: "_ZN3foo2f2Ev", scope: !4, file: !1, line: 4, type: !7, isLocal: false, isDefinition: false, scopeLine: 4, flags: DIFlagPrototyped, isOptimized: false)
81!10 = !DISubprogram(name: "f3", linkageName: "_ZN3foo2f3Ev", scope: !4, file: !1, line: 5, type: !7, isLocal: false, isDefinition: false, scopeLine: 5, flags: DIFlagPrototyped, isOptimized: false)
Shiva Chen2c864552018-05-09 02:40:45 +000082!12 = distinct !DISubprogram(name: "f2", linkageName: "_ZN3foo2f2Ev", scope: !4, file: !1, line: 7, type: !7, isLocal: false, isDefinition: true, scopeLine: 7, flags: DIFlagPrototyped, isOptimized: false, unit: !0, declaration: !9, retainedNodes: !2)
83!13 = distinct !DISubprogram(name: "f3", linkageName: "_ZN3foo2f3Ev", scope: !4, file: !14, line: 1, type: !7, isLocal: false, isDefinition: true, scopeLine: 1, flags: DIFlagPrototyped, isOptimized: false, unit: !0, declaration: !10, retainedNodes: !2)
David Blaikiec9ad9192015-10-07 00:04:16 +000084!14 = !DIFile(filename: "bar.cpp", directory: "/tmp/dbginfo")
Shiva Chen2c864552018-05-09 02:40:45 +000085!15 = distinct !DISubprogram(name: "f1", linkageName: "_ZN3foo2f1Ev", scope: !4, file: !1, line: 2, type: !7, isLocal: false, isDefinition: true, scopeLine: 2, flags: DIFlagPrototyped, isOptimized: false, unit: !0, declaration: !6, retainedNodes: !2)
David Blaikiec9ad9192015-10-07 00:04:16 +000086!16 = !{i32 2, !"Dwarf Version", i32 4}
87!17 = !{i32 2, !"Debug Info Version", i32 3}
88!18 = !{!"clang version 3.8.0 (trunk 249440) (llvm/trunk 249465)"}
89!19 = !DILocation(line: 8, column: 3, scope: !12)
90!20 = !DILocation(line: 9, column: 1, scope: !12)
91!21 = !DILocation(line: 3, column: 3, scope: !15)
92!22 = !DILocation(line: 2, column: 1, scope: !13)