1*cee313d2SEric Christopher; RUN: opt -S < %s  -partial-inliner -partial-inlining-extra-penalty=10 | FileCheck %s
2*cee313d2SEric Christopher; RUN: opt -S < %s  -passes=partial-inliner -partial-inlining-extra-penalty=10 | FileCheck %s
3*cee313d2SEric Christopherdefine i32 @outline_region_notlikely(i32* %arg) local_unnamed_addr {
4*cee313d2SEric Christopherbb:
5*cee313d2SEric Christopher;  ptr != null is predicted to be true
6*cee313d2SEric Christopher  %tmp = icmp ne i32* %arg, null
7*cee313d2SEric Christopher  br i1 %tmp, label %bb8, label %bb1
8*cee313d2SEric Christopher
9*cee313d2SEric Christopher; bb1 is not likely
10*cee313d2SEric Christopherbb1:                                              ; preds = %bb
11*cee313d2SEric Christopher  %tmp2 = tail call i32 @foo(i32* nonnull %arg)
12*cee313d2SEric Christopher  %tmp3 = tail call i32 @foo(i32* nonnull %arg)
13*cee313d2SEric Christopher  %tmp4 = tail call i32 @foo(i32* nonnull %arg)
14*cee313d2SEric Christopher  %tmp5 = tail call i32 @foo(i32* nonnull %arg)
15*cee313d2SEric Christopher  %tmp6 = tail call i32 @foo(i32* nonnull %arg)
16*cee313d2SEric Christopher  %tmp7 = tail call i32 @foo(i32* nonnull %arg)
17*cee313d2SEric Christopher  br label %bb8
18*cee313d2SEric Christopher
19*cee313d2SEric Christopherbb8:                                              ; preds = %bb1, %bb
20*cee313d2SEric Christopher  %tmp9 = phi i32 [ 0, %bb1 ], [ 1, %bb ]
21*cee313d2SEric Christopher  ret i32 %tmp9
22*cee313d2SEric Christopher}
23*cee313d2SEric Christopher
24*cee313d2SEric Christopherdefine i32 @outline_region_likely(i32* %arg) local_unnamed_addr {
25*cee313d2SEric Christopherbb:
26*cee313d2SEric Christopher;  ptr == null is predicted to be false
27*cee313d2SEric Christopher  %tmp = icmp eq i32* %arg, null
28*cee313d2SEric Christopher  br i1 %tmp, label %bb8, label %bb1
29*cee313d2SEric Christopher
30*cee313d2SEric Christopher; bb1 is likely
31*cee313d2SEric Christopherbb1:                                              ; preds = %bb
32*cee313d2SEric Christopher  %tmp2 = tail call i32 @foo(i32* nonnull %arg)
33*cee313d2SEric Christopher  %tmp3 = tail call i32 @foo(i32* nonnull %arg)
34*cee313d2SEric Christopher  %tmp4 = tail call i32 @foo(i32* nonnull %arg)
35*cee313d2SEric Christopher  %tmp5 = tail call i32 @foo(i32* nonnull %arg)
36*cee313d2SEric Christopher  %tmp6 = tail call i32 @foo(i32* nonnull %arg)
37*cee313d2SEric Christopher  %tmp7 = tail call i32 @foo(i32* nonnull %arg)
38*cee313d2SEric Christopher  br label %bb8
39*cee313d2SEric Christopher
40*cee313d2SEric Christopherbb8:                                              ; preds = %bb1, %bb
41*cee313d2SEric Christopher  %tmp9 = phi i32 [ 0, %bb1 ], [ 1, %bb ]
42*cee313d2SEric Christopher  ret i32 %tmp9
43*cee313d2SEric Christopher}
44*cee313d2SEric Christopher
45*cee313d2SEric Christopherdeclare i32 @foo(i32* %arg)
46*cee313d2SEric Christopher
47*cee313d2SEric Christopherdefine i32 @dummy_caller(i32* %arg) local_unnamed_addr {
48*cee313d2SEric Christopher; CHECK-LABEL: @dummy_caller
49*cee313d2SEric Christopher  %tmp = call i32 @outline_region_notlikely(i32* %arg)
50*cee313d2SEric Christopher; CHECK:  call void @outline_region_notlikely.2.bb1
51*cee313d2SEric Christopher  %tmp2 = tail call i32 @outline_region_likely(i32* %arg)
52*cee313d2SEric Christopher; CHECK: %tmp2 = tail call i32 @outline_region_likely(i32* %arg)
53*cee313d2SEric Christopher  ret i32 %tmp
54*cee313d2SEric Christopher
55*cee313d2SEric Christopher}
56*cee313d2SEric Christopher
57*cee313d2SEric Christopher; CHECK-LABEL: define internal void @outline_region_notlikely.2.bb1(i32* %arg) {
58*cee313d2SEric Christopher; CHECK-NEXT: newFuncRoot:
59*cee313d2SEric Christopher
60*cee313d2SEric Christopher!llvm.module.flags = !{!0}
61*cee313d2SEric Christopher!llvm.ident = !{!1}
62*cee313d2SEric Christopher
63*cee313d2SEric Christopher!0 = !{i32 1, !"wchar_size", i32 4}
64*cee313d2SEric Christopher!1 = !{!"clang version 5.0.0 (trunk 304489)"}
65