@@ -711,7 +711,7 @@ bool DataAggregator::doInterBranch(BinaryFunction *FromFunc,
711711}
712712
713713bool 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