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
6 ; RUN: opt < %s -passes='require<profile-summary>,cgscc(inline)' -inline-threshold=0 -hot-callsite-threshold=100 -S | FileCheck %s
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
12 define i32 @callee1(i32 %x) {
21 define i32 @callee2(i32 %x) {
22 ; CHECK-LABEL: @callee2(
31 define 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
41 declare i32 @__gxx_personality_v0(...)
43 define i32 @invoker2(i32 %y1) personality ptr @__gxx_personality_v0 {
44 ; CHECK-LABEL: @invoker2(
45 ; CHECK: invoke i32 @callee2
46 ; CHECK-NOT: invoke i32 @callee1
48 %y2 = invoke i32 @callee2(i32 %y1) to label %next unwind label %lpad, !prof !22
51 %y3 = invoke i32 @callee1(i32 %y2) to label %exit unwind label %lpad, !prof !21
57 %ll = landingpad { ptr, i32 } cleanup
61 define i32 @invoker3(i32 %y1) personality ptr @__gxx_personality_v0 {
62 ; CHECK-LABEL: @invoker3(
63 ; CHECK: invoke i32 @callee2
64 ; CHECK-NOT: invoke i32 @callee1
66 %y2 = invoke i32 @callee2(i32 %y1) to label %next unwind label %lpad,
67 !prof !{!"branch_weights", i64 1, i64 0}
70 %y3 = invoke i32 @callee1(i32 %y2) to label %exit unwind label %lpad,
71 !prof !{!"branch_weights", i64 300, i64 1}
77 %ll = landingpad { ptr, i32 } cleanup
81 define i32 @invoker4(i32 %y1) personality ptr @__gxx_personality_v0 {
82 ; CHECK-LABEL: @invoker4(
83 ; CHECK: invoke i32 @callee2
84 ; CHECK-NOT: invoke i32 @callee1
86 %y2 = invoke i32 @callee2(i32 %y1) to label %next unwind label %lpad,
87 !prof !{!"branch_weights", i64 1, i64 0}
90 %y3 = invoke i32 @callee1(i32 %y2) to label %exit unwind label %lpad,
91 !prof !{!"branch_weights", i64 0, i64 300}
97 %ll = landingpad { ptr, i32 } cleanup
101 declare void @extern()
103 !llvm.module.flags = !{!1}
104 !21 = !{!"branch_weights", i64 300}
105 !22 = !{!"branch_weights", i64 1}
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}