[llvm-branch-commits] [llvm] [BOLT][NFCI] Skip validation in parseLBRSample (PR #143288)
via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Sat Jun 7 15:12:13 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-bolt
Author: Amir Ayupov (aaupov)
<details>
<summary>Changes</summary>
Parsed branches and fall-throughs are validated in `doBranch` and
`doTrace` respectively. Simplify parseLBRSample by omitting the
validation. This also speeds up perf data processing as checks are only
done once for aggregated branches/fall-throughs and not individual LBR
entries.
Test Plan: NFC
---
Full diff: https://github.com/llvm/llvm-project/pull/143288.diff
1 Files Affected:
- (modified) bolt/lib/Profile/DataAggregator.cpp (+5-43)
``````````diff
diff --git a/bolt/lib/Profile/DataAggregator.cpp b/bolt/lib/Profile/DataAggregator.cpp
index b1172fd13bc72..addff196f4f5b 100644
--- a/bolt/lib/Profile/DataAggregator.cpp
+++ b/bolt/lib/Profile/DataAggregator.cpp
@@ -1425,54 +1425,16 @@ void DataAggregator::parseLBRSample(const PerfBranchSample &Sample,
const uint64_t TraceTo = NextLBR->From;
const BinaryFunction *TraceBF =
getBinaryFunctionContainingAddress(TraceFrom);
- if (opts::HeatmapMode == opts::HeatmapModeKind::HM_Exclusive) {
- FTInfo &Info = FallthroughLBRs[Trace(TraceFrom, TraceTo)];
+ FTInfo &Info = FallthroughLBRs[Trace(TraceFrom, TraceTo)];
+ if (TraceBF && TraceBF->containsAddress(LBR.From))
++Info.InternCount;
- } else if (TraceBF && TraceBF->containsAddress(TraceTo)) {
- FTInfo &Info = FallthroughLBRs[Trace(TraceFrom, TraceTo)];
- if (TraceBF->containsAddress(LBR.From))
- ++Info.InternCount;
- else
- ++Info.ExternCount;
- } else {
- const BinaryFunction *ToFunc =
- getBinaryFunctionContainingAddress(TraceTo);
- if (TraceBF && ToFunc) {
- LLVM_DEBUG({
- dbgs() << "Invalid trace starting in " << TraceBF->getPrintName()
- << formatv(" @ {0:x}", TraceFrom - TraceBF->getAddress())
- << formatv(" and ending @ {0:x}\n", TraceTo);
- });
- ++NumInvalidTraces;
- } else {
- LLVM_DEBUG({
- dbgs() << "Out of range trace starting in "
- << (TraceBF ? TraceBF->getPrintName() : "None")
- << formatv(" @ {0:x}",
- TraceFrom - (TraceBF ? TraceBF->getAddress() : 0))
- << " and ending in "
- << (ToFunc ? ToFunc->getPrintName() : "None")
- << formatv(" @ {0:x}\n",
- TraceTo - (ToFunc ? ToFunc->getAddress() : 0));
- });
- ++NumLongRangeTraces;
- }
- }
+ else
+ ++Info.ExternCount;
++NumTraces;
}
NextLBR = &LBR;
- // Record branches outside binary functions for heatmap.
- if (opts::HeatmapMode == opts::HeatmapModeKind::HM_Exclusive) {
- TakenBranchInfo &Info = BranchLBRs[Trace(LBR.From, LBR.To)];
- ++Info.TakenCount;
- continue;
- }
- uint64_t From = getBinaryFunctionContainingAddress(LBR.From) ? LBR.From : 0;
- uint64_t To = getBinaryFunctionContainingAddress(LBR.To) ? LBR.To : 0;
- if (!From && !To)
- continue;
- TakenBranchInfo &Info = BranchLBRs[Trace(From, To)];
+ TakenBranchInfo &Info = BranchLBRs[Trace(LBR.From, LBR.To)];
++Info.TakenCount;
Info.MispredCount += LBR.Mispred;
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/143288
More information about the llvm-branch-commits
mailing list