• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 -inline -inline-threshold=0 -hot-callsite-threshold=100 -S | FileCheck %s
7; RUN: opt < %s -passes='require<profile-summary>,cgscc(inline)' -inline-threshold=0 -hot-callsite-threshold=100 -S | FileCheck %s
8
9; Run this with the default O2 pipeline to test that profile summary analysis
10; is available during inlining.
11; RUN: opt < %s -passes='default<O2>' -inline-threshold=0 -hot-callsite-threshold=100 -S | FileCheck %s
12
13define i32 @callee1(i32 %x) {
14  %x1 = add i32 %x, 1
15  %x2 = add i32 %x1, 1
16  %x3 = add i32 %x2, 1
17  call void @extern()
18  call void @extern()
19  ret i32 %x3
20}
21
22define i32 @callee2(i32 %x) {
23; CHECK-LABEL: @callee2(
24  %x1 = add i32 %x, 1
25  %x2 = add i32 %x1, 1
26  %x3 = add i32 %x2, 1
27  call void @extern()
28  call void @extern()
29  ret i32 %x3
30}
31
32define i32 @caller2(i32 %y1) {
33; CHECK-LABEL: @caller2(
34; CHECK: call i32 @callee2
35; CHECK-NOT: call i32 @callee1
36; CHECK: ret i32 %x3.i
37  %y2 = call i32 @callee2(i32 %y1), !prof !22
38  %y3 = call i32 @callee1(i32 %y2), !prof !21
39  ret i32 %y3
40}
41
42declare void @extern()
43
44!llvm.module.flags = !{!1}
45!21 = !{!"branch_weights", i64 300}
46!22 = !{!"branch_weights", i64 1}
47
48!1 = !{i32 1, !"ProfileSummary", !2}
49!2 = !{!3, !4, !5, !6, !7, !8, !9, !10}
50!3 = !{!"ProfileFormat", !"SampleProfile"}
51!4 = !{!"TotalCount", i64 10000}
52!5 = !{!"MaxCount", i64 1000}
53!6 = !{!"MaxInternalCount", i64 1}
54!7 = !{!"MaxFunctionCount", i64 1000}
55!8 = !{!"NumCounts", i64 3}
56!9 = !{!"NumFunctions", i64 3}
57!10 = !{!"DetailedSummary", !11}
58!11 = !{!12, !13, !14}
59!12 = !{i32 10000, i64 100, i32 1}
60!13 = !{i32 999000, i64 100, i32 1}
61!14 = !{i32 999999, i64 1, i32 2}
62