Print branch probabilities as percentages.
authorBenjamin Kramer <benny.kra@googlemail.com>
Sun, 23 Oct 2011 11:32:54 +0000 (11:32 +0000)
committerBenjamin Kramer <benny.kra@googlemail.com>
Sun, 23 Oct 2011 11:32:54 +0000 (11:32 +0000)
50% is much more readable than 5.000000e-01.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@142752 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Support/BranchProbability.cpp

index 5a5e07583d90beb308edbe401c50dac32aa5abf6..e8b83e59802d167ef45f0d80d612786803e7c1fe 100644 (file)
 
 #include "llvm/Support/BranchProbability.h"
 #include "llvm/Support/Debug.h"
+#include "llvm/Support/Format.h"
 #include "llvm/Support/raw_ostream.h"
 
 using namespace llvm;
 
 void BranchProbability::print(raw_ostream &OS) const {
-  OS << N << " / " << D << " = " << ((double)N / D);
+  OS << N << " / " << D << " = " << format("%g%%", ((double)N / D) * 100.0);
 }
 
 void BranchProbability::dump() const {
-  print(dbgs());
-  dbgs() << "\n";
+  dbgs() << *this << '\n';
 }
 
 namespace llvm {