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() !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 e 48; CHECK: callq b 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 %call2 = call zeroext i1 @a() 72 br i1 %call2, label %header2, label %header, !prof !3 73 74end: 75 call void @f() 76 ret void 77} 78 79define void @nested_loop_1() !prof !1 { 80; Test if a cold block in an inner loop will be placed at the end of the 81; function chain. 82; 83; CHECK-LABEL: nested_loop_1: 84; CHECK: callq b 85; CHECK: callq c 86; CHECK: callq e 87; CHECK: callq d 88 89entry: 90 br label %header 91 92header: 93 call void @b() 94 br label %header2 95 96header2: 97 call void @c() 98 %call = call zeroext i1 @a() 99 br i1 %call, label %end, label %if.else, !prof !4 100 101if.else: 102 call void @d() 103 %call2 = call zeroext i1 @a() 104 br i1 %call2, label %header2, label %header, !prof !5 105 106end: 107 call void @e() 108 ret void 109} 110 111declare zeroext i1 @a() 112declare void @b() 113declare void @c() 114declare void @d() 115declare void @e() 116declare void @f() 117 118!1 = !{!"function_entry_count", i64 1} 119!2 = !{!"branch_weights", i32 100, i32 1} 120!3 = !{!"branch_weights", i32 1, i32 10} 121!4 = !{!"branch_weights", i32 1000, i32 1} 122!5 = !{!"branch_weights", i32 100, i32 1} 123