Change dynostats dynamic instruction count policy

Summary:
Also add LOAD/STORE counters.

(cherry picked from FBD4732284)
This commit is contained in:
Rafael Auler 2017-03-17 10:32:56 -07:00 committed by Maksim Panchenko
parent b1ef186ca9
commit ad81bd6779
2 changed files with 9 additions and 9 deletions

View File

@ -3772,12 +3772,7 @@ DynoStats BinaryFunction::getDynoStats() const {
// frequencies. This may deviate from the sum of outgoing branches of the
// basic block especially since the block may contain a function that
// does not return or a function that throws an exception.
uint64_t BBExecutionCount = 0;
for (const auto &BI : BB->branch_info()) {
assert(BI.Count != BinaryBasicBlock::COUNT_NO_PROFILE &&
"unexpected empty profile");
BBExecutionCount += BI.Count;
}
const uint64_t BBExecutionCount = BB->getKnownExecutionCount();
// Ignore empty blocks and blocks that were not executed.
if (BB->getNumNonPseudos() == 0 || BBExecutionCount == 0)
@ -3785,6 +3780,12 @@ DynoStats BinaryFunction::getDynoStats() const {
// Count the number of calls by iterating through all instructions.
for (const auto &Instr : *BB) {
if (BC.MIA->isStore(Instr)) {
Stats[DynoStats::STORES] += BBExecutionCount;
}
if (BC.MIA->isLoad(Instr)) {
Stats[DynoStats::LOADS] += BBExecutionCount;
}
if (!BC.MIA->isCall(Instr))
continue;
Stats[DynoStats::FUNCTION_CALLS] += BBExecutionCount;
@ -3868,9 +3869,6 @@ DynoStats BinaryFunction::getDynoStats() const {
if (NonTakenCount == COUNT_NO_PROFILE)
NonTakenCount = 0;
assert(TakenCount + NonTakenCount == BBExecutionCount &&
"internal calculation error");
if (IsForwardBranch) {
Stats[DynoStats::FORWARD_COND_BRANCHES] += BBExecutionCount;
Stats[DynoStats::FORWARD_COND_BRANCHES_TAKEN] += TakenCount;

View File

@ -69,6 +69,8 @@ class DynoStats {
D(INDIRECT_CALLS, "indirect calls", Fn)\
D(PLT_CALLS, "PLT calls", Fn)\
D(INSTRUCTIONS, "executed instructions", Fn)\
D(LOADS, "executed load instructions", Fn)\
D(STORES, "executed store instructions", Fn)\
D(JUMP_TABLE_BRANCHES, "taken jump table branches", Fn)\
D(ALL_BRANCHES, "total branches",\
Fadd(ALL_CONDITIONAL, UNCOND_BRANCHES))\