diff options
author | Andreas Neustifter <astifter-llvm@gmx.at> | 2009-08-26 09:05:21 +0000 |
---|---|---|
committer | Andreas Neustifter <astifter-llvm@gmx.at> | 2009-08-26 09:05:21 +0000 |
commit | 30457f2cab0bf62d1d1d144028c8b03965aee2ef (patch) | |
tree | fee6f7052d691acfb354f8496376786b5cd516a4 /tools/llvm-prof | |
parent | 824598883513789516a919651f4b35e7a638ec5c (diff) |
Changed std::cout to outs(), retaining formating.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80076 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/llvm-prof')
-rw-r--r-- | tools/llvm-prof/llvm-prof.cpp | 54 |
1 files changed, 27 insertions, 27 deletions
diff --git a/tools/llvm-prof/llvm-prof.cpp b/tools/llvm-prof/llvm-prof.cpp index 4110370f3bc..f1d24f7527c 100644 --- a/tools/llvm-prof/llvm-prof.cpp +++ b/tools/llvm-prof/llvm-prof.cpp @@ -27,6 +27,7 @@ #include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/PrettyStackTrace.h" #include "llvm/Support/raw_ostream.h" +#include "llvm/Support/Format.h" #include "llvm/System/Signals.h" #include <algorithm> #include <iostream> @@ -172,32 +173,32 @@ bool ProfileInfoPrinterPass::runOnModule(Module &M) { for (unsigned i = 0, e = FunctionCounts.size(); i != e; ++i) TotalExecutions += FunctionCounts[i].second; - std::cout << "===" << std::string(73, '-') << "===\n" - << "LLVM profiling output for execution"; - if (PIL.getNumExecutions() != 1) std::cout << "s"; - std::cout << ":\n"; + outs() << "===" << std::string(73, '-') << "===\n" + << "LLVM profiling output for execution"; + if (PIL.getNumExecutions() != 1) outs() << "s"; + outs() << ":\n"; for (unsigned i = 0, e = PIL.getNumExecutions(); i != e; ++i) { - std::cout << " "; - if (e != 1) std::cout << i+1 << ". "; - std::cout << PIL.getExecution(i) << "\n"; + outs() << " "; + if (e != 1) outs() << i+1 << ". "; + outs() << PIL.getExecution(i) << "\n"; } - std::cout << "\n===" << std::string(73, '-') << "===\n"; - std::cout << "Function execution frequencies:\n\n"; + outs() << "\n===" << std::string(73, '-') << "===\n"; + outs() << "Function execution frequencies:\n\n"; // Print out the function frequencies... - std::cout << " ## Frequency\n"; + outs() << " ## Frequency\n"; for (unsigned i = 0, e = FunctionCounts.size(); i != e; ++i) { if (FunctionCounts[i].second == 0) { - std::cout << "\n NOTE: " << e-i << " function" << - (e-i-1 ? "s were" : " was") << " never executed!\n"; + outs() << "\n NOTE: " << e-i << " function" + << (e-i-1 ? "s were" : " was") << " never executed!\n"; break; } - std::cout << std::setw(3) << i+1 << ". " - << std::setw(5) << FunctionCounts[i].second << "/" - << TotalExecutions << " " + outs() << format("%3d", i+1) << ". " + << format("%5.2g", FunctionCounts[i].second) << "/" + << format("%g", TotalExecutions) << " " << FunctionCounts[i].first->getNameStr() << "\n"; } @@ -211,29 +212,28 @@ bool ProfileInfoPrinterPass::runOnModule(Module &M) { sort(Counts.begin(), Counts.end(), PairSecondSortReverse<BasicBlock*>()); - std::cout << "\n===" << std::string(73, '-') << "===\n"; - std::cout << "Top 20 most frequently executed basic blocks:\n\n"; + outs() << "\n===" << std::string(73, '-') << "===\n"; + outs() << "Top 20 most frequently executed basic blocks:\n\n"; // Print out the function frequencies... - std::cout <<" ## %% \tFrequency\n"; + outs() <<" ## %% \tFrequency\n"; unsigned BlocksToPrint = Counts.size(); if (BlocksToPrint > 20) BlocksToPrint = 20; for (unsigned i = 0; i != BlocksToPrint; ++i) { if (Counts[i].second == 0) break; Function *F = Counts[i].first->getParent(); - std::cout << std::setw(3) << i+1 << ". " - << std::setw(5) << std::setprecision(3) - << Counts[i].second/(double)TotalExecutions*100 << "% " - << std::setw(5) << Counts[i].second << "/" - << TotalExecutions << "\t" - << F->getNameStr() << "() - " - << Counts[i].first->getNameStr() << "\n"; + outs() << format("%3d", i+1) << ". " + << format("%5g", Counts[i].second/(double)TotalExecutions*100) << "% " + << format("%5.0f", Counts[i].second) << "/" + << format("%g", TotalExecutions) << "\t" + << F->getNameStr() << "() - " + << Counts[i].first->getNameStr() << "\n"; FunctionsToPrint.insert(F); } if (PrintAnnotatedLLVM || PrintAllCode) { - std::cout << "\n===" << std::string(73, '-') << "===\n"; - std::cout << "Annotated LLVM code for the module:\n\n"; + outs() << "\n===" << std::string(73, '-') << "===\n"; + outs() << "Annotated LLVM code for the module:\n\n"; ProfileAnnotator PA(PI); |