diff options
author | Jakob Stoklund Olesen <stoklund@2pi.dk> | 2013-06-25 21:57:38 +0000 |
---|---|---|
committer | Jakob Stoklund Olesen <stoklund@2pi.dk> | 2013-06-25 21:57:38 +0000 |
commit | b1c0cc22dd5854a77e5699e80ce37545315b98ed (patch) | |
tree | 4c8275ab3a169fca79bdabf2cc12c9957118c610 /lib | |
parent | 5e48a0e9ae2365a130dd1ec2e0b4beb337ab79e0 (diff) | |
download | external_llvm-b1c0cc22dd5854a77e5699e80ce37545315b98ed.zip external_llvm-b1c0cc22dd5854a77e5699e80ce37545315b98ed.tar.gz external_llvm-b1c0cc22dd5854a77e5699e80ce37545315b98ed.tar.bz2 |
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')
-rw-r--r-- | lib/Support/BlockFrequency.cpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/Support/BlockFrequency.cpp b/lib/Support/BlockFrequency.cpp index 84a993e..572dbf5 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 { |