bad_input.ll 1.4 KB

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