[perf2bolt] Option to use event PC with LBR stack

Summary:
Add an option to get extra profile trace using the recorded event PC.
The trace goes from the latest LBR record destination to the event PC.

(cherry picked from FBD15711804)
This commit is contained in:
Maksim Panchenko 2019-06-06 19:38:06 -07:00
parent fac6a89c23
commit 9df5063c0e
1 changed files with 13 additions and 6 deletions

View File

@ -96,6 +96,13 @@ TimeAggregator("time-aggr",
cl::ZeroOrMore,
cl::cat(AggregatorCategory));
static cl::opt<bool>
UseEventPC("use-event-pc",
cl::desc("use event PC in combination with LBR sampling"),
cl::init(false),
cl::ZeroOrMore,
cl::cat(AggregatorCategory));
static cl::opt<bool>
WriteAutoFDOData("autofdo",
cl::desc("generate autofdo textual data instead of bolt data"),
@ -1168,14 +1175,14 @@ std::error_code DataAggregator::parseBranchEvents() {
NumEntries += Sample.LBR.size();
// LBRs are stored in reverse execution order. NextLBR refers to the next
// executed branch record.
const LBREntry *NextLBR{nullptr};
// LBRs are stored in reverse execution order. NextPC refers to the next
// recorded executed PC.
uint64_t NextPC = opts::UseEventPC ? Sample.PC : 0;
for (const auto &LBR : Sample.LBR) {
if (NextLBR) {
if (NextPC) {
// Record fall-through trace.
const auto TraceFrom = LBR.To;
const auto TraceTo = NextLBR->From;
const auto TraceTo = NextPC;
const auto *TraceBF = getBinaryFunctionContainingAddress(TraceFrom);
if (TraceBF && TraceBF->containsAddress(TraceTo)) {
auto &Info = FallthroughLBRs[Trace(TraceFrom, TraceTo)];
@ -1216,7 +1223,7 @@ std::error_code DataAggregator::parseBranchEvents() {
}
++NumTraces;
}
NextLBR = &LBR;
NextPC = LBR.From;
auto From = LBR.From;
if (!getBinaryFunctionContainingAddress(From))