diff options
author | Chris Lattner <sabre@nondot.org> | 2003-10-28 21:25:23 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2003-10-28 21:25:23 +0000 |
commit | 33f1ca7d8a86ce4933e89ddb6671924b3ec03923 (patch) | |
tree | 0df9151c0b9f8b0e7f862c4895a216738c012285 /tools/llvm-prof/ProfileInfo.cpp | |
parent | b9e578934f903ff9bec7b19f9592a76f378ff0f7 (diff) | |
download | external_llvm-33f1ca7d8a86ce4933e89ddb6671924b3ec03923.tar.gz external_llvm-33f1ca7d8a86ce4933e89ddb6671924b3ec03923.tar.bz2 external_llvm-33f1ca7d8a86ce4933e89ddb6671924b3ec03923.zip |
Add support for reading block frequencies. Fix bug in attribution of counts
to functions
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@9559 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/llvm-prof/ProfileInfo.cpp')
-rw-r--r-- | tools/llvm-prof/ProfileInfo.cpp | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/tools/llvm-prof/ProfileInfo.cpp b/tools/llvm-prof/ProfileInfo.cpp index 2341db0bb9..4c31138aa3 100644 --- a/tools/llvm-prof/ProfileInfo.cpp +++ b/tools/llvm-prof/ProfileInfo.cpp @@ -148,7 +148,28 @@ void ProfileInfo::getFunctionCounts(std::vector<std::pair<Function*, unsigned Counter = 0; for (Module::iterator I = M.begin(), E = M.end(); - I != E && Counter != FunctionCounts.size(); ++I, ++Counter) + I != E && Counter != FunctionCounts.size(); ++I) if (!I->isExternal()) - Counts.push_back(std::make_pair(I, FunctionCounts[Counter])); + Counts.push_back(std::make_pair(I, FunctionCounts[Counter++])); +} + +// getBlockCounts - This method is used by consumers of block counting +// information. If we do not directly have block count information, we +// compute it from other, more refined, types of profile information. +// +void ProfileInfo::getBlockCounts(std::vector<std::pair<BasicBlock*, + unsigned> > &Counts) { + if (BlockCounts.empty()) { + std::cerr << "Block counts not available, and no synthesis " + << "is implemented yet!\n"; + return; + } + + unsigned Counter = 0; + for (Module::iterator F = M.begin(), E = M.end(); F != E; ++F) + for (Function::iterator BB = F->begin(), E = F->end(); BB != E; ++BB) { + Counts.push_back(std::make_pair(BB, BlockCounts[Counter++])); + if (Counter == BlockCounts.size()) + return; + } } |