Skip to content

Commit e12e694

Browse files
committed
Fix
1 parent a19064d commit e12e694

File tree

3 files changed

+28
-28
lines changed

3 files changed

+28
-28
lines changed

llvm/include/llvm/ProfileData/SampleProf.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1214,19 +1214,18 @@ class FunctionSamples {
12141214
// Note the sequence of the suffixes in the knownSuffixes array matters.
12151215
// If suffix "A" is appended after the suffix "B", "A" should be in front
12161216
// of "B" in knownSuffixes.
1217-
SmallVector<StringRef> KnownSuffixes({LLVMSuffix, PartSuffix, UniqSuffix});
1217+
const char *KnownSuffixes[] = {LLVMSuffix, PartSuffix, UniqSuffix, nullptr};
12181218
return getCanonicalFnName(FnName, KnownSuffixes, Attr);
12191219
}
12201220

1221-
static StringRef getCanonicalFnName(StringRef FnName,
1222-
const SmallVector<StringRef> &Suffixes,
1221+
static StringRef getCanonicalFnName(StringRef FnName, const char *Suffixes[],
12231222
StringRef Attr = "selected") {
12241223
if (Attr == "" || Attr == "all")
12251224
return FnName.split('.').first;
12261225
if (Attr == "selected") {
12271226
StringRef Cand(FnName);
1228-
for (const auto &Suf : Suffixes) {
1229-
StringRef Suffix(Suf);
1227+
for (const char **Suf = Suffixes; *Suf; Suf++) {
1228+
StringRef Suffix(*Suf);
12301229
// If the profile contains ".__uniq." suffix, don't strip the
12311230
// suffix for names in the IR.
12321231
if (Suffix == UniqSuffix && FunctionSamples::HasUniqSuffix)

llvm/tools/llvm-profgen/ProfileGenerator.cpp

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -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

llvm/tools/llvm-profgen/ProfiledBinary.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -834,8 +834,8 @@ void ProfiledBinary::populateSymbolsFromBinary(const ObjectFile *Obj) {
834834
if (Size == 0 || Type != SymbolRef::ST_Function)
835835
continue;
836836

837-
SmallVector<StringRef> Suffixes(
838-
{".destroy", ".resume", ".llvm.", ".cold", ".warm"});
837+
const char *Suffixes[] = {".destroy", ".resume", ".llvm.",
838+
".cold", ".warm", nullptr};
839839
const StringRef SymName =
840840
FunctionSamples::getCanonicalFnName(Name, Suffixes);
841841

0 commit comments

Comments
 (0)