brintos

brintos / llvm-project-archived public Read only

0
0
Text · 9.8 KiB · e4ee939 Raw
166 lines · plain
1; Test for CSSPGO's sample loader inlining to make sure it can use llvm-profgen preinliner's decision2 3; RUN: opt < %s -passes=sample-profile -sample-profile-file=%S/Inputs/csspgo-use-preinliner.prof -pass-remarks=inline -sample-profile-prioritized-inline -profile-sample-accurate -sample-profile-use-preinliner=0 -S 2>&1 | FileCheck %s --check-prefix=DEFAULT4; RUN: opt < %s -passes=sample-profile -sample-profile-file=%S/Inputs/csspgo-use-preinliner.prof -pass-remarks=inline -sample-profile-prioritized-inline -profile-sample-accurate -sample-profile-use-preinliner=1 -S 2>&1 | FileCheck %s --check-prefix=PREINLINE5 6; RUN: llvm-profdata merge --sample --text --convert-sample-profile-layout=nest  -generate-merged-base-profiles=0 %S/Inputs/csspgo-use-preinliner.prof -o %t.prof7; RUN: opt < %s -passes=sample-profile -sample-profile-file=%t.prof -pass-remarks=inline -sample-profile-prioritized-inline -profile-sample-accurate -sample-profile-use-preinliner=0 -S 2>&1 | FileCheck %s --check-prefix=DEFAULT8; RUN: opt < %s -passes=sample-profile -sample-profile-file=%t.prof -pass-remarks=inline -sample-profile-prioritized-inline -profile-sample-accurate -sample-profile-use-preinliner=1 -S 2>&1 | FileCheck %s --check-prefix=PREINLINE9 10; DEFAULT: '_Z5funcAi' inlined into 'main'11; DEFAULT-NOT: inlined into12 13; PREINLINE-NOT: inlined into14; `[main:3 @ _Z5funcAi]` does not have preinline decision, so it's up for loader inliner to decided.15; PREINLINE: '_Z5funcAi' inlined into 'main'16; `[main:3 @ _Z5funcAi:1 @ _Z8funcLeafi]` is inlined according to preinline decision.17; PREINLINE: '_Z8funcLeafi' inlined into 'main'18; Even though `[main:3.1 @ _Z5funcBi]` context is marked should inline, `_Z5funcBi` is a noinline function, so we honor that and don't inline.19; When _Z5funcBi is promoted to be top level context-less profile, `[_Z5funcBi:1 @ _Z8funcLeafi]` becomes synthetic context, so preinline decision is ignored and we don't inline `_Z8funcLeafi`.20; PREINLINE-NOT: inlined into21 22@factor = dso_local global i32 3, align 4, !dbg !023 24define dso_local i32 @main() local_unnamed_addr #0 !dbg !18 {25entry:26  br label %for.body, !dbg !2527 28for.cond.cleanup:                                 ; preds = %for.body29  ret i32 %add3, !dbg !2730 31for.body:                                         ; preds = %for.body, %entry32  %x.011 = phi i32 [ 300000, %entry ], [ %dec, %for.body ]33  %r.010 = phi i32 [ 0, %entry ], [ %add3, %for.body ]34  %call = tail call i32 @_Z5funcBi(i32 %x.011), !dbg !3235  %add = add nuw nsw i32 %x.011, 1, !dbg !3136  %call1 = tail call i32 @_Z5funcAi(i32 %add), !dbg !2837  %add2 = add i32 %call, %r.010, !dbg !3438  %add3 = add i32 %add2, %call1, !dbg !3539  %dec = add nsw i32 %x.011, -1, !dbg !3640  %cmp = icmp eq i32 %x.011, 0, !dbg !3841  br i1 %cmp, label %for.cond.cleanup, label %for.body, !dbg !2542}43 44define dso_local i32 @_Z5funcAi(i32 %x) local_unnamed_addr #1 !dbg !40 {45entry:46  %add = add nsw i32 %x, 100000, !dbg !4447  %call = tail call i32 @_Z8funcLeafi(i32 %add), !dbg !4548  ret i32 %call, !dbg !4649}50 51define dso_local i32 @_Z8funcLeafi(i32 %x) local_unnamed_addr #1 !dbg !54 {52entry:53  %cmp = icmp sgt i32 %x, 0, !dbg !5754  br i1 %cmp, label %while.body, label %while.cond2.preheader, !dbg !5955 56while.cond2.preheader:                            ; preds = %entry57  %cmp313 = icmp slt i32 %x, 0, !dbg !6058  br i1 %cmp313, label %while.body4, label %if.end, !dbg !6359 60while.body:                                       ; preds = %while.body, %entry61  %x.addr.016 = phi i32 [ %sub, %while.body ], [ %x, %entry ]62  %tmp = load volatile i32, ptr @factor, align 4, !dbg !6463  %call = tail call i32 @_Z3fibi(i32 %tmp), !dbg !6764  %sub = sub nsw i32 %x.addr.016, %call, !dbg !6865  %cmp1 = icmp sgt i32 %sub, 0, !dbg !6966  br i1 %cmp1, label %while.body, label %if.end, !dbg !7167 68while.body4:                                      ; preds = %while.body4, %while.cond2.preheader69  %x.addr.114 = phi i32 [ %add, %while.body4 ], [ %x, %while.cond2.preheader ]70  %tmp1 = load volatile i32, ptr @factor, align 4, !dbg !7271  %call5 = tail call i32 @_Z3fibi(i32 %tmp1), !dbg !7472  %add = add nsw i32 %call5, %x.addr.114, !dbg !7573  %cmp3 = icmp slt i32 %add, 0, !dbg !6074  br i1 %cmp3, label %while.body4, label %if.end, !dbg !6375 76if.end:                                           ; preds = %while.body4, %while.body, %while.cond2.preheader77  %x.addr.2 = phi i32 [ 0, %while.cond2.preheader ], [ %sub, %while.body ], [ %add, %while.body4 ]78  ret i32 %x.addr.2, !dbg !7679}80 81define dso_local i32 @_Z5funcBi(i32 %x) local_unnamed_addr #0 !dbg !47 {82entry:83  %sub = add nsw i32 %x, -100000, !dbg !5184  %call = tail call i32 @_Z8funcLeafi(i32 %sub), !dbg !5285  ret i32 %call, !dbg !5386}87 88declare i32 @_Z3fibi(i32)89 90attributes #0 = { nofree noinline norecurse nounwind uwtable "use-sample-profile" }91attributes #1 = { nofree norecurse nounwind uwtable "use-sample-profile" }92 93!llvm.dbg.cu = !{!2}94!llvm.module.flags = !{!14, !15, !16}95!llvm.ident = !{!17}96 97!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())98!1 = distinct !DIGlobalVariable(name: "factor", scope: !2, file: !3, line: 21, type: !13, isLocal: false, isDefinition: true)99!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)100!3 = !DIFile(filename: "merged.cpp", directory: "/local/autofdo")101!4 = !{}102!5 = !{!6, !10, !11}103!6 = !DISubprogram(name: "funcA", linkageName: "_Z5funcAi", scope: !3, file: !3, line: 6, type: !7, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !4)104!7 = !DISubroutineType(types: !8)105!8 = !{!9, !9}106!9 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)107!10 = !DISubprogram(name: "funcB", linkageName: "_Z5funcBi", scope: !3, file: !3, line: 7, type: !7, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !4)108!11 = !DISubprogram(name: "funcLeaf", linkageName: "_Z8funcLeafi", scope: !3, file: !3, line: 22, type: !7, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !4)109!12 = !{!0}110!13 = !DIDerivedType(tag: DW_TAG_volatile_type, baseType: !9)111!14 = !{i32 7, !"Dwarf Version", i32 4}112!15 = !{i32 2, !"Debug Info Version", i32 3}113!16 = !{i32 1, !"wchar_size", i32 4}114!17 = !{!"clang version 11.0.0"}115!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)116!19 = !DISubroutineType(types: !20)117!20 = !{!9}118!21 = !{!22, !23}119!22 = !DILocalVariable(name: "r", scope: !18, file: !3, line: 12, type: !9)120!23 = !DILocalVariable(name: "x", scope: !24, file: !3, line: 13, type: !9)121!24 = distinct !DILexicalBlock(scope: !18, file: !3, line: 13, column: 3)122!25 = !DILocation(line: 13, column: 3, scope: !26)123!26 = !DILexicalBlockFile(scope: !24, file: !3, discriminator: 2)124!27 = !DILocation(line: 17, column: 3, scope: !18)125!28 = !DILocation(line: 14, column: 10, scope: !29)126!29 = distinct !DILexicalBlock(scope: !30, file: !3, line: 13, column: 37)127!30 = distinct !DILexicalBlock(scope: !24, file: !3, line: 13, column: 3)128!31 = !DILocation(line: 14, column: 29, scope: !29)129!32 = !DILocation(line: 14, column: 21, scope: !33)130!33 = !DILexicalBlockFile(scope: !29, file: !3, discriminator: 2)131!34 = !DILocation(line: 14, column: 19, scope: !29)132!35 = !DILocation(line: 14, column: 7, scope: !29)133!36 = !DILocation(line: 13, column: 33, scope: !37)134!37 = !DILexicalBlockFile(scope: !30, file: !3, discriminator: 6)135!38 = !DILocation(line: 13, column: 26, scope: !39)136!39 = !DILexicalBlockFile(scope: !30, file: !3, discriminator: 2)137!40 = distinct !DISubprogram(name: "funcA", linkageName: "_Z5funcAi", scope: !3, file: !3, line: 26, type: !7, scopeLine: 26, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !2)138!44 = !DILocation(line: 27, column: 22, scope: !40)139!45 = !DILocation(line: 27, column: 11, scope: !40)140!46 = !DILocation(line: 29, column: 3, scope: !40)141!47 = distinct !DISubprogram(name: "funcB", linkageName: "_Z5funcBi", scope: !3, file: !3, line: 32, type: !7, scopeLine: 32, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !2)142!51 = !DILocation(line: 33, column: 22, scope: !47)143!52 = !DILocation(line: 33, column: 11, scope: !47)144!53 = !DILocation(line: 35, column: 3, scope: !47)145!54 = distinct !DISubprogram(name: "funcLeaf", linkageName: "_Z8funcLeafi", scope: !3, file: !3, line: 48, type: !7, scopeLine: 48, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !2)146!57 = !DILocation(line: 49, column: 9, scope: !58)147!58 = distinct !DILexicalBlock(scope: !54, file: !3, line: 49, column: 7)148!59 = !DILocation(line: 49, column: 7, scope: !54)149!60 = !DILocation(line: 58, column: 14, scope: !61)150!61 = !DILexicalBlockFile(scope: !62, file: !3, discriminator: 2)151!62 = distinct !DILexicalBlock(scope: !58, file: !3, line: 56, column: 8)152!63 = !DILocation(line: 58, column: 5, scope: !61)153!64 = !DILocation(line: 52, column: 16, scope: !65)154!65 = distinct !DILexicalBlock(scope: !66, file: !3, line: 51, column: 19)155!66 = distinct !DILexicalBlock(scope: !58, file: !3, line: 49, column: 14)156!67 = !DILocation(line: 52, column: 12, scope: !65)157!68 = !DILocation(line: 52, column: 9, scope: !65)158!69 = !DILocation(line: 51, column: 14, scope: !70)159!70 = !DILexicalBlockFile(scope: !66, file: !3, discriminator: 2)160!71 = !DILocation(line: 51, column: 5, scope: !70)161!72 = !DILocation(line: 59, column: 16, scope: !73)162!73 = distinct !DILexicalBlock(scope: !62, file: !3, line: 58, column: 19)163!74 = !DILocation(line: 59, column: 12, scope: !73)164!75 = !DILocation(line: 59, column: 9, scope: !73)165!76 = !DILocation(line: 63, column: 3, scope: !54)166