xref: /aosp_15_r20/external/llvm/test/DebugInfo/Generic/def-line.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker; REQUIRES: object-emission
2*9880d681SAndroid Build Coastguard Worker
3*9880d681SAndroid Build Coastguard Worker; RUN: %llc_dwarf < %s -filetype=obj | llvm-dwarfdump -debug-dump=info - | FileCheck %s
4*9880d681SAndroid Build Coastguard Worker
5*9880d681SAndroid Build Coastguard Worker; Given the following source, ensure that the decl_line/file is correctly
6*9880d681SAndroid Build Coastguard Worker; emitted and omitted on definitions if it mismatches/matches the declaration
7*9880d681SAndroid Build Coastguard Worker
8*9880d681SAndroid Build Coastguard Worker; struct foo {
9*9880d681SAndroid Build Coastguard Worker;   static void f1() {
10*9880d681SAndroid Build Coastguard Worker;   }
11*9880d681SAndroid Build Coastguard Worker;   static void f2();
12*9880d681SAndroid Build Coastguard Worker;   static void f3();
13*9880d681SAndroid Build Coastguard Worker; };
14*9880d681SAndroid Build Coastguard Worker; void foo::f2() {
15*9880d681SAndroid Build Coastguard Worker;   f1(); // just to ensure f1 is emitted
16*9880d681SAndroid Build Coastguard Worker; }
17*9880d681SAndroid Build Coastguard Worker; #line 1 "bar.cpp"
18*9880d681SAndroid Build Coastguard Worker; void foo::f3() {
19*9880d681SAndroid Build Coastguard Worker; }
20*9880d681SAndroid Build Coastguard Worker
21*9880d681SAndroid Build Coastguard Worker; Skip the declarations
22*9880d681SAndroid Build Coastguard Worker; CHECK: DW_TAG_subprogram
23*9880d681SAndroid Build Coastguard Worker; CHECK: DW_TAG_subprogram
24*9880d681SAndroid Build Coastguard Worker; CHECK: DW_TAG_subprogram
25*9880d681SAndroid Build Coastguard Worker
26*9880d681SAndroid Build Coastguard Worker; CHECK: DW_TAG_subprogram
27*9880d681SAndroid Build Coastguard Worker; CHECK-NOT: {{DW_TAG|NULL|DW_AT_decl_file}}
28*9880d681SAndroid Build Coastguard Worker; CHECK:   DW_AT_decl_line {{.*}}7
29*9880d681SAndroid Build Coastguard Worker; CHECK-NOT: {{DW_TAG|NULL|DW_AT_decl_file}}
30*9880d681SAndroid Build Coastguard Worker; CHECK:   DW_AT_specification {{.*}}f2
31*9880d681SAndroid Build Coastguard Worker; CHECK-NOT: {{DW_TAG|NULL|DW_AT_decl_file}}
32*9880d681SAndroid Build Coastguard Worker
33*9880d681SAndroid Build Coastguard Worker; CHECK: DW_TAG_subprogram
34*9880d681SAndroid Build Coastguard Worker; CHECK-NOT: {{DW_TAG|NULL|DW_AT_decl_line|DW_AT_decl_file}}
35*9880d681SAndroid Build Coastguard Worker; CHECK:   DW_AT_specification {{.*}}f1
36*9880d681SAndroid Build Coastguard Worker
37*9880d681SAndroid Build Coastguard Worker; CHECK: DW_TAG_subprogram
38*9880d681SAndroid Build Coastguard Worker; CHECK-NOT: {{DW_TAG|NULL}}
39*9880d681SAndroid Build Coastguard Worker; CHECK:   DW_AT_decl_file {{.*}}bar.cpp
40*9880d681SAndroid Build Coastguard Worker; CHECK-NOT: {{DW_TAG|NULL}}
41*9880d681SAndroid Build Coastguard Worker; CHECK:   DW_AT_decl_line {{.*}}1
42*9880d681SAndroid Build Coastguard Worker; CHECK-NOT: {{DW_TAG|NULL}}
43*9880d681SAndroid Build Coastguard Worker; CHECK:   DW_AT_specification {{.*}}f3
44*9880d681SAndroid Build Coastguard Worker
45*9880d681SAndroid Build Coastguard Worker; Function Attrs: uwtable
46*9880d681SAndroid Build Coastguard Workerdefine void @_ZN3foo2f2Ev() #0 align 2 !dbg !12 {
47*9880d681SAndroid Build Coastguard Workerentry:
48*9880d681SAndroid Build Coastguard Worker  call void @_ZN3foo2f1Ev(), !dbg !19
49*9880d681SAndroid Build Coastguard Worker  ret void, !dbg !20
50*9880d681SAndroid Build Coastguard Worker}
51*9880d681SAndroid Build Coastguard Worker
52*9880d681SAndroid Build Coastguard Worker; Function Attrs: nounwind uwtable
53*9880d681SAndroid Build Coastguard Workerdefine linkonce_odr void @_ZN3foo2f1Ev() #1 align 2 !dbg !15 {
54*9880d681SAndroid Build Coastguard Workerentry:
55*9880d681SAndroid Build Coastguard Worker  ret void, !dbg !21
56*9880d681SAndroid Build Coastguard Worker}
57*9880d681SAndroid Build Coastguard Worker
58*9880d681SAndroid Build Coastguard Worker; Function Attrs: nounwind uwtable
59*9880d681SAndroid Build Coastguard Workerdefine void @_ZN3foo2f3Ev() #1 align 2 !dbg !13 {
60*9880d681SAndroid Build Coastguard Workerentry:
61*9880d681SAndroid Build Coastguard Worker  ret void, !dbg !22
62*9880d681SAndroid Build Coastguard Worker}
63*9880d681SAndroid Build Coastguard Worker
64*9880d681SAndroid Build Coastguard Workerattributes #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" }
65*9880d681SAndroid Build Coastguard Workerattributes #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" }
66*9880d681SAndroid Build Coastguard Worker
67*9880d681SAndroid Build Coastguard Worker!llvm.dbg.cu = !{!0}
68*9880d681SAndroid Build Coastguard Worker!llvm.module.flags = !{!16, !17}
69*9880d681SAndroid Build Coastguard Worker!llvm.ident = !{!18}
70*9880d681SAndroid Build Coastguard Worker
71*9880d681SAndroid Build Coastguard Worker!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)
72*9880d681SAndroid Build Coastguard Worker!1 = !DIFile(filename: "def-line.cpp", directory: "/tmp/dbginfo")
73*9880d681SAndroid Build Coastguard Worker!2 = !{}
74*9880d681SAndroid Build Coastguard Worker!3 = !{!4}
75*9880d681SAndroid Build Coastguard Worker!4 = !DICompositeType(tag: DW_TAG_structure_type, name: "foo", file: !1, line: 1, size: 8, align: 8, elements: !5, identifier: "_ZTS3foo")
76*9880d681SAndroid Build Coastguard Worker!5 = !{!6, !9, !10}
77*9880d681SAndroid Build Coastguard Worker!6 = !DISubprogram(name: "f1", linkageName: "_ZN3foo2f1Ev", scope: !4, file: !1, line: 2, type: !7, isLocal: false, isDefinition: false, scopeLine: 2, flags: DIFlagPrototyped, isOptimized: false)
78*9880d681SAndroid Build Coastguard Worker!7 = !DISubroutineType(types: !8)
79*9880d681SAndroid Build Coastguard Worker!8 = !{null}
80*9880d681SAndroid Build Coastguard Worker!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*9880d681SAndroid Build Coastguard Worker!10 = !DISubprogram(name: "f3", linkageName: "_ZN3foo2f3Ev", scope: !4, file: !1, line: 5, type: !7, isLocal: false, isDefinition: false, scopeLine: 5, flags: DIFlagPrototyped, isOptimized: false)
82*9880d681SAndroid Build Coastguard Worker!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, variables: !2)
83*9880d681SAndroid Build Coastguard Worker!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, variables: !2)
84*9880d681SAndroid Build Coastguard Worker!14 = !DIFile(filename: "bar.cpp", directory: "/tmp/dbginfo")
85*9880d681SAndroid Build Coastguard Worker!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, variables: !2)
86*9880d681SAndroid Build Coastguard Worker!16 = !{i32 2, !"Dwarf Version", i32 4}
87*9880d681SAndroid Build Coastguard Worker!17 = !{i32 2, !"Debug Info Version", i32 3}
88*9880d681SAndroid Build Coastguard Worker!18 = !{!"clang version 3.8.0 (trunk 249440) (llvm/trunk 249465)"}
89*9880d681SAndroid Build Coastguard Worker!19 = !DILocation(line: 8, column: 3, scope: !12)
90*9880d681SAndroid Build Coastguard Worker!20 = !DILocation(line: 9, column: 1, scope: !12)
91*9880d681SAndroid Build Coastguard Worker!21 = !DILocation(line: 3, column: 3, scope: !15)
92*9880d681SAndroid Build Coastguard Worker!22 = !DILocation(line: 2, column: 1, scope: !13)
93