@@ -827,13 +827,8 @@ bool DataAggregator::doTrace(const LBREntry &First, const LBREntry &Second,
827827 << FromFunc->getPrintName () << " :"
828828 << Twine::utohexstr (First.To ) << " to "
829829 << Twine::utohexstr (Second.From ) << " .\n " );
830- for (auto [From, To] : *FTs) {
831- if (BAT) {
832- From = BAT->translate (FromFunc->getAddress (), From, /* IsBranchSrc=*/ true );
833- To = BAT->translate (FromFunc->getAddress (), To, /* IsBranchSrc=*/ false );
834- }
830+ for (auto [From, To] : *FTs)
835831 doIntraBranch (*ParentFunc, From, To, Count, false );
836- }
837832
838833 return true ;
839834}
@@ -972,7 +967,7 @@ bool DataAggregator::recordExit(BinaryFunction &BF, uint64_t From, bool Mispred,
972967 return true ;
973968}
974969
975- ErrorOr<LBREntry> DataAggregator::parseLBREntry () {
970+ ErrorOr<DataAggregator:: LBREntry> DataAggregator::parseLBREntry () {
976971 LBREntry Res;
977972 ErrorOr<StringRef> FromStrRes = parseString (' /' );
978973 if (std::error_code EC = FromStrRes.getError ())
@@ -1430,54 +1425,16 @@ void DataAggregator::parseLBRSample(const PerfBranchSample &Sample,
14301425 const uint64_t TraceTo = NextLBR->From ;
14311426 const BinaryFunction *TraceBF =
14321427 getBinaryFunctionContainingAddress (TraceFrom);
1433- if (opts::HeatmapMode == opts::HeatmapModeKind::HM_Exclusive) {
1434- FTInfo &Info = FallthroughLBRs[ Trace (TraceFrom, TraceTo)];
1428+ FTInfo &Info = FallthroughLBRs[ Trace (TraceFrom, TraceTo)];
1429+ if (TraceBF-> containsAddress (LBR. From ))
14351430 ++Info.InternCount ;
1436- } else if (TraceBF && TraceBF->containsAddress (TraceTo)) {
1437- FTInfo &Info = FallthroughLBRs[Trace (TraceFrom, TraceTo)];
1438- if (TraceBF->containsAddress (LBR.From ))
1439- ++Info.InternCount ;
1440- else
1441- ++Info.ExternCount ;
1442- } else {
1443- const BinaryFunction *ToFunc =
1444- getBinaryFunctionContainingAddress (TraceTo);
1445- if (TraceBF && ToFunc) {
1446- LLVM_DEBUG ({
1447- dbgs () << " Invalid trace starting in " << TraceBF->getPrintName ()
1448- << formatv (" @ {0:x}" , TraceFrom - TraceBF->getAddress ())
1449- << formatv (" and ending @ {0:x}\n " , TraceTo);
1450- });
1451- ++NumInvalidTraces;
1452- } else {
1453- LLVM_DEBUG ({
1454- dbgs () << " Out of range trace starting in "
1455- << (TraceBF ? TraceBF->getPrintName () : " None" )
1456- << formatv (" @ {0:x}" ,
1457- TraceFrom - (TraceBF ? TraceBF->getAddress () : 0 ))
1458- << " and ending in "
1459- << (ToFunc ? ToFunc->getPrintName () : " None" )
1460- << formatv (" @ {0:x}\n " ,
1461- TraceTo - (ToFunc ? ToFunc->getAddress () : 0 ));
1462- });
1463- ++NumLongRangeTraces;
1464- }
1465- }
1431+ else
1432+ ++Info.ExternCount ;
14661433 ++NumTraces;
14671434 }
14681435 NextLBR = &LBR;
14691436
1470- // Record branches outside binary functions for heatmap.
1471- if (opts::HeatmapMode == opts::HeatmapModeKind::HM_Exclusive) {
1472- TakenBranchInfo &Info = BranchLBRs[Trace (LBR.From , LBR.To )];
1473- ++Info.TakenCount ;
1474- continue ;
1475- }
1476- uint64_t From = getBinaryFunctionContainingAddress (LBR.From ) ? LBR.From : 0 ;
1477- uint64_t To = getBinaryFunctionContainingAddress (LBR.To ) ? LBR.To : 0 ;
1478- if (!From && !To)
1479- continue ;
1480- TakenBranchInfo &Info = BranchLBRs[Trace (From, To)];
1437+ TakenBranchInfo &Info = BranchLBRs[Trace (LBR.From , LBR.To )];
14811438 ++Info.TakenCount ;
14821439 Info.MispredCount += LBR.Mispred ;
14831440 }
@@ -2289,6 +2246,7 @@ std::error_code DataAggregator::writeBATYAML(BinaryContext &BC,
22892246 YamlBF.Id = BF->getFunctionNumber ();
22902247 YamlBF.Hash = BAT->getBFHash (FuncAddress);
22912248 YamlBF.ExecCount = BF->getKnownExecutionCount ();
2249+ YamlBF.ExternEntryCount = BF->getExternEntryCount ();
22922250 YamlBF.NumBasicBlocks = BAT->getNumBasicBlocks (FuncAddress);
22932251 const BoltAddressTranslation::BBHashMapTy &BlockMap =
22942252 BAT->getBBHashMap (FuncAddress);
@@ -2398,16 +2356,10 @@ std::error_code DataAggregator::writeBATYAML(BinaryContext &BC,
23982356
23992357void DataAggregator::dump () const { DataReader::dump (); }
24002358
2401- void DataAggregator::dump (const LBREntry &LBR) const {
2402- Diag << " From: " << Twine::utohexstr (LBR.From )
2403- << " To: " << Twine::utohexstr (LBR.To ) << " Mispred? " << LBR.Mispred
2404- << " \n " ;
2405- }
2406-
24072359void DataAggregator::dump (const PerfBranchSample &Sample) const {
24082360 Diag << " Sample LBR entries: " << Sample.LBR .size () << " \n " ;
24092361 for (const LBREntry &LBR : Sample.LBR )
2410- dump ( LBR) ;
2362+ Diag << LBR << ' \n ' ;
24112363}
24122364
24132365void DataAggregator::dump (const PerfMemSample &Sample) const {
0 commit comments