1; RUN: opt < %s -passes='require<profile-summary>,cgscc(inline)' -pass-remarks=inline -pass-remarks-missed=inline -inline-savings-multiplier=4 -inline-savings-profitable-multiplier=5 -S 2>&1| FileCheck %s 2 3; Test that inline cost benefit multipler could be configured from command line. 4 5target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" 6target triple = "x86_64-unknown-linux-gnu" 7 8; @inlined_caleee is inlined by cost-benefit anlysis. 9; @not_inlined_callee is not inlined, decided by cost-benefit analysis 10; CHECK: remark: <unknown>:0:0: 'inlined_callee' inlined into 'caller' with (cost=always): benefit over cost 11; CHECK: remark: <unknown>:0:0: 'not_inlined_callee' not inlined into 'caller' because it should never be inlined (cost=never): cost over benefit 12 13define i32 @inlined_callee(i32 %c) !prof !17 { 14entry: 15 %mul = mul nsw i32 %c, %c 16 ret i32 %mul 17} 18 19define i32 @not_inlined_callee(i32 %c) !prof !18 { 20entry: 21 %add = add nsw i32 %c, 2 22 ret i32 %add 23} 24 25define i32 @caller(i32 %a, i32 %c) !prof !15 { 26entry: 27 %rem = srem i32 %a, 3 28 %cmp = icmp eq i32 %rem, 0 29 br i1 %cmp, label %if.then, label %if.end, !prof !16 30 31if.then: 32; CHECK-LABEL: if.then: 33; CHECK-NOT: call i32 @inlined_callee 34 %call = tail call i32 @inlined_callee(i32 %c) "inline-cycle-savings-for-test"="26" "inline-runtime-cost-for-test"="1" 35 br label %return 36 37if.end: 38; CHECK-LABEL: if.end: 39; CHECK: call i32 @not_inlined_callee 40 %call1 = tail call i32 @not_inlined_callee(i32 %c) "inline-cycle-savings-for-test"="19" "inline-runtime-cost-for-test"="1" 41 br label %return 42 43return: 44 %retval.0 = phi i32 [ %call, %if.then ], [ %call1, %if.end ] 45 ret i32 %retval.0 46} 47 48!llvm.module.flags = !{!1} 49 50!1 = !{i32 1, !"ProfileSummary", !2} 51!2 = !{!3, !4, !5, !6, !7, !8, !9, !10} 52!3 = !{!"ProfileFormat", !"InstrProf"} 53!4 = !{!"TotalCount", i64 10000} 54!5 = !{!"MaxCount", i64 1000} 55!6 = !{!"MaxInternalCount", i64 1} 56!7 = !{!"MaxFunctionCount", i64 1000} 57!8 = !{!"NumCounts", i64 3} 58!9 = !{!"NumFunctions", i64 3} 59!10 = !{!"DetailedSummary", !11} 60!11 = !{!12, !13, !14} 61!12 = !{i32 10000, i64 100, i32 1} 62!13 = !{i32 990000, i64 100, i32 1} 63!14 = !{i32 999999, i64 1, i32 2} 64!15 = !{!"function_entry_count", i64 500} 65!16 = !{!"branch_weights", i32 1, i32 2} 66!17 = !{!"function_entry_count", i64 200} 67!18 = !{!"function_entry_count", i64 400} 68