1; RUN: llc -mcpu=corei7 -mtriple=x86_64-linux < %s | FileCheck %s 2 3define void @foo() !prof !1 { 4; Test if a cold block in a loop will be placed at the end of the function 5; chain. 6; 7; CHECK-LABEL: foo: 8; CHECK: callq b 9; CHECK: callq c 10; CHECK: callq e 11; CHECK: callq f 12; CHECK: callq d 13 14entry: 15 br label %header 16 17header: 18 call void @b() 19 %call = call zeroext i1 @a() 20 br i1 %call, label %if.then, label %if.else, !prof !4 21 22if.then: 23 call void @c() 24 br label %if.end 25 26if.else: 27 call void @d() 28 br label %if.end 29 30if.end: 31 call void @e() 32 %call2 = call zeroext i1 @a() 33 br i1 %call2, label %header, label %end, !prof !5 34 35end: 36 call void @f() 37 ret void 38} 39 40define void @nested_loop_0(i1 %flag) !prof !1 { 41; Test if a block that is cold in the inner loop but not cold in the outer loop 42; will merged to the outer loop chain. 43; 44; CHECK-LABEL: nested_loop_0: 45; CHECK: callq c 46; CHECK: callq d 47; CHECK: callq b 48; CHECK: callq e 49; CHECK: callq f 50 51entry: 52 br label %header 53 54header: 55 call void @b() 56 %call4 = call zeroext i1 @a() 57 br i1 %call4, label %header2, label %end 58 59header2: 60 call void @c() 61 %call = call zeroext i1 @a() 62 br i1 %call, label %if.then, label %if.else, !prof !2 63 64if.then: 65 call void @d() 66 %call3 = call zeroext i1 @a() 67 br i1 %call3, label %header2, label %header, !prof !3 68 69if.else: 70 call void @e() 71 br i1 %flag, label %header2, label %header, !prof !3 72 73end: 74 call void @f() 75 ret void 76} 77 78define void @nested_loop_1() !prof !1 { 79; Test if a cold block in an inner loop will be placed at the end of the 80; function chain. 81; 82; CHECK-LABEL: nested_loop_1: 83; CHECK: callq b 84; CHECK: callq c 85; CHECK: callq e 86; CHECK: callq d 87 88entry: 89 br label %header 90 91header: 92 call void @b() 93 br label %header2 94 95header2: 96 call void @c() 97 %call = call zeroext i1 @a() 98 br i1 %call, label %end, label %if.else, !prof !4 99 100if.else: 101 call void @d() 102 %call2 = call zeroext i1 @a() 103 br i1 %call2, label %header2, label %header, !prof !5 104 105end: 106 call void @e() 107 ret void 108} 109 110declare zeroext i1 @a() 111declare void @b() 112declare void @c() 113declare void @d() 114declare void @e() 115declare void @f() 116 117!1 = !{!"function_entry_count", i64 1} 118!2 = !{!"branch_weights", i32 100, i32 1} 119!3 = !{!"branch_weights", i32 1, i32 10} 120!4 = !{!"branch_weights", i32 1000, i32 1} 121!5 = !{!"branch_weights", i32 100, i32 1} 122