-
Notifications
You must be signed in to change notification settings - Fork 12.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BlockFrequencyInfoImpl: Avoid big numbers, increase precision for sma…
…ll spreads BlockFrequencyInfo calculates block frequencies as Scaled64 numbers but as a last step converts them to unsigned 64bit integers (`BlockFrequency`). This improves the factors picked for this conversion so that: * Avoid big numbers close to UINT64_MAX to avoid users overflowing/saturating when adding multiply frequencies together or when multiplying with integers. This leaves the topmost 10 bits unused to allow for some room. * Spread the difference between hottest/coldest block as much as possible to increase precision. * If the hot/cold spread cannot be represented loose precision at the lower end, but keep the frequencies at the upper end for hot blocks differentiable.
- Loading branch information
Showing
90 changed files
with
1,822 additions
and
1,616 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
; RUN: opt < %s -disable-output -passes="print<block-freq>" 2>&1 | FileCheck %s | ||
; Sanity check precision for small-ish min/max spread. | ||
|
||
@g = global i32 0 | ||
|
||
; CHECK-LABEL: block-frequency-info: func0 | ||
; CHECK: - entry: float = 1.0, {{.*}}, count = 1000 | ||
; CHECK: - cmp0_true: float = 0.4, {{.*}}, count = 400 | ||
; CHECK: - cmp0_false: float = 0.6, {{.*}}, count = 600 | ||
; CHECK: - cmp1_true: float = 0.1, {{.*}}, count = 100 | ||
; CHECK: - cmp1_false: float = 0.3, {{.*}}, count = 300 | ||
; CHECK: - join: float = 1.0, {{.*}}, count = 1000 | ||
|
||
define void @func0(i32 %a0, i32 %a1) !prof !0 { | ||
entry: | ||
%cmp0 = icmp ne i32 %a0, 0 | ||
br i1 %cmp0, label %cmp0_true, label %cmp0_false, !prof !1 | ||
|
||
cmp0_true: | ||
store volatile i32 1, ptr @g | ||
%cmp1 = icmp ne i32 %a1, 0 | ||
br i1 %cmp1, label %cmp1_true, label %cmp1_false, !prof !2 | ||
|
||
cmp0_false: | ||
store volatile i32 2, ptr @g | ||
br label %join | ||
|
||
cmp1_true: | ||
store volatile i32 3, ptr @g | ||
br label %join | ||
|
||
cmp1_false: | ||
store volatile i32 4, ptr @g | ||
br label %join | ||
|
||
join: | ||
store volatile i32 5, ptr @g | ||
ret void | ||
} | ||
|
||
!0 = !{!"function_entry_count", i64 1000} | ||
!1 = !{!"branch_weights", i32 400, i32 600} | ||
!2 = !{!"branch_weights", i32 1, i32 3} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.