Skip to content

Commit d796f36

Browse files
committed
[BOLT][NFC] Simplify DataAggregator
Use short loop instead of duplicating the code for setHasProfileAvailable. Reviewed By: #bolt, maksfb Differential Revision: https://reviews.llvm.org/D154749
1 parent 2a68213 commit d796f36

File tree

1 file changed

+7
-13
lines changed

1 file changed

+7
-13
lines changed

bolt/lib/Profile/DataAggregator.cpp

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1479,13 +1479,10 @@ std::error_code DataAggregator::parseBranchEvents() {
14791479
NumTraces += parseLBRSample(Sample, NeedsSkylakeFix);
14801480
}
14811481

1482-
for (const auto &LBR : BranchLBRs) {
1483-
const Trace &Trace = LBR.first;
1484-
if (BinaryFunction *BF = getBinaryFunctionContainingAddress(Trace.From))
1485-
BF->setHasProfileAvailable();
1486-
if (BinaryFunction *BF = getBinaryFunctionContainingAddress(Trace.To))
1487-
BF->setHasProfileAvailable();
1488-
}
1482+
for (const Trace &Trace : llvm::make_first_range(BranchLBRs))
1483+
for (const uint64_t Addr : {Trace.From, Trace.To})
1484+
if (BinaryFunction *BF = getBinaryFunctionContainingAddress(Addr))
1485+
BF->setHasProfileAvailable();
14891486

14901487
auto printColored = [](raw_ostream &OS, float Percent, float T1, float T2) {
14911488
OS << " (";
@@ -1721,12 +1718,9 @@ std::error_code DataAggregator::parsePreAggregatedLBRSamples() {
17211718
if (std::error_code EC = AggrEntry.getError())
17221719
return EC;
17231720

1724-
if (BinaryFunction *BF =
1725-
getBinaryFunctionContainingAddress(AggrEntry->From.Offset))
1726-
BF->setHasProfileAvailable();
1727-
if (BinaryFunction *BF =
1728-
getBinaryFunctionContainingAddress(AggrEntry->To.Offset))
1729-
BF->setHasProfileAvailable();
1721+
for (const uint64_t Addr : {AggrEntry->From.Offset, AggrEntry->To.Offset})
1722+
if (BinaryFunction *BF = getBinaryFunctionContainingAddress(Addr))
1723+
BF->setHasProfileAvailable();
17301724

17311725
AggregatedLBRs.emplace_back(std::move(AggrEntry.get()));
17321726
}

0 commit comments

Comments
 (0)