-// getFunctionCounts - This method is used by consumers of function counting
-// information. If we do not directly have function count information, we
-// compute it from other, more refined, types of profile information.
-//
-void ProfileInfoLoader::getFunctionCounts(std::vector<std::pair<Function*,
- unsigned> > &Counts) {
- if (FunctionCounts.empty()) {
- // Synthesize function frequency information from the number of times their
- // entry blocks were executed.
- std::vector<std::pair<BasicBlock*, unsigned> > BlockCounts;
- getBlockCounts(BlockCounts);
-
- for (unsigned i = 0, e = BlockCounts.size(); i != e; ++i)
- if (&BlockCounts[i].first->getParent()->front() == BlockCounts[i].first)
- Counts.push_back(std::make_pair(BlockCounts[i].first->getParent(),
- BlockCounts[i].second));
- return;
- }
-
- unsigned Counter = 0;
- for (Module::iterator I = M.begin(), E = M.end();
- I != E && Counter != FunctionCounts.size(); ++I)
- if (!I->isExternal())
- Counts.push_back(std::make_pair(I, FunctionCounts[Counter++]));