1; This tests that a hot callsite gets the (higher) inlinehint-threshold even without 2; without inline hints and gets inlined because the cost is less than 3; inlinehint-threshold. A cold callee with identical body does not get inlined because 4; cost exceeds the inline-threshold 5 6; RUN: opt < %s -passes='require<profile-summary>,cgscc(inline)' -inline-threshold=0 -hot-callsite-threshold=100 -S | FileCheck %s 7 8; Run this with the default O2 pipeline to test that profile summary analysis 9; is available during inlining. 10; RUN: opt < %s -passes='default<O2>' -inline-threshold=0 -hot-callsite-threshold=100 -S | FileCheck %s 11 12define i32 @callee1(i32 %x) { 13 %x1 = add i32 %x, 1 14 %x2 = add i32 %x1, 1 15 %x3 = add i32 %x2, 1 16 call void @extern() 17 call void @extern() 18 ret i32 %x3 19} 20 21define i32 @callee2(i32 %x) { 22; CHECK-LABEL: @callee2( 23 %x1 = add i32 %x, 1 24 %x2 = add i32 %x1, 1 25 %x3 = add i32 %x2, 1 26 call void @extern() 27 call void @extern() 28 ret i32 %x3 29} 30 31define i32 @caller2(i32 %y1) { 32; CHECK-LABEL: @caller2( 33; CHECK: call i32 @callee2 34; CHECK-NOT: call i32 @callee1 35; CHECK: ret i32 %x3.i 36 %y2 = call i32 @callee2(i32 %y1), !prof !22 37 %y3 = call i32 @callee1(i32 %y2), !prof !21 38 ret i32 %y3 39} 40 41declare i32 @__gxx_personality_v0(...) 42 43define i32 @invoker2(i32 %y1) personality ptr @__gxx_personality_v0 { 44; CHECK-LABEL: @invoker2( 45; CHECK: invoke i32 @callee2 46; CHECK-NOT: invoke i32 @callee1 47; CHECK: ret i32 48 %y2 = invoke i32 @callee2(i32 %y1) to label %next unwind label %lpad, !prof !22 49 50next: 51 %y3 = invoke i32 @callee1(i32 %y2) to label %exit unwind label %lpad, !prof !21 52 53exit: 54 ret i32 1 55 56lpad: 57 %ll = landingpad { ptr, i32 } cleanup 58 ret i32 1 59} 60 61define i32 @invoker3(i32 %y1) personality ptr @__gxx_personality_v0 { 62; CHECK-LABEL: @invoker3( 63; CHECK: invoke i32 @callee2 64; CHECK-NOT: invoke i32 @callee1 65; CHECK: ret i32 66 %y2 = invoke i32 @callee2(i32 %y1) to label %next unwind label %lpad, 67 !prof !{!"branch_weights", i64 1, i64 0} 68 69next: 70 %y3 = invoke i32 @callee1(i32 %y2) to label %exit unwind label %lpad, 71 !prof !{!"branch_weights", i64 300, i64 1} 72 73exit: 74 ret i32 1 75 76lpad: 77 %ll = landingpad { ptr, i32 } cleanup 78 ret i32 1 79} 80 81define i32 @invoker4(i32 %y1) personality ptr @__gxx_personality_v0 { 82; CHECK-LABEL: @invoker4( 83; CHECK: invoke i32 @callee2 84; CHECK-NOT: invoke i32 @callee1 85; CHECK: ret i32 86 %y2 = invoke i32 @callee2(i32 %y1) to label %next unwind label %lpad, 87 !prof !{!"branch_weights", i64 1, i64 0} 88 89next: 90 %y3 = invoke i32 @callee1(i32 %y2) to label %exit unwind label %lpad, 91 !prof !{!"branch_weights", i64 0, i64 300} 92 93exit: 94 ret i32 1 95 96lpad: 97 %ll = landingpad { ptr, i32 } cleanup 98 ret i32 1 99} 100 101declare void @extern() 102 103!llvm.module.flags = !{!1} 104!21 = !{!"branch_weights", i64 300} 105!22 = !{!"branch_weights", i64 1} 106 107!1 = !{i32 1, !"ProfileSummary", !2} 108!2 = !{!3, !4, !5, !6, !7, !8, !9, !10} 109!3 = !{!"ProfileFormat", !"SampleProfile"} 110!4 = !{!"TotalCount", i64 10000} 111!5 = !{!"MaxCount", i64 1000} 112!6 = !{!"MaxInternalCount", i64 1} 113!7 = !{!"MaxFunctionCount", i64 1000} 114!8 = !{!"NumCounts", i64 3} 115!9 = !{!"NumFunctions", i64 3} 116!10 = !{!"DetailedSummary", !11} 117!11 = !{!12, !13, !14} 118!12 = !{i32 10000, i64 100, i32 1} 119!13 = !{i32 999000, i64 100, i32 1} 120!14 = !{i32 999999, i64 1, i32 2} 121