1 ; The outlined region has high frequency and the outlining
2 ; call sequence is expensive (input, output, multiple exit etc)
3 ; RUN: opt < %s -passes=partial-inliner -max-num-inline-blocks=2 -S | FileCheck %s
4 ; RUN: opt < %s -passes=partial-inliner -skip-partial-inlining-cost-analysis -max-num-inline-blocks=2 -S | FileCheck --check-prefix=NOCOST %s
7 ; Function Attrs: nounwind
8 define i32 @bar_hot_outline_region(i32 %arg) local_unnamed_addr #0 {
10 %tmp = icmp slt i32 %arg, 0
11 br i1 %tmp, label %bb1, label %bb16, !prof !1
14 %tmp2 = tail call i32 (...) @foo() #0
15 %tmp3 = tail call i32 (...) @foo() #0
16 %tmp4 = tail call i32 (...) @foo() #0
17 %tmp5 = tail call i32 (...) @foo() #0
18 %tmp6 = tail call i32 (...) @foo() #0
19 %tmp7 = tail call i32 (...) @foo() #0
20 %tmp8 = add nsw i32 %arg, 1
21 %tmp9 = tail call i32 @goo(i32 %tmp8) #0
22 %tmp10 = tail call i32 (...) @foo() #0
23 %tmp11 = icmp eq i32 %tmp10, 0
24 br i1 %tmp11, label %bb12, label %bb16
27 %tmp13 = tail call i32 (...) @foo() #0
28 %tmp14 = icmp eq i32 %tmp13, 0
29 %tmp15 = select i1 %tmp14, i32 0, i32 3
32 bb16: ; preds = %bb12, %bb1, %bb
33 %tmp17 = phi i32 [ 2, %bb1 ], [ %tmp15, %bb12 ], [ 0, %bb ]
37 define i32 @bar_cold_outline_region(i32 %arg) local_unnamed_addr #0 {
39 %tmp = icmp slt i32 %arg, 0
40 br i1 %tmp, label %bb1, label %bb16, !prof !2
43 %tmp2 = tail call i32 (...) @foo() #0
44 %tmp3 = tail call i32 (...) @foo() #0
45 %tmp4 = tail call i32 (...) @foo() #0
46 %tmp5 = tail call i32 (...) @foo() #0
47 %tmp6 = tail call i32 (...) @foo() #0
48 %tmp7 = tail call i32 (...) @foo() #0
49 %tmp8 = add nsw i32 %arg, 1
50 %tmp9 = tail call i32 @goo(i32 %tmp8) #0
51 %tmp10 = tail call i32 (...) @foo() #0
52 %tmp11 = icmp eq i32 %tmp10, 0
53 br i1 %tmp11, label %bb12, label %bb16
56 %tmp13 = tail call i32 (...) @foo() #0
57 %tmp14 = icmp eq i32 %tmp13, 0
58 %tmp15 = select i1 %tmp14, i32 0, i32 3
61 bb16: ; preds = %bb12, %bb1, %bb
62 %tmp17 = phi i32 [ 2, %bb1 ], [ %tmp15, %bb12 ], [ 0, %bb ]
66 ; Function Attrs: nounwind
67 declare i32 @foo(...) local_unnamed_addr #0
69 ; Function Attrs: nounwind
70 declare i32 @goo(i32) local_unnamed_addr #0
72 ; Function Attrs: nounwind
73 define i32 @dummy_caller(i32 %arg) local_unnamed_addr #0 {
75 ; CHECK-LABEL: @dummy_caller
77 ; CHECK-NOT: call{{.*}}bar_hot_outline_region.
78 ; NOCOST-LABEL: @dummy_caller
80 ; NOCOST: call{{.*}}bar_hot_outline_region.
82 %tmp = tail call i32 @bar_hot_outline_region(i32 %arg)
86 define i32 @dummy_caller2(i32 %arg) local_unnamed_addr #0 {
88 ; CHECK-LABEL: @dummy_caller2
90 ; CHECK: call{{.*}}bar_cold_outline_region.
91 ; NOCOST-LABEL: @dummy_caller2
93 ; NOCOST: call{{.*}}bar_cold_outline_region.
95 %tmp = tail call i32 @bar_cold_outline_region(i32 %arg)
99 attributes #0 = { nounwind }
103 !0 = !{!"clang version 5.0.0 (trunk 301898)"}
104 !1 = !{!"branch_weights", i32 2000, i32 1}
105 !2 = !{!"branch_weights", i32 1, i32 100}