1*9880d681SAndroid Build Coastguard Worker; RUN: opt < %s -analyze -block-freq | FileCheck %s 2*9880d681SAndroid Build Coastguard Worker; RUN: opt < %s -passes='print<block-freq>' -disable-output 2>&1 | FileCheck %s 3*9880d681SAndroid Build Coastguard Worker 4*9880d681SAndroid Build Coastguard Workerdeclare void @g(i32 %x) 5*9880d681SAndroid Build Coastguard Worker 6*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: Printing analysis {{.*}} for function 'branch_weight_0': 7*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: block-frequency-info: branch_weight_0 8*9880d681SAndroid Build Coastguard Workerdefine void @branch_weight_0(i32 %a) { 9*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: entry: float = 1.0, int = [[ENTRY:[0-9]+]] 10*9880d681SAndroid Build Coastguard Workerentry: 11*9880d681SAndroid Build Coastguard Worker br label %for.body 12*9880d681SAndroid Build Coastguard Worker 13*9880d681SAndroid Build Coastguard Worker; Check that we get 1 and a huge frequency instead of 0,3. 14*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: for.body: float = 2147483647.8, 15*9880d681SAndroid Build Coastguard Workerfor.body: 16*9880d681SAndroid Build Coastguard Worker %i = phi i32 [ 0, %entry ], [ %inc, %for.body ] 17*9880d681SAndroid Build Coastguard Worker call void @g(i32 %i) 18*9880d681SAndroid Build Coastguard Worker %inc = add i32 %i, 1 19*9880d681SAndroid Build Coastguard Worker %cmp = icmp ugt i32 %inc, %a 20*9880d681SAndroid Build Coastguard Worker br i1 %cmp, label %for.end, label %for.body, !prof !0 21*9880d681SAndroid Build Coastguard Worker 22*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: for.end: float = 1.0, int = [[ENTRY]] 23*9880d681SAndroid Build Coastguard Workerfor.end: 24*9880d681SAndroid Build Coastguard Worker ret void 25*9880d681SAndroid Build Coastguard Worker} 26*9880d681SAndroid Build Coastguard Worker 27*9880d681SAndroid Build Coastguard Worker!0 = !{!"branch_weights", i32 0, i32 3} 28*9880d681SAndroid Build Coastguard Worker 29*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: Printing analysis {{.*}} for function 'infinite_loop' 30*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: block-frequency-info: infinite_loop 31*9880d681SAndroid Build Coastguard Workerdefine void @infinite_loop(i1 %x) { 32*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: entry: float = 1.0, int = [[ENTRY:[0-9]+]] 33*9880d681SAndroid Build Coastguard Workerentry: 34*9880d681SAndroid Build Coastguard Worker br i1 %x, label %for.body, label %for.end, !prof !1 35*9880d681SAndroid Build Coastguard Worker 36*9880d681SAndroid Build Coastguard Worker; Check that the infinite loop is arbitrarily scaled to max out at 4096, 37*9880d681SAndroid Build Coastguard Worker; giving 2048 here. 38*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: for.body: float = 2048.0, 39*9880d681SAndroid Build Coastguard Workerfor.body: 40*9880d681SAndroid Build Coastguard Worker %i = phi i32 [ 0, %entry ], [ %inc, %for.body ] 41*9880d681SAndroid Build Coastguard Worker call void @g(i32 %i) 42*9880d681SAndroid Build Coastguard Worker %inc = add i32 %i, 1 43*9880d681SAndroid Build Coastguard Worker br label %for.body 44*9880d681SAndroid Build Coastguard Worker 45*9880d681SAndroid Build Coastguard Worker; Check that the exit weight is half of entry, since half is lost in the 46*9880d681SAndroid Build Coastguard Worker; infinite loop above. 47*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: for.end: float = 0.5, 48*9880d681SAndroid Build Coastguard Workerfor.end: 49*9880d681SAndroid Build Coastguard Worker ret void 50*9880d681SAndroid Build Coastguard Worker} 51*9880d681SAndroid Build Coastguard Worker 52*9880d681SAndroid Build Coastguard Worker!1 = !{!"branch_weights", i32 1, i32 1} 53