1; RUN: opt < %s -partial-inliner -S | FileCheck %s
2; RUN: opt < %s -passes=partial-inliner -S | FileCheck %s
3; RUN: opt < %s -partial-inliner -max-num-inline-blocks=3 -skip-partial-inlining-cost-analysis  -S | FileCheck --check-prefix=LIMIT3 %s
4; RUN: opt < %s -passes=partial-inliner -max-num-inline-blocks=3 -skip-partial-inlining-cost-analysis -S | FileCheck  --check-prefix=LIMIT3 %s
5; RUN: opt < %s -partial-inliner -max-num-inline-blocks=2 -S | FileCheck --check-prefix=LIMIT2 %s
6; RUN: opt < %s -passes=partial-inliner -max-num-inline-blocks=2 -S | FileCheck  --check-prefix=LIMIT2 %s
7
8
9; Function Attrs: nounwind uwtable
10define i32 @bar(i32 %arg) local_unnamed_addr #0 {
11bb:
12  %tmp = icmp slt i32 %arg, 0
13  br i1 %tmp, label %bb4, label %bb1
14
15bb1:                                              ; preds = %bb
16  %tmp2 = tail call i32 (...) @n() #2
17  %tmp3 = icmp slt i32 %tmp2, %arg
18  br i1 %tmp3, label %bb4, label %bb8
19
20bb4:                                              ; preds = %bb1, %bb
21  %tmp5 = tail call i32 (...) @m() #2
22  %tmp6 = icmp sgt i32 %tmp5, %arg
23  br i1 %tmp6, label %bb7, label %bb8
24
25bb7:                                              ; preds = %bb4
26  tail call void (...) @foo() #2
27  tail call void (...) @foo() #2
28  tail call void (...) @foo() #2
29  tail call void (...) @foo() #2
30  tail call void (...) @foo() #2
31  tail call void (...) @foo() #2
32  tail call void (...) @foo() #2
33  tail call void (...) @foo() #2
34  tail call void (...) @foo() #2
35  br label %bb8
36
37bb8:                                              ; preds = %bb7, %bb4, %bb1
38  %tmp9 = phi i32 [ 0, %bb7 ], [ 1, %bb4 ], [ 1, %bb1 ]
39  ret i32 %tmp9
40}
41
42declare i32 @n(...) local_unnamed_addr #1
43
44declare i32 @m(...) local_unnamed_addr #1
45
46declare void @foo(...) local_unnamed_addr #1
47
48; Function Attrs: nounwind uwtable
49define i32 @dummy_caller(i32 %arg) local_unnamed_addr #0 {
50bb:
51; CHECK-LABEL: @dummy_caller
52; CHECK: br i1
53; CHECK: br i1
54; CHECK: br i1
55; CHECK: call void @bar.1.
56; LIMIT3-LABEL: @dummy_caller
57; LIMIT3: br i1
58; LIMIT3: br i1
59; LIMIT3-NOT: br i1
60; LIMIT3: call void @bar.1.
61; LIMIT2-LABEL: @dummy_caller
62; LIMIT2-NOT: br i1
63; LIMIT2: call i32 @bar(
64  %tmp = tail call i32 @bar(i32 %arg)
65  ret i32 %tmp
66}
67
68attributes #0 = { nounwind }
69attributes #1 = { nounwind }
70attributes #2 = { nounwind }
71
72