mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-14 11:32:34 +00:00
Print block frequencies in decimal form.
This is easier to read than the internal fixed-point representation. If anybody knows the correct algorithm for converting fixed-point numbers to base 10, feel free to fix it. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@184881 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
5e48a0e9ae
commit
b1c0cc22dd
@ -117,7 +117,16 @@ BlockFrequency::operator+(const BlockFrequency &Prob) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void BlockFrequency::print(raw_ostream &OS) const {
|
void BlockFrequency::print(raw_ostream &OS) const {
|
||||||
OS << Frequency;
|
// Convert fixed-point number to decimal.
|
||||||
|
OS << Frequency / getEntryFrequency() << ".";
|
||||||
|
uint64_t Rem = Frequency % getEntryFrequency();
|
||||||
|
uint64_t Eps = 1;
|
||||||
|
do {
|
||||||
|
Rem *= 10;
|
||||||
|
Eps *= 10;
|
||||||
|
OS << Rem / getEntryFrequency();
|
||||||
|
Rem = Rem % getEntryFrequency();
|
||||||
|
} while (Rem >= Eps/2);
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace llvm {
|
namespace llvm {
|
||||||
|
@ -2,12 +2,12 @@
|
|||||||
|
|
||||||
define i32 @test1(i32 %i, i32* %a) {
|
define i32 @test1(i32 %i, i32* %a) {
|
||||||
; CHECK: Printing analysis {{.*}} for function 'test1'
|
; CHECK: Printing analysis {{.*}} for function 'test1'
|
||||||
; CHECK: entry = 16384
|
; CHECK: entry = 1.0
|
||||||
entry:
|
entry:
|
||||||
br label %body
|
br label %body
|
||||||
|
|
||||||
; Loop backedges are weighted and thus their bodies have a greater frequency.
|
; Loop backedges are weighted and thus their bodies have a greater frequency.
|
||||||
; CHECK: body = 524288
|
; CHECK: body = 32.0
|
||||||
body:
|
body:
|
||||||
%iv = phi i32 [ 0, %entry ], [ %next, %body ]
|
%iv = phi i32 [ 0, %entry ], [ %next, %body ]
|
||||||
%base = phi i32 [ 0, %entry ], [ %sum, %body ]
|
%base = phi i32 [ 0, %entry ], [ %sum, %body ]
|
||||||
@ -18,29 +18,29 @@ body:
|
|||||||
%exitcond = icmp eq i32 %next, %i
|
%exitcond = icmp eq i32 %next, %i
|
||||||
br i1 %exitcond, label %exit, label %body
|
br i1 %exitcond, label %exit, label %body
|
||||||
|
|
||||||
; CHECK: exit = 16384
|
; CHECK: exit = 1.0
|
||||||
exit:
|
exit:
|
||||||
ret i32 %sum
|
ret i32 %sum
|
||||||
}
|
}
|
||||||
|
|
||||||
define i32 @test2(i32 %i, i32 %a, i32 %b) {
|
define i32 @test2(i32 %i, i32 %a, i32 %b) {
|
||||||
; CHECK: Printing analysis {{.*}} for function 'test2'
|
; CHECK: Printing analysis {{.*}} for function 'test2'
|
||||||
; CHECK: entry = 16384
|
; CHECK: entry = 1.0
|
||||||
entry:
|
entry:
|
||||||
%cond = icmp ult i32 %i, 42
|
%cond = icmp ult i32 %i, 42
|
||||||
br i1 %cond, label %then, label %else, !prof !0
|
br i1 %cond, label %then, label %else, !prof !0
|
||||||
|
|
||||||
; The 'then' branch is predicted more likely via branch weight metadata.
|
; The 'then' branch is predicted more likely via branch weight metadata.
|
||||||
; CHECK: then = 15420
|
; CHECK: then = 0.94116
|
||||||
then:
|
then:
|
||||||
br label %exit
|
br label %exit
|
||||||
|
|
||||||
; CHECK: else = 963
|
; CHECK: else = 0.05877
|
||||||
else:
|
else:
|
||||||
br label %exit
|
br label %exit
|
||||||
|
|
||||||
; FIXME: It may be a bug that we don't sum back to 16384.
|
; FIXME: It may be a bug that we don't sum back to 1.0.
|
||||||
; CHECK: exit = 16383
|
; CHECK: exit = 0.99993
|
||||||
exit:
|
exit:
|
||||||
%result = phi i32 [ %a, %then ], [ %b, %else ]
|
%result = phi i32 [ %a, %then ], [ %b, %else ]
|
||||||
ret i32 %result
|
ret i32 %result
|
||||||
@ -50,36 +50,36 @@ exit:
|
|||||||
|
|
||||||
define i32 @test3(i32 %i, i32 %a, i32 %b, i32 %c, i32 %d, i32 %e) {
|
define i32 @test3(i32 %i, i32 %a, i32 %b, i32 %c, i32 %d, i32 %e) {
|
||||||
; CHECK: Printing analysis {{.*}} for function 'test3'
|
; CHECK: Printing analysis {{.*}} for function 'test3'
|
||||||
; CHECK: entry = 16384
|
; CHECK: entry = 1.0
|
||||||
entry:
|
entry:
|
||||||
switch i32 %i, label %case_a [ i32 1, label %case_b
|
switch i32 %i, label %case_a [ i32 1, label %case_b
|
||||||
i32 2, label %case_c
|
i32 2, label %case_c
|
||||||
i32 3, label %case_d
|
i32 3, label %case_d
|
||||||
i32 4, label %case_e ], !prof !1
|
i32 4, label %case_e ], !prof !1
|
||||||
|
|
||||||
; CHECK: case_a = 819
|
; CHECK: case_a = 0.04998
|
||||||
case_a:
|
case_a:
|
||||||
br label %exit
|
br label %exit
|
||||||
|
|
||||||
; CHECK: case_b = 819
|
; CHECK: case_b = 0.04998
|
||||||
case_b:
|
case_b:
|
||||||
br label %exit
|
br label %exit
|
||||||
|
|
||||||
; The 'case_c' branch is predicted more likely via branch weight metadata.
|
; The 'case_c' branch is predicted more likely via branch weight metadata.
|
||||||
; CHECK: case_c = 13107
|
; CHECK: case_c = 0.79998
|
||||||
case_c:
|
case_c:
|
||||||
br label %exit
|
br label %exit
|
||||||
|
|
||||||
; CHECK: case_d = 819
|
; CHECK: case_d = 0.04998
|
||||||
case_d:
|
case_d:
|
||||||
br label %exit
|
br label %exit
|
||||||
|
|
||||||
; CHECK: case_e = 819
|
; CHECK: case_e = 0.04998
|
||||||
case_e:
|
case_e:
|
||||||
br label %exit
|
br label %exit
|
||||||
|
|
||||||
; FIXME: It may be a bug that we don't sum back to 16384.
|
; FIXME: It may be a bug that we don't sum back to 1.0.
|
||||||
; CHECK: exit = 16383
|
; CHECK: exit = 0.99993
|
||||||
exit:
|
exit:
|
||||||
%result = phi i32 [ %a, %case_a ],
|
%result = phi i32 [ %a, %case_a ],
|
||||||
[ %b, %case_b ],
|
[ %b, %case_b ],
|
||||||
|
Loading…
Reference in New Issue
Block a user