mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-21 02:24:22 +00:00
Profile: Remove an inefficient and unnecessary API function
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
This commit is contained in:
@ -79,10 +79,8 @@ public:
|
|||||||
/// Fill Counts with the profile data for the given function name.
|
/// Fill Counts with the profile data for the given function name.
|
||||||
error_code getFunctionCounts(StringRef FuncName, uint64_t &FunctionHash,
|
error_code getFunctionCounts(StringRef FuncName, uint64_t &FunctionHash,
|
||||||
std::vector<uint64_t> &Counts);
|
std::vector<uint64_t> &Counts);
|
||||||
/// Get the frequency with which a function is called relative to the function
|
/// Return the maximum of all known function counts.
|
||||||
/// that is called most often in the program.
|
uint64_t getMaximumFunctionCount() { return MaxFunctionCount; }
|
||||||
error_code getCallFrequency(StringRef FuncName, uint64_t &FunctionHash,
|
|
||||||
double &F);
|
|
||||||
|
|
||||||
static error_code create(std::string Path,
|
static error_code create(std::string Path,
|
||||||
std::unique_ptr<ProfileDataReader> &Result);
|
std::unique_ptr<ProfileDataReader> &Result);
|
||||||
|
@ -165,19 +165,3 @@ error_code ProfileDataReader::getFunctionCounts(StringRef FuncName,
|
|||||||
|
|
||||||
return profiledata_error::success;
|
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;
|
|
||||||
}
|
|
||||||
|
@ -171,21 +171,24 @@ int show_main(int argc, const char *argv[]) {
|
|||||||
if (ShowAllFunctions && !ShowFunction.empty())
|
if (ShowAllFunctions && !ShowFunction.empty())
|
||||||
errs() << "warning: -function argument ignored: showing all functions\n";
|
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;
|
uint64_t Hash;
|
||||||
double CallFreq;
|
|
||||||
size_t ShownFunctions = false;
|
size_t ShownFunctions = false;
|
||||||
std::vector<uint64_t> Counts;
|
std::vector<uint64_t> Counts;
|
||||||
for (const auto &Name : *Reader) {
|
for (const auto &Name : *Reader) {
|
||||||
bool Show = ShowAllFunctions || Name.find(ShowFunction) != Name.npos;
|
bool Show = ShowAllFunctions || Name.find(ShowFunction) != Name.npos;
|
||||||
if (error_code EC = Reader->getFunctionCounts(Name, Hash, Counts))
|
if (error_code EC = Reader->getFunctionCounts(Name, Hash, Counts))
|
||||||
exitWithError(EC.message(), Filename);
|
exitWithError(EC.message(), Filename);
|
||||||
if (error_code EC = Reader->getCallFrequency(Name, Hash, CallFreq))
|
|
||||||
exitWithError(EC.message(), Filename);
|
|
||||||
if (Show) {
|
if (Show) {
|
||||||
|
double CallFreq = Counts[0] / (double)MaxFunctionCount;
|
||||||
|
|
||||||
if (!ShownFunctions)
|
if (!ShownFunctions)
|
||||||
OS << "Counters:\n";
|
OS << "Counters:\n";
|
||||||
++ShownFunctions;
|
++ShownFunctions;
|
||||||
|
|
||||||
OS << " " << Name << ":\n"
|
OS << " " << Name << ":\n"
|
||||||
<< " Hash: " << HashPrinter(Hash) << "\n"
|
<< " Hash: " << HashPrinter(Hash) << "\n"
|
||||||
<< " Relative call frequency: " << FreqPrinter(CallFreq) << "\n"
|
<< " Relative call frequency: " << FreqPrinter(CallFreq) << "\n"
|
||||||
@ -193,9 +196,6 @@ int show_main(int argc, const char *argv[]) {
|
|||||||
<< " Function count: " << Counts[0] << "\n";
|
<< " Function count: " << Counts[0] << "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Counts[0] > MaxFunctionCount)
|
|
||||||
MaxFunctionCount = Counts[0];
|
|
||||||
|
|
||||||
if (Show && ShowCounts)
|
if (Show && ShowCounts)
|
||||||
OS << " Block counts: [";
|
OS << " Block counts: [";
|
||||||
for (size_t I = 1, E = Counts.size(); I < E; ++I) {
|
for (size_t I = 1, E = Counts.size(); I < E; ++I) {
|
||||||
|
Reference in New Issue
Block a user