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