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