Add PLT dyno stats.

Summary: Get PLT call stats.

(cherry picked from FBD3874799)
This commit is contained in:
Maksim Panchenko 2016-09-15 15:47:10 -07:00
parent c4e36c1dd6
commit 2c9bf9afd6
2 changed files with 15 additions and 0 deletions

View file

@ -2688,6 +2688,20 @@ DynoStats BinaryFunction::getDynoStats() const {
Stats[DynoStats::FUNCTION_CALLS] += BBExecutionCount;
if (BC.MIA->getMemoryOperandNo(Instr) != -1) {
Stats[DynoStats::INDIRECT_CALLS] += BBExecutionCount;
} else if (const auto *CallSymbol = BC.MIA->getTargetSymbol(Instr)) {
if (BC.getFunctionForSymbol(CallSymbol))
continue;
auto GSI = BC.GlobalSymbols.find(CallSymbol->getName());
if (GSI == BC.GlobalSymbols.end())
continue;
auto Section = BC.getSectionForAddress(GSI->second);
if (!Section)
continue;
StringRef SectionName;
Section->getName(SectionName);
if (SectionName == ".plt") {
Stats[DynoStats::PLT_CALLS] += BBExecutionCount;
}
}
}

View file

@ -64,6 +64,7 @@ class DynoStats {
D(UNCOND_BRANCHES, "executed unconditional branches", Fn)\
D(FUNCTION_CALLS, "all function calls", Fn)\
D(INDIRECT_CALLS, "indirect calls", Fn)\
D(PLT_CALLS, "PLT calls", Fn)\
D(INSTRUCTIONS, "executed instructions", Fn)\
D(JUMP_TABLE_BRANCHES, "taken jump table branches", Fn)\
D(ALL_BRANCHES, "total branches",\