Debian Codegraph @

llvm/test/Transforms/SampleProfile/pseudo-probe-stale-profile-renaming-recursive.ll

raw
1 ; REQUIRES: asserts && x86-registered-target
2 ; RUN: opt < %s -passes=sample-profile -sample-profile-file=%S/Inputs/pseudo-probe-stale-profile-renaming-recursive.prof --salvage-stale-profile --salvage-unused-profile -report-profile-staleness -persist-profile-staleness -S --debug-only=sample-profile,sample-profile-matcher,sample-profile-impl -pass-remarks=inline --min-call-count-for-cg-matching=0 --min-func-count-for-cg-matching=0 2>&1 | FileCheck %s
3
4 ; CHECK: Run stale profile matching for main
5 ; CHECK: Function:foo_new matches profile:foo
6 ; CHECK: Run stale profile matching for foo_new
7 ; CHECK: Function:bar_new matches profile:bar
8 ; CHECK: Run stale profile matching for bar_new
9
10 ; CHECK: Function processing order:
11 ; CHECK: main
12 ; CHECK: foo_new
13 ; CHECK: bar_new
14
15 ; CHECK: 'foo_new' inlined into 'main' to match profiling context with (cost=0, threshold=3000) at callsite main:2:7;
16 ; CHECK: 'bar_new' inlined into 'main' to match profiling context with (cost=-15, threshold=3000) at callsite foo_new:1:3 @ main:2:7;
17
18
19
20 @x = dso_local global i32 0, align 4, !dbg !0
21
22 ; Function Attrs: nounwind uwtable
23 define dso_local void @bar_new() #0 !dbg !18 {
24 entry:
25 call void @llvm.pseudoprobe(i64 8236371237083957767, i64 1, i32 0, i64 -1), !dbg !21
26 %0 = load volatile i32, ptr @x, align 4, !dbg !21, !tbaa !22
27 %inc = add nsw i32 %0, 1, !dbg !21
28 store volatile i32 %inc, ptr @x, align 4, !dbg !21, !tbaa !22
29 ret void, !dbg !26
30 }
31
32 ; Function Attrs: nounwind uwtable
33 define dso_local void @foo_new() #0 !dbg !27 {
34 entry:
35 call void @llvm.pseudoprobe(i64 -837213161392124280, i64 1, i32 0, i64 -1), !dbg !28
36 call void @bar_new(), !dbg !29
37 ret void, !dbg !31
38 }
39
40 ; Function Attrs: nounwind uwtable
41 define dso_local i32 @main() #0 !dbg !32 {
42 entry:
43 call void @llvm.pseudoprobe(i64 -2624081020897602054, i64 1, i32 0, i64 -1), !dbg !38
44 #dbg_value(i32 0, !36, !DIExpression(), !39)
45 br label %for.cond, !dbg !40
46
47 for.cond: ; preds = %for.body, %entry
48 %i.0 = phi i32 [ 0, %entry ], [ %inc, %for.body ], !dbg !41
49 #dbg_value(i32 %i.0, !36, !DIExpression(), !39)
50 call void @llvm.pseudoprobe(i64 -2624081020897602054, i64 2, i32 0, i64 -1), !dbg !42
51 %cmp = icmp slt i32 %i.0, 1000000, !dbg !44
52 br i1 %cmp, label %for.body, label %for.cond.cleanup, !dbg !45
53
54 for.cond.cleanup: ; preds = %for.cond
55 call void @llvm.pseudoprobe(i64 -2624081020897602054, i64 3, i32 0, i64 -1), !dbg !46
56 call void @llvm.pseudoprobe(i64 -2624081020897602054, i64 7, i32 0, i64 -1), !dbg !47
57 ret i32 0, !dbg !47
58
59 for.body: ; preds = %for.cond
60 call void @llvm.pseudoprobe(i64 -2624081020897602054, i64 4, i32 0, i64 -1), !dbg !48
61 call void @foo_new(), !dbg !50
62 call void @llvm.pseudoprobe(i64 -2624081020897602054, i64 6, i32 0, i64 -1), !dbg !52
63 %inc = add nsw i32 %i.0, 1, !dbg !52
64 #dbg_value(i32 %inc, !36, !DIExpression(), !39)
65 br label %for.cond, !dbg !53, !llvm.loop !54
66 }
67
68 ; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
69 declare void @llvm.lifetime.start.p0(ptr nocapture) #1
70
71 ; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
72 declare void @llvm.dbg.declare(metadata, metadata, metadata) #2
73
74 ; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
75 declare void @llvm.lifetime.end.p0(ptr nocapture) #1
76
77 ; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: readwrite)
78 declare void @llvm.pseudoprobe(i64, i64, i32, i64) #3
79
80 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" }
81 attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
82 attributes #2 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
83 attributes #3 = { mustprogress nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: readwrite) }
84
85 !llvm.dbg.cu = !{!2}
86 !llvm.module.flags = !{!7, !8, !9, !10, !11, !12, !13}
87 !llvm.ident = !{!14}
88 !llvm.pseudo_probe_desc = !{!15, !16, !17}
89
90 !0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
91 !1 = distinct !DIGlobalVariable(name: "x", scope: !2, file: !3, line: 1, type: !5, isLocal: false, isDefinition: true)
92 !2 = distinct !DICompileUnit(language: DW_LANG_C11, file: !3, producer: "clang", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, globals: !4, splitDebugInlining: false, nameTableKind: None)
93 !3 = !DIFile(filename: "test.c", directory: "/home/", checksumkind: CSK_MD5, checksum: "48867dcc5b42e2991317c585b7545860")
94 !4 = !{!0}
95 !5 = !DIDerivedType(tag: DW_TAG_volatile_type, baseType: !6)
96 !6 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
97 !7 = !{i32 7, !"Dwarf Version", i32 5}
98 !8 = !{i32 2, !"Debug Info Version", i32 3}
99 !9 = !{i32 1, !"wchar_size", i32 4}
100 !10 = !{i32 8, !"PIC Level", i32 2}
101 !11 = !{i32 7, !"PIE Level", i32 2}
102 !12 = !{i32 7, !"uwtable", i32 2}
103 !13 = !{i32 7, !"debug-info-assignment-tracking", i1 true}
104 !14 = !{!"clang version 19.0.0"}
105 !15 = !{i64 8236371237083957767, i64 4294967295, !"bar_new"}
106 !16 = !{i64 -837213161392124280, i64 281479271677951, !"foo_new"}
107 !17 = !{i64 -2624081020897602054, i64 281582264815352, !"main"}
108 !18 = distinct !DISubprogram(name: "bar_new", scope: !3, file: !3, line: 3, type: !19, scopeLine: 3, flags: DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !2)
109 !19 = !DISubroutineType(types: !20)
110 !20 = !{null}
111 !21 = !DILocation(line: 4, column: 4, scope: !18)
112 !22 = !{!23, !23, i64 0}
113 !23 = !{!"int", !24, i64 0}
114 !24 = !{!"omnipotent char", !25, i64 0}
115 !25 = !{!"Simple C/C++ TBAA"}
116 !26 = !DILocation(line: 5, column: 1, scope: !18)
117 !27 = distinct !DISubprogram(name: "foo_new", scope: !3, file: !3, line: 7, type: !19, scopeLine: 7, flags: DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !2)
118 !28 = !DILocation(line: 8, column: 3, scope: !27)
119 !29 = !DILocation(line: 8, column: 3, scope: !30)
120 !30 = !DILexicalBlockFile(scope: !27, file: !3, discriminator: 455082007)
121 !31 = !DILocation(line: 9, column: 1, scope: !27)
122 !32 = distinct !DISubprogram(name: "main", scope: !3, file: !3, line: 11, type: !33, scopeLine: 11, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !2, retainedNodes: !35)
123 !33 = !DISubroutineType(types: !34)
124 !34 = !{!6}
125 !35 = !{!36}
126 !36 = !DILocalVariable(name: "i", scope: !37, file: !3, line: 12, type: !6)
127 !37 = distinct !DILexicalBlock(scope: !32, file: !3, line: 12, column: 3)
128 !38 = !DILocation(line: 12, column: 12, scope: !37)
129 !39 = !DILocation(line: 0, scope: !37)
130 !40 = !DILocation(line: 12, column: 8, scope: !37)
131 !41 = !DILocation(line: 12, scope: !37)
132 !42 = !DILocation(line: 12, column: 19, scope: !43)
133 !43 = distinct !DILexicalBlock(scope: !37, file: !3, line: 12, column: 3)
134 !44 = !DILocation(line: 12, column: 21, scope: !43)
135 !45 = !DILocation(line: 12, column: 3, scope: !37)
136 !46 = !DILocation(line: 0, scope: !32)
137 !47 = !DILocation(line: 15, column: 1, scope: !32)
138 !48 = !DILocation(line: 13, column: 7, scope: !49)
139 !49 = distinct !DILexicalBlock(scope: !43, file: !3, line: 12, column: 41)
140 !50 = !DILocation(line: 13, column: 7, scope: !51)
141 !51 = !DILexicalBlockFile(scope: !49, file: !3, discriminator: 455082031)
142 !52 = !DILocation(line: 12, column: 37, scope: !43)
143 !53 = !DILocation(line: 12, column: 3, scope: !43)
144 !54 = distinct !{!54, !45, !55, !56}
145 !55 = !DILocation(line: 14, column: 3, scope: !37)
146 !56 = !{!"llvm.loop.mustprogress"}