xref: /aosp_15_r20/external/llvm/test/Transforms/Inline/debug-info-duplicate-calls.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker; RUN: opt < %s -always-inline -S | FileCheck %s
2*9880d681SAndroid Build Coastguard Worker
3*9880d681SAndroid Build Coastguard Worker; Original input generated from clang -emit-llvm -S -c -mllvm -disable-llvm-optzns
4*9880d681SAndroid Build Coastguard Worker;
5*9880d681SAndroid Build Coastguard Worker; #define CALLS1 f2(); f2();
6*9880d681SAndroid Build Coastguard Worker; #define CALLS2 f4(); f4();
7*9880d681SAndroid Build Coastguard Worker; void f1();
8*9880d681SAndroid Build Coastguard Worker; inline __attribute__((always_inline)) void f2() {
9*9880d681SAndroid Build Coastguard Worker;   f1();
10*9880d681SAndroid Build Coastguard Worker; }
11*9880d681SAndroid Build Coastguard Worker; inline __attribute__((always_inline)) void f3() {
12*9880d681SAndroid Build Coastguard Worker;   CALLS1
13*9880d681SAndroid Build Coastguard Worker; }
14*9880d681SAndroid Build Coastguard Worker; inline __attribute__((always_inline)) void f4() {
15*9880d681SAndroid Build Coastguard Worker;   f3();
16*9880d681SAndroid Build Coastguard Worker; }
17*9880d681SAndroid Build Coastguard Worker; void f() {
18*9880d681SAndroid Build Coastguard Worker;   CALLS2
19*9880d681SAndroid Build Coastguard Worker; }
20*9880d681SAndroid Build Coastguard Worker
21*9880d681SAndroid Build Coastguard Worker; There should be unique locations for all 4 of these instructions, correctly
22*9880d681SAndroid Build Coastguard Worker; describing the inlining that has occurred, even in the face of duplicate call
23*9880d681SAndroid Build Coastguard Worker; site locations.
24*9880d681SAndroid Build Coastguard Worker
25*9880d681SAndroid Build Coastguard Worker; The nomenclature used for the tags here is <function name>[cs<number>] where
26*9880d681SAndroid Build Coastguard Worker; 'cs' is an abbreviation for 'call site' and the number indicates which call
27*9880d681SAndroid Build Coastguard Worker; site from within the named function this is. (so, given the above inlining, we
28*9880d681SAndroid Build Coastguard Worker; should have 4 calls to 'f1', two from the first call to f4 and two from the
29*9880d681SAndroid Build Coastguard Worker; second call to f4)
30*9880d681SAndroid Build Coastguard Worker
31*9880d681SAndroid Build Coastguard Worker; CHECK: call void @_Z2f1v(), !dbg [[fcs1_f4_f3cs1_f2:![0-9]+]]
32*9880d681SAndroid Build Coastguard Worker; CHECK: call void @_Z2f1v(), !dbg [[fcs1_f4_f3cs2_f2:![0-9]+]]
33*9880d681SAndroid Build Coastguard Worker; CHECK: call void @_Z2f1v(), !dbg [[fcs2_f4_f3cs1_f2:![0-9]+]]
34*9880d681SAndroid Build Coastguard Worker; CHECK: call void @_Z2f1v(), !dbg [[fcs2_f4_f3cs2_f2:![0-9]+]]
35*9880d681SAndroid Build Coastguard Worker
36*9880d681SAndroid Build Coastguard Worker; CHECK-DAG: [[F:![0-9]+]]  = distinct !DISubprogram(name: "f"
37*9880d681SAndroid Build Coastguard Worker; CHECK-DAG: [[F2:![0-9]+]] = distinct !DISubprogram(name: "f2"
38*9880d681SAndroid Build Coastguard Worker; CHECK-DAG: [[F3:![0-9]+]] = distinct !DISubprogram(name: "f3"
39*9880d681SAndroid Build Coastguard Worker; CHECK-DAG: [[F4:![0-9]+]] = distinct !DISubprogram(name: "f4"
40*9880d681SAndroid Build Coastguard Worker
41*9880d681SAndroid Build Coastguard Worker; CHECK-DAG: [[fcs1_f4_f3cs1_f2]] = {{.*}}, scope: [[F2]], inlinedAt: [[fcs1_f4_f3cs1:![0-9]+]])
42*9880d681SAndroid Build Coastguard Worker; CHECK-DAG: [[fcs1_f4_f3cs1]] = {{.*}}, scope: [[F3]], inlinedAt: [[fcs1_f4:![0-9]+]])
43*9880d681SAndroid Build Coastguard Worker; CHECK-DAG: [[fcs1_f4]] = {{.*}}, scope: [[F4]], inlinedAt: [[fcs1:![0-9]+]])
44*9880d681SAndroid Build Coastguard Worker; CHECK-DAG: [[fcs1]] = {{.*}}, scope: [[F]])
45*9880d681SAndroid Build Coastguard Worker; CHECK-DAG: [[fcs1_f4_f3cs2_f2]] = {{.*}}, scope: [[F2]], inlinedAt: [[fcs1_f4_f3cs2:![0-9]+]])
46*9880d681SAndroid Build Coastguard Worker; CHECK-DAG: [[fcs1_f4_f3cs2]] = {{.*}}, scope: [[F3]], inlinedAt: [[fcs1_f4]])
47*9880d681SAndroid Build Coastguard Worker
48*9880d681SAndroid Build Coastguard Worker; CHECK-DAG: [[fcs2_f4_f3cs1_f2]] = {{.*}}, scope: [[F2]], inlinedAt: [[fcs2_f4_f3cs1:![0-9]+]])
49*9880d681SAndroid Build Coastguard Worker; CHECK-DAG: [[fcs2_f4_f3cs1]] = {{.*}}, scope: [[F3]], inlinedAt: [[fcs2_f4:![0-9]+]])
50*9880d681SAndroid Build Coastguard Worker; CHECK-DAG: [[fcs2_f4]] = {{.*}}, scope: [[F4]], inlinedAt: [[fcs2:![0-9]+]])
51*9880d681SAndroid Build Coastguard Worker; CHECK-DAG: [[fcs2]] = {{.*}}, scope: [[F]])
52*9880d681SAndroid Build Coastguard Worker; CHECK-DAG: [[fcs2_f4_f3cs2_f2]] = {{.*}}, scope: [[F2]], inlinedAt: [[fcs2_f4_f3cs2:![0-9]+]])
53*9880d681SAndroid Build Coastguard Worker; CHECK-DAG: [[fcs2_f4_f3cs2]] = {{.*}}, scope: [[F3]], inlinedAt: [[fcs2_f4]])
54*9880d681SAndroid Build Coastguard Worker
55*9880d681SAndroid Build Coastguard Worker$_Z2f4v = comdat any
56*9880d681SAndroid Build Coastguard Worker
57*9880d681SAndroid Build Coastguard Worker$_Z2f3v = comdat any
58*9880d681SAndroid Build Coastguard Worker
59*9880d681SAndroid Build Coastguard Worker$_Z2f2v = comdat any
60*9880d681SAndroid Build Coastguard Worker
61*9880d681SAndroid Build Coastguard Worker; Function Attrs: uwtable
62*9880d681SAndroid Build Coastguard Workerdefine void @_Z1fv() #0 !dbg !4 {
63*9880d681SAndroid Build Coastguard Workerentry:
64*9880d681SAndroid Build Coastguard Worker  call void @_Z2f4v(), !dbg !13
65*9880d681SAndroid Build Coastguard Worker  call void @_Z2f4v(), !dbg !13
66*9880d681SAndroid Build Coastguard Worker  ret void, !dbg !14
67*9880d681SAndroid Build Coastguard Worker}
68*9880d681SAndroid Build Coastguard Worker
69*9880d681SAndroid Build Coastguard Worker; Function Attrs: alwaysinline inlinehint uwtable
70*9880d681SAndroid Build Coastguard Workerdefine linkonce_odr void @_Z2f4v() #1 comdat !dbg !7 {
71*9880d681SAndroid Build Coastguard Workerentry:
72*9880d681SAndroid Build Coastguard Worker  call void @_Z2f3v(), !dbg !15
73*9880d681SAndroid Build Coastguard Worker  ret void, !dbg !16
74*9880d681SAndroid Build Coastguard Worker}
75*9880d681SAndroid Build Coastguard Worker
76*9880d681SAndroid Build Coastguard Worker; Function Attrs: alwaysinline inlinehint uwtable
77*9880d681SAndroid Build Coastguard Workerdefine linkonce_odr void @_Z2f3v() #1 comdat !dbg !8 {
78*9880d681SAndroid Build Coastguard Workerentry:
79*9880d681SAndroid Build Coastguard Worker  call void @_Z2f2v(), !dbg !17
80*9880d681SAndroid Build Coastguard Worker  call void @_Z2f2v(), !dbg !17
81*9880d681SAndroid Build Coastguard Worker  ret void, !dbg !18
82*9880d681SAndroid Build Coastguard Worker}
83*9880d681SAndroid Build Coastguard Worker
84*9880d681SAndroid Build Coastguard Worker; Function Attrs: alwaysinline inlinehint uwtable
85*9880d681SAndroid Build Coastguard Workerdefine linkonce_odr void @_Z2f2v() #1 comdat !dbg !9 {
86*9880d681SAndroid Build Coastguard Workerentry:
87*9880d681SAndroid Build Coastguard Worker  call void @_Z2f1v(), !dbg !19
88*9880d681SAndroid Build Coastguard Worker  ret void, !dbg !20
89*9880d681SAndroid Build Coastguard Worker}
90*9880d681SAndroid Build Coastguard Worker
91*9880d681SAndroid Build Coastguard Workerdeclare void @_Z2f1v() #2
92*9880d681SAndroid Build Coastguard Worker
93*9880d681SAndroid Build Coastguard Workerattributes #0 = { 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" }
94*9880d681SAndroid Build Coastguard Workerattributes #1 = { alwaysinline inlinehint 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" }
95*9880d681SAndroid Build Coastguard Workerattributes #2 = { "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" }
96*9880d681SAndroid Build Coastguard Worker
97*9880d681SAndroid Build Coastguard Worker!llvm.dbg.cu = !{!0}
98*9880d681SAndroid Build Coastguard Worker!llvm.module.flags = !{!10, !11}
99*9880d681SAndroid Build Coastguard Worker!llvm.ident = !{!12}
100*9880d681SAndroid Build Coastguard Worker
101*9880d681SAndroid Build Coastguard Worker!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, producer: "clang version 3.7.0 (trunk 226474) (llvm/trunk 226478)", isOptimized: false, emissionKind: LineTablesOnly, file: !1, enums: !2, retainedTypes: !2, globals: !2, imports: !2)
102*9880d681SAndroid Build Coastguard Worker!1 = !DIFile(filename: "debug-info-duplicate-calls.cpp", directory: "/tmp/dbginfo")
103*9880d681SAndroid Build Coastguard Worker!2 = !{}
104*9880d681SAndroid Build Coastguard Worker!4 = distinct !DISubprogram(name: "f", line: 13, isLocal: false, isDefinition: true, flags: DIFlagPrototyped, isOptimized: false, unit: !0, scopeLine: 13, file: !1, scope: !5, type: !6, variables: !2)
105*9880d681SAndroid Build Coastguard Worker!5 = !DIFile(filename: "debug-info-duplicate-calls.cpp", directory: "/tmp/dbginfo")
106*9880d681SAndroid Build Coastguard Worker!6 = !DISubroutineType(types: !2)
107*9880d681SAndroid Build Coastguard Worker!7 = distinct !DISubprogram(name: "f4", line: 10, isLocal: false, isDefinition: true, flags: DIFlagPrototyped, isOptimized: false, unit: !0, scopeLine: 10, file: !1, scope: !5, type: !6, variables: !2)
108*9880d681SAndroid Build Coastguard Worker!8 = distinct !DISubprogram(name: "f3", line: 7, isLocal: false, isDefinition: true, flags: DIFlagPrototyped, isOptimized: false, unit: !0, scopeLine: 7, file: !1, scope: !5, type: !6, variables: !2)
109*9880d681SAndroid Build Coastguard Worker!9 = distinct !DISubprogram(name: "f2", line: 4, isLocal: false, isDefinition: true, flags: DIFlagPrototyped, isOptimized: false, unit: !0, scopeLine: 4, file: !1, scope: !5, type: !6, variables: !2)
110*9880d681SAndroid Build Coastguard Worker!10 = !{i32 2, !"Dwarf Version", i32 4}
111*9880d681SAndroid Build Coastguard Worker!11 = !{i32 2, !"Debug Info Version", i32 3}
112*9880d681SAndroid Build Coastguard Worker!12 = !{!"clang version 3.7.0 (trunk 226474) (llvm/trunk 226478)"}
113*9880d681SAndroid Build Coastguard Worker!13 = !DILocation(line: 14, column: 3, scope: !4)
114*9880d681SAndroid Build Coastguard Worker!14 = !DILocation(line: 15, column: 1, scope: !4)
115*9880d681SAndroid Build Coastguard Worker!15 = !DILocation(line: 11, column: 3, scope: !7)
116*9880d681SAndroid Build Coastguard Worker!16 = !DILocation(line: 12, column: 1, scope: !7)
117*9880d681SAndroid Build Coastguard Worker!17 = !DILocation(line: 8, column: 3, scope: !8)
118*9880d681SAndroid Build Coastguard Worker!18 = !DILocation(line: 9, column: 1, scope: !8)
119*9880d681SAndroid Build Coastguard Worker!19 = !DILocation(line: 5, column: 3, scope: !9)
120*9880d681SAndroid Build Coastguard Worker!20 = !DILocation(line: 6, column: 1, scope: !9)
121