[llvm-profgen] Ignore stack samples before aggregation

With `ignore-stack-samples`, We can ignore the call stack before the samples aggregation which could reduce some redundant computations.

Reviewed By: hoy, wenlei

Differential Revision: https://reviews.llvm.org/D111577
This commit is contained in:
wlei 2021-10-11 13:40:22 -07:00
parent 4fcc0ac15e
commit ab5d65e685
1 changed files with 7 additions and 3 deletions

View File

@ -647,9 +647,13 @@ void HybridPerfReader::parseSample(TraceStream &TraceIt, uint64_t Count) {
if (!TraceIt.isAtEoF() && TraceIt.getCurrentLine().startswith(" 0x")) {
// Parsing LBR stack and populate into PerfSample.LBRStack
if (extractLBRStack(TraceIt, Sample->LBRStack)) {
// Canonicalize stack leaf to avoid 'random' IP from leaf frame skew LBR
// ranges
Sample->CallStack.front() = Sample->LBRStack[0].Target;
if (IgnoreStackSamples) {
Sample->CallStack.clear();
} else {
// Canonicalize stack leaf to avoid 'random' IP from leaf frame skew LBR
// ranges
Sample->CallStack.front() = Sample->LBRStack[0].Target;
}
// Record samples by aggregation
AggregatedSamples[Hashable<PerfSample>(Sample)] += Count;
}