Xinliang David Li | 66bdfca | 2017-05-12 23:41:43 +0000 | [diff] [blame] | 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 |
| 7 | |
| 8 | |
| 9 | ; Function Attrs: nounwind |
| 10 | define i32 @bar_hot_outline_region(i32 %arg) local_unnamed_addr #0 { |
| 11 | bb: |
| 12 | %tmp = icmp slt i32 %arg, 0 |
| 13 | br i1 %tmp, label %bb1, label %bb16, !prof !1 |
| 14 | |
| 15 | bb1: ; preds = %bb |
| 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 |
| 27 | |
| 28 | bb12: ; preds = %bb1 |
| 29 | %tmp13 = tail call i32 (...) @foo() #0 |
| 30 | %tmp14 = icmp eq i32 %tmp13, 0 |
| 31 | %tmp15 = select i1 %tmp14, i32 0, i32 3 |
| 32 | br label %bb16 |
| 33 | |
| 34 | bb16: ; preds = %bb12, %bb1, %bb |
| 35 | %tmp17 = phi i32 [ 2, %bb1 ], [ %tmp15, %bb12 ], [ 0, %bb ] |
| 36 | ret i32 %tmp17 |
| 37 | } |
| 38 | |
| 39 | define i32 @bar_cold_outline_region(i32 %arg) local_unnamed_addr #0 { |
| 40 | bb: |
| 41 | %tmp = icmp slt i32 %arg, 0 |
| 42 | br i1 %tmp, label %bb1, label %bb16, !prof !2 |
| 43 | |
| 44 | bb1: ; preds = %bb |
| 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 |
| 56 | |
| 57 | bb12: ; preds = %bb1 |
| 58 | %tmp13 = tail call i32 (...) @foo() #0 |
| 59 | %tmp14 = icmp eq i32 %tmp13, 0 |
| 60 | %tmp15 = select i1 %tmp14, i32 0, i32 3 |
| 61 | br label %bb16 |
| 62 | |
| 63 | bb16: ; preds = %bb12, %bb1, %bb |
| 64 | %tmp17 = phi i32 [ 2, %bb1 ], [ %tmp15, %bb12 ], [ 0, %bb ] |
| 65 | ret i32 %tmp17 |
| 66 | } |
| 67 | |
| 68 | ; Function Attrs: nounwind |
| 69 | declare i32 @foo(...) local_unnamed_addr #0 |
| 70 | |
| 71 | ; Function Attrs: nounwind |
| 72 | declare i32 @goo(i32) local_unnamed_addr #0 |
| 73 | |
| 74 | ; Function Attrs: nounwind |
| 75 | define i32 @dummy_caller(i32 %arg) local_unnamed_addr #0 { |
| 76 | bb: |
| 77 | ; CHECK-LABEL: @dummy_caller |
| 78 | ; CHECK-NOT: br i1 |
| 79 | ; CHECK-NOT: call{{.*}}bar_hot_outline_region. |
| 80 | ; NOCOST-LABEL: @dummy_caller |
| 81 | ; NOCOST: br i1 |
| 82 | ; NOCOST: call{{.*}}bar_hot_outline_region. |
| 83 | |
| 84 | %tmp = tail call i32 @bar_hot_outline_region(i32 %arg) |
| 85 | ret i32 %tmp |
| 86 | } |
| 87 | |
| 88 | define i32 @dummy_caller2(i32 %arg) local_unnamed_addr #0 { |
| 89 | bb: |
| 90 | ; CHECK-LABEL: @dummy_caller2 |
| 91 | ; CHECK: br i1 |
| 92 | ; CHECK: call{{.*}}bar_cold_outline_region. |
| 93 | ; NOCOST-LABEL: @dummy_caller2 |
| 94 | ; NOCOST: br i1 |
| 95 | ; NOCOST: call{{.*}}bar_cold_outline_region. |
| 96 | |
| 97 | %tmp = tail call i32 @bar_cold_outline_region(i32 %arg) |
| 98 | ret i32 %tmp |
| 99 | } |
| 100 | |
| 101 | attributes #0 = { nounwind } |
| 102 | |
| 103 | !llvm.ident = !{!0} |
| 104 | |
| 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} |