122 lines · plain
1; RUN: llc -mcpu=corei7 -mtriple=x86_64-linux < %s | FileCheck %s2 3define void @foo() !prof !1 {4; Test if a cold block in a loop will be placed at the end of the function5; chain.6;7; CHECK-LABEL: foo:8; CHECK: callq b9; CHECK: callq c10; CHECK: callq e11; CHECK: callq f12; CHECK: callq d13 14entry:15 br label %header16 17header:18 call void @b()19 %call = call zeroext i1 @a()20 br i1 %call, label %if.then, label %if.else, !prof !421 22if.then:23 call void @c()24 br label %if.end25 26if.else:27 call void @d()28 br label %if.end29 30if.end:31 call void @e()32 %call2 = call zeroext i1 @a()33 br i1 %call2, label %header, label %end, !prof !534 35end:36 call void @f()37 ret void38}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 loop42; will merged to the outer loop chain.43;44; CHECK-LABEL: nested_loop_0:45; CHECK: callq c46; CHECK: callq d47; CHECK: callq b48; CHECK: callq e49; CHECK: callq f50 51entry:52 br label %header53 54header:55 call void @b()56 %call4 = call zeroext i1 @a()57 br i1 %call4, label %header2, label %end58 59header2:60 call void @c()61 %call = call zeroext i1 @a()62 br i1 %call, label %if.then, label %if.else, !prof !263 64if.then:65 call void @d()66 %call3 = call zeroext i1 @a()67 br i1 %call3, label %header2, label %header, !prof !368 69if.else:70 call void @e()71 br i1 %flag, label %header2, label %header, !prof !372 73end:74 call void @f()75 ret void76}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 the80; function chain.81;82; CHECK-LABEL: nested_loop_1:83; CHECK: callq b84; CHECK: callq c85; CHECK: callq e86; CHECK: callq d87 88entry:89 br label %header90 91header:92 call void @b()93 br label %header294 95header2:96 call void @c()97 %call = call zeroext i1 @a()98 br i1 %call, label %end, label %if.else, !prof !499 100if.else:101 call void @d()102 %call2 = call zeroext i1 @a()103 br i1 %call2, label %header2, label %header, !prof !5104 105end:106 call void @e()107 ret void108}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