1 ; RUN: opt -S -partial-inliner -min-block-execution=1 -skip-partial-inlining-cost-analysis < %s | FileCheck %s
2 ; RUN: opt -S -passes=partial-inliner -min-block-execution=1 -skip-partial-inlining-cost-analysis < %s | FileCheck %s
3 ; Require a dummy block (if.then.b) as successor to if.then due to PI requirement
4 ; of region containing more than one BB.
5 define signext i32 @bar(i32 signext %value, i32 signext %ub) #0 !prof !30 {
7 %value.addr = alloca i32, align 4
8 %ub.addr = alloca i32, align 4
9 %sum = alloca i32, align 4
10 %i = alloca i32, align 4
11 store i32 %value, i32* %value.addr, align 4
12 store i32 %ub, i32* %ub.addr, align 4
13 store i32 0, i32* %sum, align 4
14 store i32 0, i32* %i, align 4
17 for.cond: ; preds = %for.inc, %entry
18 %0 = load i32, i32* %i, align 4
19 %1 = load i32, i32* %ub.addr, align 4
20 %cmp = icmp slt i32 %0, %1
21 br i1 %cmp, label %for.body, label %for.end, !prof !31
23 for.body: ; preds = %for.cond
24 %2 = load i32, i32* %value.addr, align 4
25 %rem = srem i32 %2, 20
26 %cmp1 = icmp eq i32 %rem, 0
27 br i1 %cmp1, label %if.then, label %if.else, !prof !32
29 if.then: ; preds = %for.body
30 %3 = load i32, i32* %value.addr, align 4
31 %4 = load i32, i32* %i, align 4
32 %mul = mul nsw i32 %4, 5
33 %add = add nsw i32 %3, %mul
34 %5 = load i32, i32* %sum, align 4
35 %add2 = add nsw i32 %5, %add
36 store i32 %add2, i32* %sum, align 4
39 if.then.b: ; preds = %if.then
42 if.else: ; preds = %for.body
43 %6 = load i32, i32* %value.addr, align 4
44 %7 = load i32, i32* %i, align 4
45 %sub = sub nsw i32 %6, %7
46 %8 = load i32, i32* %sum, align 4
47 %add3 = add nsw i32 %8, %sub
48 store i32 %add3, i32* %sum, align 4
51 if.end: ; preds = %if.else, %if.then
54 for.inc: ; preds = %if.end
55 %9 = load i32, i32* %i, align 4
56 %inc = add nsw i32 %9, 1
57 store i32 %inc, i32* %i, align 4
60 for.end: ; preds = %for.cond
61 %10 = load i32, i32* %sum, align 4
65 define signext i32 @foo(i32 signext %value, i32 signext %ub) #0 !prof !30 {
68 ; CHECK-NOT: call signext i32 @bar
69 ; CHECK: call void @bar.1.if.then
71 %value.addr = alloca i32, align 4
72 %ub.addr = alloca i32, align 4
73 store i32 %value, i32* %value.addr, align 4
74 store i32 %ub, i32* %ub.addr, align 4
75 %0 = load i32, i32* %value.addr, align 4
76 %1 = load i32, i32* %ub.addr, align 4
77 %call = call signext i32 @bar(i32 signext %0, i32 signext %1)
81 ; CHECK-LABEL: define internal void @bar.1.if.then
85 !llvm.module.flags = !{!0, !1, !2}
88 !0 = !{i32 1, !"wchar_size", i32 4}
89 !1 = !{i32 7, !"PIC Level", i32 2}
90 !2 = !{i32 1, !"ProfileSummary", !3}
91 !3 = !{!4, !5, !6, !7, !8, !9, !10, !11}
92 !4 = !{!"ProfileFormat", !"InstrProf"}
93 !5 = !{!"TotalCount", i64 103}
94 !6 = !{!"MaxCount", i64 100}
95 !7 = !{!"MaxInternalCount", i64 1}
96 !8 = !{!"MaxFunctionCount", i64 100}
97 !9 = !{!"NumCounts", i64 5}
98 !10 = !{!"NumFunctions", i64 3}
99 !11 = !{!"DetailedSummary", !12}
100 !12 = !{!13, !14, !15, !16, !17, !18, !18, !19, !19, !20, !21, !22, !23, !24, !25, !26, !27, !28}
101 !13 = !{i32 10000, i64 100, i32 1}
102 !14 = !{i32 100000, i64 100, i32 1}
103 !15 = !{i32 200000, i64 100, i32 1}
104 !16 = !{i32 300000, i64 100, i32 1}
105 !17 = !{i32 400000, i64 100, i32 1}
106 !18 = !{i32 500000, i64 100, i32 1}
107 !19 = !{i32 600000, i64 100, i32 1}
108 !20 = !{i32 700000, i64 100, i32 1}
109 !21 = !{i32 800000, i64 100, i32 1}
110 !22 = !{i32 900000, i64 100, i32 1}
111 !23 = !{i32 950000, i64 100, i32 1}
112 !24 = !{i32 990000, i64 1, i32 4}
113 !25 = !{i32 999000, i64 1, i32 4}
114 !26 = !{i32 999900, i64 1, i32 4}
115 !27 = !{i32 999990, i64 1, i32 4}
116 !28 = !{i32 999999, i64 1, i32 4}
117 !29 = !{!"clang version 6.0.0 (123456)"}
118 !30 = !{!"function_entry_count", i64 2}
119 !31 = !{!"branch_weights", i32 100, i32 1}
120 !32 = !{!"branch_weights", i32 0, i32 100}