Skip to content

Commit

Permalink
Profile: Remove an inefficient and unnecessary API function
Browse files Browse the repository at this point in the history
This was leftover from an approach I abandoned, but I forgot to update
it before committing.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@203708 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
bogner committed Mar 12, 2014
1 parent 230eda4 commit f3e1756
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 27 deletions.
6 changes: 2 additions & 4 deletions include/llvm/Profile/ProfileDataReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,8 @@ class ProfileDataReader {
/// Fill Counts with the profile data for the given function name.
error_code getFunctionCounts(StringRef FuncName, uint64_t &FunctionHash,
std::vector<uint64_t> &Counts);
/// Get the frequency with which a function is called relative to the function
/// that is called most often in the program.
error_code getCallFrequency(StringRef FuncName, uint64_t &FunctionHash,
double &F);
/// Return the maximum of all known function counts.
uint64_t getMaximumFunctionCount() { return MaxFunctionCount; }

static error_code create(std::string Path,
std::unique_ptr<ProfileDataReader> &Result);
Expand Down
16 changes: 0 additions & 16 deletions lib/Profile/ProfileDataReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,19 +165,3 @@ error_code ProfileDataReader::getFunctionCounts(StringRef FuncName,

return profiledata_error::success;
}

error_code ProfileDataReader::getCallFrequency(StringRef FuncName,
uint64_t &FunctionHash,
double &Frequency) {
ProfileDataCursor Cursor(DataBuffer.get());
error_code EC;
if ((EC = findFunctionCounts(FuncName, FunctionHash, Cursor)))
return EC;
if ((EC = Cursor.skip64()))
return EC;
uint64_t CallCount;
if ((EC = Cursor.read64(CallCount)))
return EC;
Frequency = CallCount / (double)MaxFunctionCount;
return profiledata_error::success;
}
14 changes: 7 additions & 7 deletions tools/llvm-profdata/llvm-profdata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,31 +171,31 @@ int show_main(int argc, const char *argv[]) {
if (ShowAllFunctions && !ShowFunction.empty())
errs() << "warning: -function argument ignored: showing all functions\n";

uint64_t MaxBlockCount = 0, MaxFunctionCount = 0;
uint64_t MaxFunctionCount = Reader->getMaximumFunctionCount();

uint64_t MaxBlockCount = 0;
uint64_t Hash;
double CallFreq;
size_t ShownFunctions = false;
std::vector<uint64_t> Counts;
for (const auto &Name : *Reader) {
bool Show = ShowAllFunctions || Name.find(ShowFunction) != Name.npos;
if (error_code EC = Reader->getFunctionCounts(Name, Hash, Counts))
exitWithError(EC.message(), Filename);
if (error_code EC = Reader->getCallFrequency(Name, Hash, CallFreq))
exitWithError(EC.message(), Filename);

if (Show) {
double CallFreq = Counts[0] / (double)MaxFunctionCount;

if (!ShownFunctions)
OS << "Counters:\n";
++ShownFunctions;

OS << " " << Name << ":\n"
<< " Hash: " << HashPrinter(Hash) << "\n"
<< " Relative call frequency: " << FreqPrinter(CallFreq) << "\n"
<< " Counters: " << Counts.size() << "\n"
<< " Function count: " << Counts[0] << "\n";
}

if (Counts[0] > MaxFunctionCount)
MaxFunctionCount = Counts[0];

if (Show && ShowCounts)
OS << " Block counts: [";
for (size_t I = 1, E = Counts.size(); I < E; ++I) {
Expand Down

0 comments on commit f3e1756

Please sign in to comment.