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. 5define signext i32 @bar(i32 signext %value, i32 signext %ub) #0 !prof !30 { 6entry: 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 15 br label %for.cond 16 17for.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.cond2, !prof !31 22 23for.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 28 29if.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 37 br label %if.then.b 38 39if.then.b: ; preds = %if.then 40 br label %if.end 41 42if.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 49 br label %if.end 50 51if.end: ; preds = %if.else, %if.then 52 br label %for.inc 53 54for.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 58 br label %for.cond 59 60for.cond2: ; preds = %for.cond 61 %10 = load i32, i32* %i, align 4 62 %11 = load i32, i32* %ub.addr, align 4 63 %cmp2 = icmp slt i32 %10, %11 64 br i1 %cmp2, label %for.body2, label %for.end, !prof !31 65 66for.body2: ; preds = %for.cond2 67 %12 = load i32, i32* %value.addr, align 4 68 %rem2 = srem i32 %12, 20 69 %cmp3 = icmp eq i32 %rem2, 0 70 br i1 %cmp3, label %if.then2, label %if.else2, !prof !32 71 72if.then2: ; preds = %for.body2 73 %13 = load i32, i32* %value.addr, align 4 74 %14 = load i32, i32* %i, align 4 75 %mul2 = mul nsw i32 %14, 5 76 %add4 = add nsw i32 %13, %mul2 77 %15 = load i32, i32* %sum, align 4 78 %add5 = add nsw i32 %15, %add4 79 store i32 %add5, i32* %sum, align 4 80 br label %if.then2.b 81 82if.then2.b: ; preds = %if.then2 83 br label %if.end2 84 85if.else2: ; preds = %for.body2 86 %16 = load i32, i32* %value.addr, align 4 87 %17 = load i32, i32* %i, align 4 88 %sub2 = sub nsw i32 %16, %17 89 %18 = load i32, i32* %sum, align 4 90 %add6 = add nsw i32 %18, %sub2 91 store i32 %add6, i32* %sum, align 4 92 br label %if.end2 93 94if.end2: ; preds = %if.else2, %if.then2 95 br label %for.inc2 96 97for.inc2: ; preds = %if.end2 98 %19 = load i32, i32* %i, align 4 99 %inc2 = add nsw i32 %19, 1 100 store i32 %inc2, i32* %i, align 4 101 br label %for.cond2 102 103for.end: ; preds = %for.cond2 104 %20 = load i32, i32* %sum, align 4 105 ret i32 %20 106} 107 108define signext i32 @foo(i32 signext %value, i32 signext %ub) #0 !prof !30 { 109; CHECK-LABEL: @foo 110; CHECK-NOT: call signext i32 @bar 111; CHECK: codeRepl1.i: 112; CHECK: call void @bar.1.if.then 113; CHECK: codeRepl.i: 114; CHECK: call void @bar.1.if.then2 115entry: 116 %value.addr = alloca i32, align 4 117 %ub.addr = alloca i32, align 4 118 store i32 %value, i32* %value.addr, align 4 119 store i32 %ub, i32* %ub.addr, align 4 120 %0 = load i32, i32* %value.addr, align 4 121 %1 = load i32, i32* %ub.addr, align 4 122 %call = call signext i32 @bar(i32 signext %0, i32 signext %1) 123 ret i32 %call 124} 125 126; CHECK-LABEL: define internal void @bar.1.if.then2 127; CHECK: .exitStub: 128; CHECK: ret void 129 130; CHECK-LABEL: define internal void @bar.1.if.then 131; CHECK: .exitStub: 132; CHECK: ret void 133 134!llvm.module.flags = !{!0, !1, !2} 135!llvm.ident = !{!29} 136 137!0 = !{i32 1, !"wchar_size", i32 4} 138!1 = !{i32 7, !"PIC Level", i32 2} 139!2 = !{i32 1, !"ProfileSummary", !3} 140!3 = !{!4, !5, !6, !7, !8, !9, !10, !11} 141!4 = !{!"ProfileFormat", !"InstrProf"} 142!5 = !{!"TotalCount", i64 103} 143!6 = !{!"MaxCount", i64 100} 144!7 = !{!"MaxInternalCount", i64 1} 145!8 = !{!"MaxFunctionCount", i64 100} 146!9 = !{!"NumCounts", i64 5} 147!10 = !{!"NumFunctions", i64 3} 148!11 = !{!"DetailedSummary", !12} 149!12 = !{!13, !14, !15, !16, !17, !18, !18, !19, !19, !20, !21, !22, !23, !24, !25, !26, !27, !28} 150!13 = !{i32 10000, i64 100, i32 1} 151!14 = !{i32 100000, i64 100, i32 1} 152!15 = !{i32 200000, i64 100, i32 1} 153!16 = !{i32 300000, i64 100, i32 1} 154!17 = !{i32 400000, i64 100, i32 1} 155!18 = !{i32 500000, i64 100, i32 1} 156!19 = !{i32 600000, i64 100, i32 1} 157!20 = !{i32 700000, i64 100, i32 1} 158!21 = !{i32 800000, i64 100, i32 1} 159!22 = !{i32 900000, i64 100, i32 1} 160!23 = !{i32 950000, i64 100, i32 1} 161!24 = !{i32 990000, i64 1, i32 4} 162!25 = !{i32 999000, i64 1, i32 4} 163!26 = !{i32 999900, i64 1, i32 4} 164!27 = !{i32 999990, i64 1, i32 4} 165!28 = !{i32 999999, i64 1, i32 4} 166!29 = !{!"clang version 6.0.0 (123456)"} 167!30 = !{!"function_entry_count", i64 2} 168!31 = !{!"branch_weights", i32 100, i32 1} 169!32 = !{!"branch_weights", i32 0, i32 100} 170