summaryrefslogtreecommitdiff
path: root/lib/Support/BlockFrequency.cpp
diff options
context:
space:
mode:
authorJakob Stoklund Olesen <stoklund@2pi.dk>2013-06-25 21:57:38 +0000
committerJakob Stoklund Olesen <stoklund@2pi.dk>2013-06-25 21:57:38 +0000
commitb1c0cc22dd5854a77e5699e80ce37545315b98ed (patch)
tree4c8275ab3a169fca79bdabf2cc12c9957118c610 /lib/Support/BlockFrequency.cpp
parent5e48a0e9ae2365a130dd1ec2e0b4beb337ab79e0 (diff)
downloadllvm-b1c0cc22dd5854a77e5699e80ce37545315b98ed.tar.gz
llvm-b1c0cc22dd5854a77e5699e80ce37545315b98ed.tar.bz2
llvm-b1c0cc22dd5854a77e5699e80ce37545315b98ed.tar.xz
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
Diffstat (limited to 'lib/Support/BlockFrequency.cpp')
-rw-r--r--lib/Support/BlockFrequency.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/Support/BlockFrequency.cpp b/lib/Support/BlockFrequency.cpp
index 84a993e3e5..572dbf5765 100644
--- a/lib/Support/BlockFrequency.cpp
+++ b/lib/Support/BlockFrequency.cpp
@@ -117,7 +117,16 @@ BlockFrequency::operator+(const BlockFrequency &Prob) 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 {