17b61ae68SWenlei He; Let sample profile loader replay inlining of small/cold functions 27b61ae68SWenlei He 37b61ae68SWenlei He; Make sure we don't inline the cold call sites by default 47b61ae68SWenlei He; RUN: opt < %s -passes=sample-profile -sample-profile-file=%S/Inputs/inline-cold.prof -S | FileCheck -check-prefix=NOTINLINE %s 57b61ae68SWenlei He 67b61ae68SWenlei He; Make sure we inline code call sites for size if requested 77b61ae68SWenlei He 87b61ae68SWenlei He; Make sure we re-inline everything if requested 97b61ae68SWenlei He; RUN: opt < %s -passes=sample-profile -sample-profile-file=%S/Inputs/inline-cold.prof -sample-profile-inline-size -sample-profile-cold-inline-threshold=9999999 -S | FileCheck -check-prefix=INLINE %s 107b61ae68SWenlei He 117b61ae68SWenlei He; Make sure the separate size threshold for sample profile loader inlining works 127b61ae68SWenlei He; RUN: opt < %s -passes=sample-profile -sample-profile-file=%S/Inputs/inline-cold.prof -sample-profile-inline-size -sample-profile-cold-inline-threshold=-500 -S | FileCheck -check-prefix=NOTINLINE %s 137b61ae68SWenlei He 147b61ae68SWenlei He@.str = private unnamed_addr constant [11 x i8] c"sum is %d\0A\00", align 1 157b61ae68SWenlei He 167a6c8942SWei Midefine i32 @_Z3sumii(i32 %x, i32 %y) #0 !dbg !6 { 177b61ae68SWenlei Heentry: 187b61ae68SWenlei He %x.addr = alloca i32, align 4 197b61ae68SWenlei He %y.addr = alloca i32, align 4 20*0271ae65SFangrui Song store i32 %x, ptr %x.addr, align 4 21*0271ae65SFangrui Song store i32 %y, ptr %y.addr, align 4 22*0271ae65SFangrui Song %tmp = load i32, ptr %x.addr, align 4, !dbg !8 23*0271ae65SFangrui Song %tmp1 = load i32, ptr %y.addr, align 4, !dbg !8 247b61ae68SWenlei He %add = add nsw i32 %tmp, %tmp1, !dbg !8 257b61ae68SWenlei He ret i32 %add, !dbg !8 267b61ae68SWenlei He} 277b61ae68SWenlei He 287a6c8942SWei Midefine i32 @main() #0 !dbg !9 { 297b61ae68SWenlei Heentry: 307b61ae68SWenlei He %retval = alloca i32, align 4 317b61ae68SWenlei He %s = alloca i32, align 4 327b61ae68SWenlei He %i = alloca i32, align 4 33*0271ae65SFangrui Song store i32 0, ptr %retval 34*0271ae65SFangrui Song store i32 0, ptr %i, align 4, !dbg !10 357b61ae68SWenlei He br label %while.cond, !dbg !11 367b61ae68SWenlei He 377b61ae68SWenlei Hewhile.cond: ; preds = %if.end, %entry 38*0271ae65SFangrui Song %tmp = load i32, ptr %i, align 4, !dbg !12 397b61ae68SWenlei He %inc = add nsw i32 %tmp, 1, !dbg !12 40*0271ae65SFangrui Song store i32 %inc, ptr %i, align 4, !dbg !12 417b61ae68SWenlei He %cmp = icmp slt i32 %tmp, 400000000, !dbg !12 427b61ae68SWenlei He br i1 %cmp, label %while.body, label %while.end, !dbg !12 437b61ae68SWenlei He 447b61ae68SWenlei Hewhile.body: ; preds = %while.cond 45*0271ae65SFangrui Song %tmp1 = load i32, ptr %i, align 4, !dbg !14 467b61ae68SWenlei He %cmp1 = icmp ne i32 %tmp1, 100, !dbg !14 477b61ae68SWenlei He br i1 %cmp1, label %if.then, label %if.else, !dbg !14 487b61ae68SWenlei He 497b61ae68SWenlei Heif.then: ; preds = %while.body 50*0271ae65SFangrui Song %tmp2 = load i32, ptr %i, align 4, !dbg !16 51*0271ae65SFangrui Song %tmp3 = load i32, ptr %s, align 4, !dbg !16 527b61ae68SWenlei He %call = call i32 @_Z3sumii(i32 %tmp2, i32 %tmp3), !dbg !16 537b61ae68SWenlei He; INLINE-NOT: call i32 @_Z3sumii 547b61ae68SWenlei He; NOTINLINE: call i32 @_Z3sumii 55*0271ae65SFangrui Song store i32 %call, ptr %s, align 4, !dbg !16 567b61ae68SWenlei He br label %if.end, !dbg !16 577b61ae68SWenlei He 587b61ae68SWenlei Heif.else: ; preds = %while.body 59*0271ae65SFangrui Song store i32 30, ptr %s, align 4, !dbg !18 607b61ae68SWenlei He br label %if.end 617b61ae68SWenlei He 627b61ae68SWenlei Heif.end: ; preds = %if.else, %if.then 637b61ae68SWenlei He br label %while.cond, !dbg !20 647b61ae68SWenlei He 657b61ae68SWenlei Hewhile.end: ; preds = %while.cond 66*0271ae65SFangrui Song %tmp4 = load i32, ptr %s, align 4, !dbg !22 67*0271ae65SFangrui Song %call2 = call i32 (ptr, ...) @printf(ptr @.str, i32 %tmp4), !dbg !22 687b61ae68SWenlei He ret i32 0, !dbg !23 697b61ae68SWenlei He} 707b61ae68SWenlei He 717a6c8942SWei Miattributes #0 = { "use-sample-profile" } 727a6c8942SWei Mi 73*0271ae65SFangrui Songdeclare i32 @printf(ptr, ...) 747b61ae68SWenlei He 757b61ae68SWenlei He!llvm.dbg.cu = !{!0} 767b61ae68SWenlei He!llvm.module.flags = !{!3, !4} 777b61ae68SWenlei He!llvm.ident = !{!5} 787b61ae68SWenlei He 797b61ae68SWenlei He!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 3.5 ", isOptimized: false, runtimeVersion: 0, emissionKind: NoDebug, enums: !2, retainedTypes: !2, globals: !2, imports: !2) 807b61ae68SWenlei He!1 = !DIFile(filename: "calls.cc", directory: ".") 817b61ae68SWenlei He!2 = !{} 827b61ae68SWenlei He!3 = !{i32 2, !"Dwarf Version", i32 4} 837b61ae68SWenlei He!4 = !{i32 1, !"Debug Info Version", i32 3} 847b61ae68SWenlei He!5 = !{!"clang version 3.5 "} 857b61ae68SWenlei He!6 = distinct !DISubprogram(name: "sum", scope: !1, file: !1, line: 3, type: !7, scopeLine: 3, virtualIndex: 6, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2) 867b61ae68SWenlei He!7 = !DISubroutineType(types: !2) 877b61ae68SWenlei He!8 = !DILocation(line: 4, scope: !6) 887b61ae68SWenlei He!9 = distinct !DISubprogram(name: "main", scope: !1, file: !1, line: 7, type: !7, scopeLine: 7, virtualIndex: 6, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2) 897b61ae68SWenlei He!10 = !DILocation(line: 8, scope: !9) 907b61ae68SWenlei He!11 = !DILocation(line: 9, scope: !9) 917b61ae68SWenlei He!12 = !DILocation(line: 9, scope: !13) 927b61ae68SWenlei He!13 = !DILexicalBlockFile(scope: !9, file: !1, discriminator: 2) 937b61ae68SWenlei He!14 = !DILocation(line: 10, scope: !15) 947b61ae68SWenlei He!15 = distinct !DILexicalBlock(scope: !9, file: !1, line: 10) 957b61ae68SWenlei He!16 = !DILocation(line: 10, scope: !17) 967b61ae68SWenlei He!17 = !DILexicalBlockFile(scope: !15, file: !1, discriminator: 2) 977b61ae68SWenlei He!18 = !DILocation(line: 10, scope: !19) 987b61ae68SWenlei He!19 = !DILexicalBlockFile(scope: !15, file: !1, discriminator: 4) 997b61ae68SWenlei He!20 = !DILocation(line: 10, scope: !21) 1007b61ae68SWenlei He!21 = !DILexicalBlockFile(scope: !15, file: !1, discriminator: 6) 1017b61ae68SWenlei He!22 = !DILocation(line: 11, scope: !9) 1027b61ae68SWenlei He!23 = !DILocation(line: 12, scope: !9) 103