105 lines · plain
1; Make sure Import GUID list for ThinLTO properly set for CSSPGO2; 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 %s3; RUN: llvm-profdata merge --sample --extbinary %S/Inputs/csspgo-import-list.prof -o %t.prof4; 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 %s5; RUN: llvm-profdata show --sample -show-sec-info-only %t.prof | FileCheck %s --check-prefix=CHECK-ORDERED6; RUN: llvm-profdata merge --sample --extbinary --use-md5 %S/Inputs/csspgo-import-list.prof -o %t.md57; 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 %s8; RUN: llvm-profdata show --sample -show-sec-info-only %t.md5 | FileCheck %s --check-prefix=CHECK-ORDERED9 10;; Validate that with replay in effect, we import call sites even if they are below the threshold11;; Baseline import decisions12; 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=THRESHOLD13;; With replay14; 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-REPLAY15;; 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 samples16; 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-FUNCA17 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 !2524 25for.cond.cleanup: ; preds = %for.body26 ret i32 %add3, !dbg !2727 28for.body: ; preds = %for.body, %entry29 %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 !3232 %add = add nuw nsw i32 %x.011, 1, !dbg !3133 %call1 = tail call i32 @_Z5funcAi(i32 %add), !dbg !2834 %add2 = add i32 %call, %r.010, !dbg !3435 %add3 = add i32 %add2, %call1, !dbg !3536 %dec = add nsw i32 %x.011, -1, !dbg !3637 %cmp = icmp eq i32 %x.011, 0, !dbg !3838 br i1 %cmp, label %for.cond.cleanup, label %for.body, !dbg !2539}40 41; Make sure the ImportGUID stays with entry count metadata for ThinLTO-PreLink42; For reference, the GUIDs of the functions are:43; _Z5funcBi:44606151508692498144; _Z8funcLeafi:710263308215053752145; _Z5funcBiLeaf2:381589532099840604246; _Z8funcLeafi3:-286207674858759732047; _Z5funcAi:630974246996297838948; _Z3fibi:-201697669471320951649 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 "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