1; Make sure Import GUID list for ThinLTO properly set for CSSPGO 2; 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 3; RUN: llvm-profdata merge --sample --extbinary %S/Inputs/csspgo-import-list.prof -o %t.prof 4; 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 5; RUN: llvm-profdata show --sample -show-sec-info-only %t.prof | FileCheck %s --check-prefix=CHECK-ORDERED 6; RUN: llvm-profdata merge --sample --extbinary --use-md5 %S/Inputs/csspgo-import-list.prof -o %t.md5 7; 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 8; RUN: llvm-profdata show --sample -show-sec-info-only %t.md5 | FileCheck %s --check-prefix=CHECK-ORDERED 9 10;; Validate that with replay in effect, we import call sites even if they are below the threshold 11;; Baseline import decisions 12; 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 13;; With replay 14; 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 15;; 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; 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 17 18declare i32 @_Z5funcBi(i32 %x) 19declare i32 @_Z5funcAi(i32 %x) 20 21define dso_local i32 @main() local_unnamed_addr #0 !dbg !18 { 22entry: 23 br label %for.body, !dbg !25 24 25for.cond.cleanup: ; preds = %for.body 26 ret i32 %add3, !dbg !27 27 28for.body: ; preds = %for.body, %entry 29 %x.011 = phi i32 [ 300000, %entry ], [ %dec, %for.body ] 30 %r.010 = phi i32 [ 0, %entry ], [ %add3, %for.body ] 31 %call = tail call i32 @_Z5funcBi(i32 %x.011), !dbg !32 32 %add = add nuw nsw i32 %x.011, 1, !dbg !31 33 %call1 = tail call i32 @_Z5funcAi(i32 %add), !dbg !28 34 %add2 = add i32 %call, %r.010, !dbg !34 35 %add3 = add i32 %add2, %call1, !dbg !35 36 %dec = add nsw i32 %x.011, -1, !dbg !36 37 %cmp = icmp eq i32 %x.011, 0, !dbg !38 38 br i1 %cmp, label %for.cond.cleanup, label %for.body, !dbg !25 39} 40 41; Make sure the ImportGUID stays with entry count metadata for ThinLTO-PreLink 42; For reference, the GUIDs of the functions are: 43; _Z5funcBi:446061515086924981 44; _Z8funcLeafi:7102633082150537521 45; _Z5funcBiLeaf2:3815895320998406042 46; _Z8funcLeafi3:-2862076748587597320 47; _Z5funcAi:6309742469962978389 48; _Z3fibi:-2016976694713209516 49 50; CHECK: distinct !DISubprogram(name: "main" 51; CHECK: !{!"function_entry_count", i64 1, i64 446061515086924981, i64 3815895320998406042, i64 7102633082150537521, i64 -2862076748587597320} 52 53; CHECK-ORDERED: FuncOffsetTableSection {{.*}} {ordered} 54 55; THRESHOLD: !{!"function_entry_count", i64 1} 56; THRESHOLD-REPLAY: !{!"function_entry_count", i64 1, i64 446061515086924981, i64 3815895320998406042, i64 6309742469962978389, i64 7102633082150537521, i64 -2862076748587597320, i64 -2016976694713209516} 57; THRESHOLD-REPLAY-NO-FUNCA: !{!"function_entry_count", i64 1, i64 446061515086924981, i64 3815895320998406042, i64 6309742469962978389, i64 7102633082150537521, i64 -2862076748587597320} 58 59attributes #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" } 60 61!llvm.dbg.cu = !{!2} 62!llvm.module.flags = !{!14, !15, !16} 63!llvm.ident = !{!17} 64 65!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression()) 66!1 = distinct !DIGlobalVariable(name: "factor", scope: !2, file: !3, line: 21, type: !13, isLocal: false, isDefinition: true) 67!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) 68!3 = !DIFile(filename: "merged.cpp", directory: "/local/autofdo") 69!4 = !{} 70!5 = !{!6, !10, !11} 71!6 = !DISubprogram(name: "funcA", linkageName: "_Z5funcAi", scope: !3, file: !3, line: 6, type: !7, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !4) 72!7 = !DISubroutineType(types: !8) 73!8 = !{!9, !9} 74!9 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) 75!10 = !DISubprogram(name: "funcB", linkageName: "_Z5funcBi", scope: !3, file: !3, line: 7, type: !7, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !4) 76!11 = !DISubprogram(name: "funcLeaf", linkageName: "_Z8funcLeafi", scope: !3, file: !3, line: 22, type: !7, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !4) 77!12 = !{!0} 78!13 = !DIDerivedType(tag: DW_TAG_volatile_type, baseType: !9) 79!14 = !{i32 7, !"Dwarf Version", i32 4} 80!15 = !{i32 2, !"Debug Info Version", i32 3} 81!16 = !{i32 1, !"wchar_size", i32 4} 82!17 = !{!"clang version 11.0.0"} 83!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) 84!19 = !DISubroutineType(types: !20) 85!20 = !{!9} 86!21 = !{!22, !23} 87!22 = !DILocalVariable(name: "r", scope: !18, file: !3, line: 12, type: !9) 88!23 = !DILocalVariable(name: "x", scope: !24, file: !3, line: 13, type: !9) 89!24 = distinct !DILexicalBlock(scope: !18, file: !3, line: 13, column: 3) 90!25 = !DILocation(line: 13, column: 3, scope: !26) 91!26 = !DILexicalBlockFile(scope: !24, file: !3, discriminator: 2) 92!27 = !DILocation(line: 17, column: 3, scope: !18) 93!28 = !DILocation(line: 13, column: 10, scope: !29) 94!29 = distinct !DILexicalBlock(scope: !30, file: !3, line: 13, column: 37) 95!30 = distinct !DILexicalBlock(scope: !24, file: !3, line: 13, column: 3) 96!31 = !DILocation(line: 14, column: 29, scope: !29) 97!32 = !DILocation(line: 14, column: 21, scope: !33) 98!33 = !DILexicalBlockFile(scope: !29, file: !3, discriminator: 2) 99!34 = !DILocation(line: 14, column: 19, scope: !29) 100!35 = !DILocation(line: 14, column: 7, scope: !29) 101!36 = !DILocation(line: 13, column: 33, scope: !37) 102!37 = !DILexicalBlockFile(scope: !30, file: !3, discriminator: 6) 103!38 = !DILocation(line: 13, column: 26, scope: !39) 104!39 = !DILexicalBlockFile(scope: !30, file: !3, discriminator: 2) 105