diff --git a/bolt/BinaryFunction.cpp b/bolt/BinaryFunction.cpp index 57d1cd8cbbb3..4b7fa4644588 100644 --- a/bolt/BinaryFunction.cpp +++ b/bolt/BinaryFunction.cpp @@ -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; diff --git a/bolt/BinaryFunction.h b/bolt/BinaryFunction.h index e41e946db511..3aa6bc16f6ab 100644 --- a/bolt/BinaryFunction.h +++ b/bolt/BinaryFunction.h @@ -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))\