aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2009-08-08 17:43:09 +0000
committerDaniel Dunbar <daniel@zuster.org>2009-08-08 17:43:09 +0000
commitcaaa49336b47b542d7255a8455fbab2e14a20ec5 (patch)
tree076150196f25bc2b89d6799338abf9b1112bf62a /tools
parent3e0094d9694a27c9e925f789fa26e740dc445fbe (diff)
downloadexternal_llvm-caaa49336b47b542d7255a8455fbab2e14a20ec5.zip
external_llvm-caaa49336b47b542d7255a8455fbab2e14a20ec5.tar.gz
external_llvm-caaa49336b47b542d7255a8455fbab2e14a20ec5.tar.bz2
More ProfileInfo improvements.
- Part of optimal static profiling patch sequence by Andreas Neustifter. - Store edge, block, and function information separately for each functions (instead of in one giant map). - Return frequencies as double instead of int, and use a sentinel value for missing information. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@78477 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools')
-rw-r--r--tools/llvm-prof/llvm-prof.cpp35
1 files changed, 25 insertions, 10 deletions
diff --git a/tools/llvm-prof/llvm-prof.cpp b/tools/llvm-prof/llvm-prof.cpp
index d3971d3..6144fe5 100644
--- a/tools/llvm-prof/llvm-prof.cpp
+++ b/tools/llvm-prof/llvm-prof.cpp
@@ -66,6 +66,11 @@ struct PairSecondSortReverse
}
};
+static double ignoreMissing(double w) {
+ if (w == ProfileInfo::MissingValue) return 0;
+ return w;
+}
+
namespace {
class ProfileAnnotator : public AssemblyAnnotationWriter {
ProfileInfo &PI;
@@ -73,16 +78,24 @@ namespace {
ProfileAnnotator(ProfileInfo& pi) : PI(pi) {}
virtual void emitFunctionAnnot(const Function *F, raw_ostream &OS) {
- OS << ";;; %" << F->getName() << " called " << PI.getExecutionCount(F)
- << " times.\n;;;\n";
+ OS << ";;; %" << F->getName() << " called ";
+ double w = PI.getExecutionCount(F);
+ if (w == ProfileInfo::MissingValue)
+ OS << "(no value)";
+ else
+ OS << (unsigned)w;
+ OS << " times.\n;;;\n";
}
virtual void emitBasicBlockStartAnnot(const BasicBlock *BB,
raw_ostream &OS) {
- unsigned w = PI.getExecutionCount(BB);
- if (w != 0)
- OS << "\t;;; Basic block executed " << w << " times.\n";
+ double w = PI.getExecutionCount(BB);
+ if (w == ProfileInfo::MissingValue)
+ OS << "\t;;; (no value)\n";
else
- OS << "\t;;; Never executed!\n";
+ if (w != 0)
+ OS << "\t;;; Basic block executed " << w << " times.\n";
+ else
+ OS << "\t;;; Never executed!\n";
}
virtual void emitBasicBlockEndAnnot(const BasicBlock *BB, raw_ostream &OS) {
@@ -92,8 +105,8 @@ namespace {
const TerminatorInst *TI = BB->getTerminator();
for (unsigned s = 0, e = TI->getNumSuccessors(); s != e; ++s) {
BasicBlock* Succ = TI->getSuccessor(s);
- SuccCounts.push_back(std::make_pair(std::make_pair(BB,Succ),
- PI.getEdgeWeight(BB,Succ)));
+ double w = ignoreMissing(PI.getEdgeWeight(std::make_pair(BB,Succ)));
+ SuccCounts.push_back(std::make_pair(std::make_pair(BB,Succ), w));
}
if (!SuccCounts.empty()) {
OS << "\t;;; Out-edge counts:";
@@ -143,10 +156,12 @@ bool ProfileInfoPrinterPass::runOnModule(Module &M) {
std::vector<std::pair<BasicBlock*, unsigned> > Counts;
for (Module::iterator FI = M.begin(), FE = M.end(); FI != FE; ++FI) {
if (FI->isDeclaration()) continue;
- FunctionCounts.push_back(std::make_pair(FI,PI.getExecutionCount(FI)));
+ double w = ignoreMissing(PI.getExecutionCount(FI));
+ FunctionCounts.push_back(std::make_pair(FI,w));
for (Function::iterator BB = FI->begin(), BBE = FI->end();
BB != BBE; ++BB) {
- Counts.push_back(std::make_pair(BB,PI.getExecutionCount(BB)));
+ double w = ignoreMissing(PI.getExecutionCount(BB));
+ Counts.push_back(std::make_pair(BB,w));
}
}