xref: /llvm-project/llvm/test/Transforms/SampleProfile/csspgo-import-list.ll (revision 61eb12e1f423063b0ead944827dc53b02baed0d4)
1a5d30421SWenlei He; Make sure Import GUID list for ThinLTO properly set for CSSPGO
2*61eb12e1Sspupyrev; RUN: opt < %s -passes='thinlto-pre-link<O2>' -pgo-kind=pgo-sample-use-pipeline -sample-profile-file=%S/Inputs/csspgo-import-list.prof --sample-profile-even-flow-distribution=0 -S | FileCheck %s
3b9db7036SHongtao Yu; RUN: llvm-profdata merge --sample --extbinary %S/Inputs/csspgo-import-list.prof -o %t.prof
4*61eb12e1Sspupyrev; RUN: opt < %s -passes='thinlto-pre-link<O2>' -pgo-kind=pgo-sample-use-pipeline -sample-profile-file=%t.prof --sample-profile-even-flow-distribution=0 -S | FileCheck %s
5f4711e0dSHongtao Yu; RUN: llvm-profdata show --sample -show-sec-info-only %t.prof | FileCheck %s --check-prefix=CHECK-ORDERED
67ca80300SHongtao Yu; RUN: llvm-profdata merge --sample --extbinary --use-md5 %S/Inputs/csspgo-import-list.prof -o %t.md5
7*61eb12e1Sspupyrev; RUN: opt < %s -passes='thinlto-pre-link<O2>' -pgo-kind=pgo-sample-use-pipeline -sample-profile-file=%t.md5 --sample-profile-even-flow-distribution=0 -S | FileCheck %s
8f4711e0dSHongtao Yu; RUN: llvm-profdata show --sample -show-sec-info-only %t.md5 | FileCheck %s --check-prefix=CHECK-ORDERED
9f4711e0dSHongtao Yu
1051ce567bSmodimo;; Validate that with replay in effect, we import call sites even if they are below the threshold
1151ce567bSmodimo;; Baseline import decisions
12*61eb12e1Sspupyrev; RUN: opt < %s -passes='thinlto-pre-link<O2>' -pgo-kind=pgo-sample-use-pipeline -sample-profile-file=%S/Inputs/csspgo-import-list.prof -profile-summary-hot-count=10000 --sample-profile-even-flow-distribution=0 -S | FileCheck %s --check-prefix=THRESHOLD
1351ce567bSmodimo;; With replay
14*61eb12e1Sspupyrev; RUN: opt < %s -passes='thinlto-pre-link<O2>' -pgo-kind=pgo-sample-use-pipeline -sample-profile-file=%S/Inputs/csspgo-import-list.prof -sample-profile-inline-replay=%S/Inputs/csspgo-import-list-replay.txt -sample-profile-inline-replay-scope=Module -profile-summary-hot-count=10000 --sample-profile-even-flow-distribution=0 -S | FileCheck %s --check-prefix=THRESHOLD-REPLAY
1551ce567bSmodimo;; With replay but no profile information for call to _Z5funcAi. We import _Z5funcAi because it's explicitly in the replay but don't go further to its callee (_Z3fibi) because we lack samples
16*61eb12e1Sspupyrev; RUN: opt < %s -passes='thinlto-pre-link<O2>' -pgo-kind=pgo-sample-use-pipeline -sample-profile-file=%S/Inputs/csspgo-import-list-no-funca.prof -sample-profile-inline-replay=%S/Inputs/csspgo-import-list-replay.txt -sample-profile-inline-replay-scope=Module -profile-summary-hot-count=10000 --sample-profile-even-flow-distribution=0 -S | FileCheck %s --check-prefix=THRESHOLD-REPLAY-NO-FUNCA
17a5d30421SWenlei He
18a5d30421SWenlei Hedeclare i32 @_Z5funcBi(i32 %x)
19a5d30421SWenlei Hedeclare i32 @_Z5funcAi(i32 %x)
20a5d30421SWenlei He
21a5d30421SWenlei Hedefine dso_local i32 @main() local_unnamed_addr #0 !dbg !18 {
22a5d30421SWenlei Heentry:
23a5d30421SWenlei He  br label %for.body, !dbg !25
24a5d30421SWenlei He
25a5d30421SWenlei Hefor.cond.cleanup:                                 ; preds = %for.body
26a5d30421SWenlei He  ret i32 %add3, !dbg !27
27a5d30421SWenlei He
28a5d30421SWenlei Hefor.body:                                         ; preds = %for.body, %entry
29a5d30421SWenlei He  %x.011 = phi i32 [ 300000, %entry ], [ %dec, %for.body ]
30a5d30421SWenlei He  %r.010 = phi i32 [ 0, %entry ], [ %add3, %for.body ]
31a5d30421SWenlei He  %call = tail call i32 @_Z5funcBi(i32 %x.011), !dbg !32
32a5d30421SWenlei He  %add = add nuw nsw i32 %x.011, 1, !dbg !31
33a5d30421SWenlei He  %call1 = tail call i32 @_Z5funcAi(i32 %add), !dbg !28
34a5d30421SWenlei He  %add2 = add i32 %call, %r.010, !dbg !34
35a5d30421SWenlei He  %add3 = add i32 %add2, %call1, !dbg !35
36a5d30421SWenlei He  %dec = add nsw i32 %x.011, -1, !dbg !36
37a5d30421SWenlei He  %cmp = icmp eq i32 %x.011, 0, !dbg !38
38a5d30421SWenlei He  br i1 %cmp, label %for.cond.cleanup, label %for.body, !dbg !25
39a5d30421SWenlei He}
40a5d30421SWenlei He
41a5d30421SWenlei He; Make sure the ImportGUID stays with entry count metadata for ThinLTO-PreLink
4251ce567bSmodimo; For reference, the GUIDs of the functions are:
4351ce567bSmodimo; _Z5funcBi:446061515086924981
4451ce567bSmodimo; _Z8funcLeafi:7102633082150537521
4551ce567bSmodimo; _Z5funcBiLeaf2:3815895320998406042
4651ce567bSmodimo; _Z8funcLeafi3:-2862076748587597320
4751ce567bSmodimo; _Z5funcAi:6309742469962978389
4851ce567bSmodimo; _Z3fibi:-2016976694713209516
4951ce567bSmodimo
50a5d30421SWenlei He; CHECK: distinct !DISubprogram(name: "main"
514e24ca1cSHongtao Yu; CHECK: !{!"function_entry_count", i64 1, i64 446061515086924981, i64 3815895320998406042, i64 7102633082150537521, i64 -2862076748587597320}
52a5d30421SWenlei He
53f4711e0dSHongtao Yu; CHECK-ORDERED: FuncOffsetTableSection {{.*}} {ordered}
54a5d30421SWenlei He
554e24ca1cSHongtao Yu; THRESHOLD: !{!"function_entry_count", i64 1}
564e24ca1cSHongtao Yu; THRESHOLD-REPLAY: !{!"function_entry_count", i64 1, i64 446061515086924981, i64 3815895320998406042, i64 6309742469962978389, i64 7102633082150537521, i64 -2862076748587597320, i64 -2016976694713209516}
574e24ca1cSHongtao Yu; THRESHOLD-REPLAY-NO-FUNCA: !{!"function_entry_count", i64 1, i64 446061515086924981, i64 3815895320998406042, i64 6309742469962978389, i64 7102633082150537521, i64 -2862076748587597320}
5851ce567bSmodimo
594ab3041aSserge-sans-pailleattributes #0 = { nofree noinline norecurse nounwind uwtable "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "frame-pointer"="none" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" "use-sample-profile" }
60a5d30421SWenlei He
61a5d30421SWenlei He!llvm.dbg.cu = !{!2}
62a5d30421SWenlei He!llvm.module.flags = !{!14, !15, !16}
63a5d30421SWenlei He!llvm.ident = !{!17}
64a5d30421SWenlei He
65a5d30421SWenlei He!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
66a5d30421SWenlei He!1 = distinct !DIGlobalVariable(name: "factor", scope: !2, file: !3, line: 21, type: !13, isLocal: false, isDefinition: true)
67a5d30421SWenlei He!2 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !3, producer: "clang version 11.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, retainedTypes: !5, globals: !12, splitDebugInlining: false, debugInfoForProfiling: true, nameTableKind: None)
68a5d30421SWenlei He!3 = !DIFile(filename: "merged.cpp", directory: "/local/autofdo")
69a5d30421SWenlei He!4 = !{}
70a5d30421SWenlei He!5 = !{!6, !10, !11}
71a5d30421SWenlei He!6 = !DISubprogram(name: "funcA", linkageName: "_Z5funcAi", scope: !3, file: !3, line: 6, type: !7, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !4)
72a5d30421SWenlei He!7 = !DISubroutineType(types: !8)
73a5d30421SWenlei He!8 = !{!9, !9}
74a5d30421SWenlei He!9 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
75a5d30421SWenlei He!10 = !DISubprogram(name: "funcB", linkageName: "_Z5funcBi", scope: !3, file: !3, line: 7, type: !7, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !4)
76a5d30421SWenlei He!11 = !DISubprogram(name: "funcLeaf", linkageName: "_Z8funcLeafi", scope: !3, file: !3, line: 22, type: !7, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !4)
77a5d30421SWenlei He!12 = !{!0}
78a5d30421SWenlei He!13 = !DIDerivedType(tag: DW_TAG_volatile_type, baseType: !9)
79a5d30421SWenlei He!14 = !{i32 7, !"Dwarf Version", i32 4}
80a5d30421SWenlei He!15 = !{i32 2, !"Debug Info Version", i32 3}
81a5d30421SWenlei He!16 = !{i32 1, !"wchar_size", i32 4}
82a5d30421SWenlei He!17 = !{!"clang version 11.0.0"}
83a5d30421SWenlei He!18 = distinct !DISubprogram(name: "main", scope: !3, file: !3, line: 11, type: !19, scopeLine: 11, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !2, retainedNodes: !21)
84a5d30421SWenlei He!19 = !DISubroutineType(types: !20)
85a5d30421SWenlei He!20 = !{!9}
86a5d30421SWenlei He!21 = !{!22, !23}
87a5d30421SWenlei He!22 = !DILocalVariable(name: "r", scope: !18, file: !3, line: 12, type: !9)
88a5d30421SWenlei He!23 = !DILocalVariable(name: "x", scope: !24, file: !3, line: 13, type: !9)
89a5d30421SWenlei He!24 = distinct !DILexicalBlock(scope: !18, file: !3, line: 13, column: 3)
90a5d30421SWenlei He!25 = !DILocation(line: 13, column: 3, scope: !26)
91a5d30421SWenlei He!26 = !DILexicalBlockFile(scope: !24, file: !3, discriminator: 2)
92a5d30421SWenlei He!27 = !DILocation(line: 17, column: 3, scope: !18)
93a5d30421SWenlei He!28 = !DILocation(line: 13, column: 10, scope: !29)
94a5d30421SWenlei He!29 = distinct !DILexicalBlock(scope: !30, file: !3, line: 13, column: 37)
95a5d30421SWenlei He!30 = distinct !DILexicalBlock(scope: !24, file: !3, line: 13, column: 3)
96a5d30421SWenlei He!31 = !DILocation(line: 14, column: 29, scope: !29)
97a5d30421SWenlei He!32 = !DILocation(line: 14, column: 21, scope: !33)
98a5d30421SWenlei He!33 = !DILexicalBlockFile(scope: !29, file: !3, discriminator: 2)
99a5d30421SWenlei He!34 = !DILocation(line: 14, column: 19, scope: !29)
100a5d30421SWenlei He!35 = !DILocation(line: 14, column: 7, scope: !29)
101a5d30421SWenlei He!36 = !DILocation(line: 13, column: 33, scope: !37)
102a5d30421SWenlei He!37 = !DILexicalBlockFile(scope: !30, file: !3, discriminator: 6)
103a5d30421SWenlei He!38 = !DILocation(line: 13, column: 26, scope: !39)
104a5d30421SWenlei He!39 = !DILexicalBlockFile(scope: !30, file: !3, discriminator: 2)
105