Skip to content

Commit e06744d

Browse files
committed
[𝘀𝗽𝗿] changes to main this commit is based on
Created using spr 1.3.4 [skip ci]
1 parent 1c207f1 commit e06744d

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

bolt/include/bolt/Profile/DataAggregator.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,10 @@ class DataAggregator : public DataReader {
197197

198198
BoltAddressTranslation *BAT{nullptr};
199199

200+
/// Whether pre-aggregated profile needs to convert branch profile into call
201+
/// to continuation fallthrough profile.
202+
bool NeedsConvertRetProfileToCallCont{false};
203+
200204
/// Update function execution profile with a recorded trace.
201205
/// A trace is region of code executed between two LBR entries supplied in
202206
/// execution order.
@@ -268,8 +272,7 @@ class DataAggregator : public DataReader {
268272
uint64_t Mispreds);
269273

270274
/// Register a \p Branch.
271-
bool doBranch(uint64_t From, uint64_t To, uint64_t Count, uint64_t Mispreds,
272-
bool IsPreagg);
275+
bool doBranch(uint64_t From, uint64_t To, uint64_t Count, uint64_t Mispreds);
273276

274277
/// Register a trace between two LBR entries supplied in execution order.
275278
bool doTrace(const LBREntry &First, const LBREntry &Second,

bolt/lib/Profile/DataAggregator.cpp

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -711,7 +711,7 @@ bool DataAggregator::doInterBranch(BinaryFunction *FromFunc,
711711
}
712712

713713
bool DataAggregator::doBranch(uint64_t From, uint64_t To, uint64_t Count,
714-
uint64_t Mispreds, bool IsPreagg) {
714+
uint64_t Mispreds) {
715715
// Returns whether \p Offset in \p Func contains a return instruction.
716716
auto checkReturn = [&](const BinaryFunction &Func, const uint64_t Offset) {
717717
auto isReturn = [&](auto MI) { return MI && BC->MIB->isReturn(*MI); };
@@ -772,7 +772,8 @@ bool DataAggregator::doBranch(uint64_t From, uint64_t To, uint64_t Count,
772772
return false;
773773

774774
// Record call to continuation trace.
775-
if (IsPreagg && FromFunc != ToFunc && (IsReturn || IsCallCont)) {
775+
if (NeedsConvertRetProfileToCallCont && FromFunc != ToFunc &&
776+
(IsReturn || IsCallCont)) {
776777
LBREntry First{ToOrig - 1, ToOrig - 1, false};
777778
LBREntry Second{ToOrig, ToOrig, false};
778779
return doTrace(First, Second, Count);
@@ -1224,12 +1225,17 @@ DataAggregator::parseAggregatedLBREntry() {
12241225
ErrorOr<StringRef> TypeOrErr = parseString(FieldSeparator);
12251226
if (std::error_code EC = TypeOrErr.getError())
12261227
return EC;
1228+
// Pre-aggregated profile with branches and fallthroughs needs to convert
1229+
// return profile into call to continuation fall-through.
12271230
auto Type = AggregatedLBREntry::BRANCH;
12281231
if (TypeOrErr.get() == "B") {
1232+
NeedsConvertRetProfileToCallCont = true;
12291233
Type = AggregatedLBREntry::BRANCH;
12301234
} else if (TypeOrErr.get() == "F") {
1235+
NeedsConvertRetProfileToCallCont = true;
12311236
Type = AggregatedLBREntry::FT;
12321237
} else if (TypeOrErr.get() == "f") {
1238+
NeedsConvertRetProfileToCallCont = true;
12331239
Type = AggregatedLBREntry::FT_EXTERNAL_ORIGIN;
12341240
} else {
12351241
reportError("expected B, F or f");
@@ -1585,8 +1591,7 @@ void DataAggregator::processBranchEvents() {
15851591
for (const auto &AggrLBR : BranchLBRs) {
15861592
const Trace &Loc = AggrLBR.first;
15871593
const TakenBranchInfo &Info = AggrLBR.second;
1588-
doBranch(Loc.From, Loc.To, Info.TakenCount, Info.MispredCount,
1589-
/*IsPreagg*/ false);
1594+
doBranch(Loc.From, Loc.To, Info.TakenCount, Info.MispredCount);
15901595
}
15911596
}
15921597

@@ -1747,7 +1752,7 @@ void DataAggregator::processPreAggregated() {
17471752
switch (AggrEntry.EntryType) {
17481753
case AggregatedLBREntry::BRANCH:
17491754
doBranch(AggrEntry.From.Offset, AggrEntry.To.Offset, AggrEntry.Count,
1750-
AggrEntry.Mispreds, /*IsPreagg*/ true);
1755+
AggrEntry.Mispreds);
17511756
break;
17521757
case AggregatedLBREntry::FT:
17531758
case AggregatedLBREntry::FT_EXTERNAL_ORIGIN: {

0 commit comments

Comments
 (0)