Debian Codegraph @

llvm/test/Transforms/SampleProfile/pseudo-probe-stale-profile-matching-LCS.ll

raw
1 ; REQUIRES: asserts && x86-registered-target
2 ; RUN: opt < %s -passes=sample-profile -sample-profile-file=%S/Inputs/pseudo-probe-stale-profile-matching-LCS.prof --salvage-stale-profile -S --debug-only=sample-profile,sample-profile-matcher,sample-profile-impl 2>&1 | FileCheck %s
3 ; RUN: opt < %s -passes=sample-profile -sample-profile-file=%S/Inputs/pseudo-probe-stale-profile-matching-LCS.prof --salvage-stale-profile -S --debug-only=sample-profile,sample-profile-matcher,sample-profile-impl --salvage-stale-profile-max-callsites=6 2>&1 | FileCheck %s -check-prefix=CHECK-MAX-CALLSITES
4
5 ; CHECK: Run stale profile matching for test_indirect_call
6 ; CHECK: Location is matched from 1 to 1
7 ; CHECK: Location is matched from 2 to 2
8 ; CHECK: Location is matched from 3 to 3
9 ; CHECK: Location is matched from 4 to 4
10 ; CHECK: Callsite with callee:C is matched from 5 to 2
11 ; CHECK: Location is rematched backwards from 3 to 0
12 ; CHECK: Location is rematched backwards from 4 to 1
13 ; CHECK: Callsite with callee:unknown.indirect.callee is matched from 6 to 3
14 ; CHECK:Callsite with callee:B is matched from 7 to 4
15 ; CHECK: Location is matched from 8 to 5
16 ; CHECK: Callsite with callee:unknown.indirect.callee is matched from 9 to 6
17 ; CHECK: Callsite with callee:C is matched from 10 to 7
18
19 ; CHECK: Run stale profile matching for test_direct_call
20 ; CHECK: Location is matched from 1 to 1
21 ; CHECK: Location is matched from 2 to 2
22 ; CHECK: Location is matched from 3 to 3
23 ; CHECK: Callsite with callee:C is matched from 4 to 2
24 ; CHECK: Location is rematched backwards from 3 to 1
25 ; CHECK: Callsite with callee:A is matched from 5 to 4
26 ; CHECK: Callsite with callee:B is matched from 6 to 5
27 ; CHECK: Location is matched from 7 to 6
28 ; CHECK: Callsite with callee:A is matched from 8 to 6
29
30 ; CHECK-MAX-CALLSITES: Skip stale profile matching for test_direct_call
31 ; CHECK-MAX-CALLSITES-NOT: Skip stale profile matching for test_indirect_call
32
33 @c = external global i32, align 4
34
35 ; Function Attrs: nounwind uwtable
36 define dso_local i32 @test_direct_call(i32 noundef %x) #0 !dbg !12 {
37 entry:
38 #dbg_value(i32 %x, !17, !DIExpression(), !18)
39 call void @llvm.pseudoprobe(i64 -4364451034228175269, i64 1, i32 0, i64 -1), !dbg !19
40 %call = call i32 @A(i32 noundef %x), !dbg !20
41 %add = add nsw i32 %x, %call, !dbg !22
42 #dbg_value(i32 %add, !17, !DIExpression(), !18)
43 %call1 = call i32 @B(i32 noundef %add), !dbg !23
44 %add2 = add nsw i32 %add, %call1, !dbg !25
45 #dbg_value(i32 %add2, !17, !DIExpression(), !18)
46 %call3 = call i32 @C(i32 noundef %add2), !dbg !26
47 %add4 = add nsw i32 %add2, %call3, !dbg !28
48 #dbg_value(i32 %add4, !17, !DIExpression(), !18)
49 %call5 = call i32 @A(i32 noundef %add4), !dbg !29
50 %add6 = add nsw i32 %add4, %call5, !dbg !31
51 #dbg_value(i32 %add6, !17, !DIExpression(), !18)
52 %call7 = call i32 @B(i32 noundef %add6), !dbg !32
53 %add8 = add nsw i32 %add6, %call7, !dbg !34
54 #dbg_value(i32 %add8, !17, !DIExpression(), !18)
55 %call9 = call i32 @B(i32 noundef %add8), !dbg !35
56 %add10 = add nsw i32 %add8, %call9, !dbg !37
57 #dbg_value(i32 %add10, !17, !DIExpression(), !18)
58 %call11 = call i32 @A(i32 noundef %add10), !dbg !38
59 %add12 = add nsw i32 %add10, %call11, !dbg !40
60 #dbg_value(i32 %add12, !17, !DIExpression(), !18)
61 ret i32 %add12, !dbg !41
62 }
63
64 ; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
65 declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
66
67 declare !dbg !42 i32 @A(i32 noundef) #2
68
69 declare !dbg !43 i32 @B(i32 noundef) #2
70
71 declare !dbg !44 i32 @C(i32 noundef) #2
72
73 ; Function Attrs: nounwind uwtable
74 define dso_local i32 @test_indirect_call(i32 noundef %x) #0 !dbg !45 {
75 entry:
76 #dbg_value(i32 %x, !47, !DIExpression(), !50)
77 call void @llvm.pseudoprobe(i64 -8563147518712133441, i64 1, i32 0, i64 -1), !dbg !51
78 %0 = load i32, ptr @c, align 4, !dbg !51, !tbaa !53
79 %tobool = icmp ne i32 %0, 0, !dbg !51
80 br i1 %tobool, label %if.then, label %if.else, !dbg !57
81
82 if.then: ; preds = %entry
83 call void @llvm.pseudoprobe(i64 -8563147518712133441, i64 2, i32 0, i64 -1), !dbg !58
84 #dbg_value(ptr @A, !48, !DIExpression(), !50)
85 br label %if.end, !dbg !59
86
87 if.else: ; preds = %entry
88 call void @llvm.pseudoprobe(i64 -8563147518712133441, i64 3, i32 0, i64 -1), !dbg !60
89 #dbg_value(ptr @B, !48, !DIExpression(), !50)
90 br label %if.end
91
92 if.end: ; preds = %if.else, %if.then
93 %fp.0 = phi ptr [ @A, %if.then ], [ @B, %if.else ], !dbg !61
94 #dbg_value(ptr %fp.0, !48, !DIExpression(), !50)
95 call void @llvm.pseudoprobe(i64 -8563147518712133441, i64 4, i32 0, i64 -1), !dbg !62
96 %call = call i32 @C(i32 noundef %x), !dbg !63
97 %add = add nsw i32 %x, %call, !dbg !65
98 #dbg_value(i32 %add, !47, !DIExpression(), !50)
99 %call1 = call i32 %fp.0(i32 noundef %add), !dbg !66
100 %add2 = add nsw i32 %add, %call1, !dbg !68
101 #dbg_value(i32 %add2, !47, !DIExpression(), !50)
102 %call3 = call i32 @B(i32 noundef %add2), !dbg !69
103 %add4 = add nsw i32 %add2, %call3, !dbg !71
104 #dbg_value(i32 %add4, !47, !DIExpression(), !50)
105 %call5 = call i32 @C(i32 noundef %add4), !dbg !72
106 %add6 = add nsw i32 %add4, %call5, !dbg !74
107 #dbg_value(i32 %add6, !47, !DIExpression(), !50)
108 %call7 = call i32 %fp.0(i32 noundef %add6), !dbg !75
109 %add8 = add nsw i32 %add6, %call7, !dbg !77
110 #dbg_value(i32 %add8, !47, !DIExpression(), !50)
111 %call9 = call i32 @C(i32 noundef %add8), !dbg !78
112 %add10 = add nsw i32 %add8, %call9, !dbg !80
113 #dbg_value(i32 %add10, !47, !DIExpression(), !50)
114 ret i32 %add10, !dbg !81
115 }
116
117 ; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
118 declare void @llvm.lifetime.start.p0(ptr nocapture) #3
119
120 ; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
121 declare void @llvm.lifetime.end.p0(ptr nocapture) #3
122
123 ; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: readwrite)
124 declare void @llvm.pseudoprobe(i64, i64, i32, i64) #4
125
126 attributes #0 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" "use-sample-profile" }
127 attributes #1 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn }
128 attributes #2 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
129 attributes #3 = { mustprogress nocallback nofree nosync nounwind willreturn }
130 attributes #4 = { mustprogress nocallback nofree nosync nounwind willreturn }
131
132 !llvm.dbg.cu = !{!0}
133 !llvm.module.flags = !{!2, !3, !4, !5, !6, !7, !8}
134 !llvm.ident = !{!9}
135 !llvm.pseudo_probe_desc = !{!10, !11}
136
137 !0 = distinct !DICompileUnit(language: DW_LANG_C11, file: !1, producer: "clang version 19.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false, debugInfoForProfiling: true, nameTableKind: None)
138 !1 = !DIFile(filename: "test.c", directory: "/home/", checksumkind: CSK_MD5, checksum: "be98aa946f37f0ad8d307c9121efe101")
139 !2 = !{i32 7, !"Dwarf Version", i32 5}
140 !3 = !{i32 2, !"Debug Info Version", i32 3}
141 !4 = !{i32 1, !"wchar_size", i32 4}
142 !5 = !{i32 8, !"PIC Level", i32 2}
143 !6 = !{i32 7, !"PIE Level", i32 2}
144 !7 = !{i32 7, !"uwtable", i32 2}
145 !8 = !{i32 7, !"debug-info-assignment-tracking", i1 true}
146 !9 = !{!"clang version 19.0.0"}
147 !10 = !{i64 -4364451034228175269, i64 1970329131941887, !"test_direct_call"}
148 !11 = !{i64 -8563147518712133441, i64 1688922477484692, !"test_indirect_call"}
149 !12 = distinct !DISubprogram(name: "test_direct_call", scope: !1, file: !1, line: 10, type: !13, scopeLine: 10, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !16)
150 !13 = !DISubroutineType(types: !14)
151 !14 = !{!15, !15}
152 !15 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
153 !16 = !{!17}
154 !17 = !DILocalVariable(name: "x", arg: 1, scope: !12, file: !1, line: 10, type: !15)
155 !18 = !DILocation(line: 0, scope: !12)
156 !19 = !DILocation(line: 11, column: 10, scope: !12)
157 !20 = !DILocation(line: 11, column: 8, scope: !21)
158 !21 = !DILexicalBlockFile(scope: !12, file: !1, discriminator: 186646551)
159 !22 = !DILocation(line: 11, column: 5, scope: !12)
160 !23 = !DILocation(line: 12, column: 8, scope: !24)
161 !24 = !DILexicalBlockFile(scope: !12, file: !1, discriminator: 186646559)
162 !25 = !DILocation(line: 12, column: 5, scope: !12)
163 !26 = !DILocation(line: 13, column: 8, scope: !27)
164 !27 = !DILexicalBlockFile(scope: !12, file: !1, discriminator: 186646567)
165 !28 = !DILocation(line: 13, column: 5, scope: !12)
166 !29 = !DILocation(line: 14, column: 8, scope: !30)
167 !30 = !DILexicalBlockFile(scope: !12, file: !1, discriminator: 186646575)
168 !31 = !DILocation(line: 14, column: 5, scope: !12)
169 !32 = !DILocation(line: 15, column: 8, scope: !33)
170 !33 = !DILexicalBlockFile(scope: !12, file: !1, discriminator: 186646583)
171 !34 = !DILocation(line: 15, column: 5, scope: !12)
172 !35 = !DILocation(line: 16, column: 8, scope: !36)
173 !36 = !DILexicalBlockFile(scope: !12, file: !1, discriminator: 186646591)
174 !37 = !DILocation(line: 16, column: 5, scope: !12)
175 !38 = !DILocation(line: 17, column: 8, scope: !39)
176 !39 = !DILexicalBlockFile(scope: !12, file: !1, discriminator: 186646599)
177 !40 = !DILocation(line: 17, column: 5, scope: !12)
178 !41 = !DILocation(line: 18, column: 3, scope: !12)
179 !42 = !DISubprogram(name: "A", scope: !1, file: !1, line: 2, type: !13, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized)
180 !43 = !DISubprogram(name: "B", scope: !1, file: !1, line: 3, type: !13, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized)
181 !44 = !DISubprogram(name: "C", scope: !1, file: !1, line: 4, type: !13, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized)
182 !45 = distinct !DISubprogram(name: "test_indirect_call", scope: !1, file: !1, line: 21, type: !13, scopeLine: 21, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !46)
183 !46 = !{!47, !48}
184 !47 = !DILocalVariable(name: "x", arg: 1, scope: !45, file: !1, line: 21, type: !15)
185 !48 = !DILocalVariable(name: "fp", scope: !45, file: !1, line: 22, type: !49)
186 !49 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !13, size: 64)
187 !50 = !DILocation(line: 0, scope: !45)
188 !51 = !DILocation(line: 23, column: 6, scope: !52)
189 !52 = distinct !DILexicalBlock(scope: !45, file: !1, line: 23, column: 6)
190 !53 = !{!54, !54, i64 0}
191 !54 = !{!"int", !55, i64 0}
192 !55 = !{!"omnipotent char", !56, i64 0}
193 !56 = !{!"Simple C/C++ TBAA"}
194 !57 = !DILocation(line: 23, column: 6, scope: !45)
195 !58 = !DILocation(line: 24, column: 8, scope: !52)
196 !59 = !DILocation(line: 24, column: 5, scope: !52)
197 !60 = !DILocation(line: 26, column: 8, scope: !52)
198 !61 = !DILocation(line: 0, scope: !52)
199 !62 = !DILocation(line: 27, column: 10, scope: !45)
200 !63 = !DILocation(line: 27, column: 8, scope: !64)
201 !64 = !DILexicalBlockFile(scope: !45, file: !1, discriminator: 186646575)
202 !65 = !DILocation(line: 27, column: 5, scope: !45)
203 !66 = !DILocation(line: 28, column: 8, scope: !67)
204 !67 = !DILexicalBlockFile(scope: !45, file: !1, discriminator: 119537719)
205 !68 = !DILocation(line: 28, column: 5, scope: !45)
206 !69 = !DILocation(line: 29, column: 8, scope: !70)
207 !70 = !DILexicalBlockFile(scope: !45, file: !1, discriminator: 186646591)
208 !71 = !DILocation(line: 29, column: 5, scope: !45)
209 !72 = !DILocation(line: 30, column: 8, scope: !73)
210 !73 = !DILexicalBlockFile(scope: !45, file: !1, discriminator: 186646599)
211 !74 = !DILocation(line: 30, column: 5, scope: !45)
212 !75 = !DILocation(line: 31, column: 8, scope: !76)
213 !76 = !DILexicalBlockFile(scope: !45, file: !1, discriminator: 119537743)
214 !77 = !DILocation(line: 31, column: 5, scope: !45)
215 !78 = !DILocation(line: 32, column: 8, scope: !79)
216 !79 = !DILexicalBlockFile(scope: !45, file: !1, discriminator: 186646615)
217 !80 = !DILocation(line: 32, column: 5, scope: !45)
218 !81 = !DILocation(line: 33, column: 3, scope: !45)