121 lines · plain
1; This tests that a hot callsite gets the (higher) inlinehint-threshold even without2; without inline hints and gets inlined because the cost is less than3; inlinehint-threshold. A cold callee with identical body does not get inlined because4; cost exceeds the inline-threshold5 6; RUN: opt < %s -passes='require<profile-summary>,cgscc(inline)' -inline-threshold=0 -hot-callsite-threshold=100 -S | FileCheck %s7 8; Run this with the default O2 pipeline to test that profile summary analysis9; is available during inlining.10; RUN: opt < %s -passes='default<O2>' -inline-threshold=0 -hot-callsite-threshold=100 -S | FileCheck %s11 12define i32 @callee1(i32 %x) {13 %x1 = add i32 %x, 114 %x2 = add i32 %x1, 115 %x3 = add i32 %x2, 116 call void @extern()17 call void @extern()18 ret i32 %x319}20 21define i32 @callee2(i32 %x) {22; CHECK-LABEL: @callee2(23 %x1 = add i32 %x, 124 %x2 = add i32 %x1, 125 %x3 = add i32 %x2, 126 call void @extern()27 call void @extern()28 ret i32 %x329}30 31define i32 @caller2(i32 %y1) {32; CHECK-LABEL: @caller2(33; CHECK: call i32 @callee234; CHECK-NOT: call i32 @callee135; CHECK: ret i32 %x3.i36 %y2 = call i32 @callee2(i32 %y1), !prof !2237 %y3 = call i32 @callee1(i32 %y2), !prof !2138 ret i32 %y339}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 @callee246; CHECK-NOT: invoke i32 @callee147; CHECK: ret i3248 %y2 = invoke i32 @callee2(i32 %y1) to label %next unwind label %lpad, !prof !2249 50next:51 %y3 = invoke i32 @callee1(i32 %y2) to label %exit unwind label %lpad, !prof !2152 53exit:54 ret i32 155 56lpad:57 %ll = landingpad { ptr, i32 } cleanup58 ret i32 159}60 61define i32 @invoker3(i32 %y1) personality ptr @__gxx_personality_v0 {62; CHECK-LABEL: @invoker3(63; CHECK: invoke i32 @callee264; CHECK-NOT: invoke i32 @callee165; CHECK: ret i3266 %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 175 76lpad:77 %ll = landingpad { ptr, i32 } cleanup78 ret i32 179}80 81define i32 @invoker4(i32 %y1) personality ptr @__gxx_personality_v0 {82; CHECK-LABEL: @invoker4(83; CHECK: invoke i32 @callee284; CHECK-NOT: invoke i32 @callee185; CHECK: ret i3286 %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 195 96lpad:97 %ll = landingpad { ptr, i32 } cleanup98 ret i32 199}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