Skip to content

Commit 426d44d

Browse files
aaupovJaddyen
authored andcommitted
[BOLT][NFC] Simplify doTrace in BAT mode (llvm#143233)
`BoltAddressTranslation::getFallthroughsInTrace` iterates over address translation map entries and therefore has direct access to both original and translated offsets. Return the translated offsets in fall-throughs list to avoid duplicate address translation inside `doTrace`. Test Plan: NFC
1 parent 625ef3e commit 426d44d

File tree

2 files changed

+3
-8
lines changed

2 files changed

+3
-8
lines changed

bolt/lib/Profile/BoltAddressTranslation.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,7 @@ BoltAddressTranslation::getFallthroughsInTrace(uint64_t FuncAddress,
546546
return Res;
547547

548548
for (auto Iter = FromIter; Iter != ToIter;) {
549-
const uint32_t Src = Iter->first;
549+
const uint32_t Src = Iter->second >> 1;
550550
if (Iter->second & BRANCHENTRY) {
551551
++Iter;
552552
continue;
@@ -557,7 +557,7 @@ BoltAddressTranslation::getFallthroughsInTrace(uint64_t FuncAddress,
557557
++Iter;
558558
if (Iter->second & BRANCHENTRY)
559559
break;
560-
Res.emplace_back(Src, Iter->first);
560+
Res.emplace_back(Src, Iter->second >> 1);
561561
}
562562

563563
return Res;

bolt/lib/Profile/DataAggregator.cpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -835,13 +835,8 @@ bool DataAggregator::doTrace(const Trace &Trace, uint64_t Count,
835835

836836
LLVM_DEBUG(dbgs() << "Processing " << FTs->size() << " fallthroughs for "
837837
<< FromFunc->getPrintName() << ":" << Trace << '\n');
838-
for (auto [From, To] : *FTs) {
839-
if (BAT) {
840-
From = BAT->translate(FromFunc->getAddress(), From, /*IsBranchSrc=*/true);
841-
To = BAT->translate(FromFunc->getAddress(), To, /*IsBranchSrc=*/false);
842-
}
838+
for (const auto &[From, To] : *FTs)
843839
doIntraBranch(*ParentFunc, From, To, Count, false);
844-
}
845840

846841
return true;
847842
}

0 commit comments

Comments
 (0)