1 ; The outlined region has high frequency and the outlining
2 ; call sequence is expensive (input, output, multiple exit etc)
3 ; RUN: opt < %s -partial-inliner -max-num-inline-blocks=2 -S | FileCheck %s
4 ; RUN: opt < %s -passes=partial-inliner -max-num-inline-blocks=2 -S | FileCheck %s
5 ; RUN: opt < %s -partial-inliner -skip-partial-inlining-cost-analysis -max-num-inline-blocks=2 -S | FileCheck --check-prefix=NOCOST %s
6 ; RUN: opt < %s -passes=partial-inliner -skip-partial-inlining-cost-analysis -max-num-inline-blocks=2 -S | FileCheck --check-prefix=NOCOST %s
9 ; Function Attrs: nounwind
10 define i32 @bar_hot_outline_region(i32 %arg) local_unnamed_addr #0 {
12 %tmp = icmp slt i32 %arg, 0
13 br i1 %tmp, label %bb1, label %bb16, !prof !1
16 %tmp2 = tail call i32 (...) @foo() #0
17 %tmp3 = tail call i32 (...) @foo() #0
18 %tmp4 = tail call i32 (...) @foo() #0
19 %tmp5 = tail call i32 (...) @foo() #0
20 %tmp6 = tail call i32 (...) @foo() #0
21 %tmp7 = tail call i32 (...) @foo() #0
22 %tmp8 = add nsw i32 %arg, 1
23 %tmp9 = tail call i32 @goo(i32 %tmp8) #0
24 %tmp10 = tail call i32 (...) @foo() #0
25 %tmp11 = icmp eq i32 %tmp10, 0
26 br i1 %tmp11, label %bb12, label %bb16
29 %tmp13 = tail call i32 (...) @foo() #0
30 %tmp14 = icmp eq i32 %tmp13, 0
31 %tmp15 = select i1 %tmp14, i32 0, i32 3
34 bb16: ; preds = %bb12, %bb1, %bb
35 %tmp17 = phi i32 [ 2, %bb1 ], [ %tmp15, %bb12 ], [ 0, %bb ]
39 define i32 @bar_cold_outline_region(i32 %arg) local_unnamed_addr #0 {
41 %tmp = icmp slt i32 %arg, 0
42 br i1 %tmp, label %bb1, label %bb16, !prof !2
45 %tmp2 = tail call i32 (...) @foo() #0
46 %tmp3 = tail call i32 (...) @foo() #0
47 %tmp4 = tail call i32 (...) @foo() #0
48 %tmp5 = tail call i32 (...) @foo() #0
49 %tmp6 = tail call i32 (...) @foo() #0
50 %tmp7 = tail call i32 (...) @foo() #0
51 %tmp8 = add nsw i32 %arg, 1
52 %tmp9 = tail call i32 @goo(i32 %tmp8) #0
53 %tmp10 = tail call i32 (...) @foo() #0
54 %tmp11 = icmp eq i32 %tmp10, 0
55 br i1 %tmp11, label %bb12, label %bb16
58 %tmp13 = tail call i32 (...) @foo() #0
59 %tmp14 = icmp eq i32 %tmp13, 0
60 %tmp15 = select i1 %tmp14, i32 0, i32 3
63 bb16: ; preds = %bb12, %bb1, %bb
64 %tmp17 = phi i32 [ 2, %bb1 ], [ %tmp15, %bb12 ], [ 0, %bb ]
68 ; Function Attrs: nounwind
69 declare i32 @foo(...) local_unnamed_addr #0
71 ; Function Attrs: nounwind
72 declare i32 @goo(i32) local_unnamed_addr #0
74 ; Function Attrs: nounwind
75 define i32 @dummy_caller(i32 %arg) local_unnamed_addr #0 {
77 ; CHECK-LABEL: @dummy_caller
79 ; CHECK-NOT: call{{.*}}bar_hot_outline_region.
80 ; NOCOST-LABEL: @dummy_caller
82 ; NOCOST: call{{.*}}bar_hot_outline_region.
84 %tmp = tail call i32 @bar_hot_outline_region(i32 %arg)
88 define i32 @dummy_caller2(i32 %arg) local_unnamed_addr #0 {
90 ; CHECK-LABEL: @dummy_caller2
92 ; CHECK: call{{.*}}bar_cold_outline_region.
93 ; NOCOST-LABEL: @dummy_caller2
95 ; NOCOST: call{{.*}}bar_cold_outline_region.
97 %tmp = tail call i32 @bar_cold_outline_region(i32 %arg)
101 attributes #0 = { nounwind }
105 !0 = !{!"clang version 5.0.0 (trunk 301898)"}
106 !1 = !{!"branch_weights", i32 2000, i32 1}
107 !2 = !{!"branch_weights", i32 1, i32 100}