@@ -454,56 +454,57 @@ bool ProfileGeneratorBase::collectFunctionsFromRawProfile(
454454 for (const auto &CI : *SampleCounters) {
455455 if (const auto *CtxKey = dyn_cast<AddrBasedCtxKey>(CI.first .getPtr ())) {
456456 for (auto StackAddr : CtxKey->Context ) {
457- uint64_t inc = Binary->addressIsCode (StackAddr) ? 1 : 0 ;
458- TotalStkAddr += inc ;
457+ uint64_t Inc = Binary->addressIsCode (StackAddr) ? 1 : 0 ;
458+ TotalStkAddr += Inc ;
459459 if (FuncRange *FRange = Binary->findFuncRange (StackAddr))
460460 ProfiledFunctions.insert (FRange->Func );
461461 else
462- ErrStkAddr += inc ;
462+ ErrStkAddr += Inc ;
463463 }
464464 }
465465
466466 for (auto Item : CI.second .RangeCounter ) {
467467 uint64_t StartAddress = Item.first .first ;
468- uint64_t inc = Binary->addressIsCode (StartAddress) ? 1 : 0 ;
469- TotalFuncRange += inc ;
468+ uint64_t Inc = Binary->addressIsCode (StartAddress) ? Item. second : 0 ;
469+ TotalFuncRange += Inc ;
470470 if (FuncRange *FRange = Binary->findFuncRange (StartAddress))
471471 ProfiledFunctions.insert (FRange->Func );
472472 else
473- ErrFuncRange += inc ;
473+ ErrFuncRange += Inc ;
474474 }
475475
476476 for (auto Item : CI.second .BranchCounter ) {
477477 uint64_t SourceAddress = Item.first .first ;
478478 uint64_t TargetAddress = Item.first .second ;
479- uint64_t srcinc = Binary->addressIsCode (SourceAddress) ? 1 : 0 ;
480- uint64_t tgtinc = Binary->addressIsCode (TargetAddress) ? 1 : 0 ;
481- TotalSrc += srcinc ;
479+ uint64_t SrcInc = Binary->addressIsCode (SourceAddress) ? Item. second : 0 ;
480+ uint64_t TgtInc = Binary->addressIsCode (TargetAddress) ? Item. second : 0 ;
481+ TotalSrc += SrcInc ;
482482 if (FuncRange *FRange = Binary->findFuncRange (SourceAddress))
483483 ProfiledFunctions.insert (FRange->Func );
484484 else
485- ErrSrc += srcinc ;
486- TotalTgt += tgtinc ;
485+ ErrSrc += SrcInc ;
486+ TotalTgt += TgtInc ;
487487 if (FuncRange *FRange = Binary->findFuncRange (TargetAddress))
488488 ProfiledFunctions.insert (FRange->Func );
489489 else
490- ErrTgt += tgtinc ;
490+ ErrTgt += TgtInc ;
491491 }
492492 }
493493
494494 if (ErrStkAddr)
495- WithColor::warning () << " Cannot find Stack Address from DWARF Info: "
496- << ErrStkAddr << " /" << TotalStkAddr << " missing\n " ;
495+ emitWarningSummary (
496+ ErrStkAddr, TotalStkAddr,
497+ " of stack address samples do not belong to any function" );
497498 if (ErrFuncRange)
498- WithColor::warning () << " Cannot find Function Range from DWARF Info: "
499- << ErrFuncRange << " / " << TotalFuncRange
500- << " missing \n " ;
499+ emitWarningSummary (
500+ ErrFuncRange, TotalFuncRange,
501+ " of function range samples do not belong to any function " ) ;
501502 if (ErrSrc)
502- WithColor::warning () << " Cannot find LBR Source Addr from DWARF Info: "
503- << ErrSrc << " / " << TotalSrc << " missing \n " ;
503+ emitWarningSummary (ErrSrc, TotalSrc,
504+ " of LBR source samples do not belong to any function " ) ;
504505 if (ErrTgt)
505- WithColor::warning () << " Cannot find LBR Target Addr from DWARF Info: "
506- << ErrTgt << " / " << TotalTgt << " missing \n " ;
506+ emitWarningSummary (ErrTgt, TotalTgt,
507+ " of LBR target samples do not belong to any function " ) ;
507508 return true ;
508509}
509510
0 commit comments