diff --git a/llvm/test/tools/llvm-profdata/compact-sample.proftext b/llvm/test/tools/llvm-profdata/compact-sample.proftext --- a/llvm/test/tools/llvm-profdata/compact-sample.proftext +++ b/llvm/test/tools/llvm-profdata/compact-sample.proftext @@ -1,8 +1,20 @@ # Make sure "llvm-profdata show" works for sample profile in binary compact format -# RUN: llvm-profdata show -sample %S/Inputs/compat-sample.profdata | FileCheck %s +# RUN: llvm-profdata show -sample %S/Inputs/compat-sample.profdata | FileCheck %s -# CHECK: Function: 15822663052811949562: 17, 0, 6 sampled lines +# CHECK: Function: 15822663052811949562: 17, 0, 6 sampled lines # CHECK-NEXT: Samples collected in the function's body { # CHECK: Samples collected in inlined callsites { # CHECK-NEXT: 1: inlined callee: 6309742469962978389: 17, 0, 1 + +# RUN: llvm-profdata show -hot-func-list -sample %S/Inputs/compat-sample.profdata | FileCheck %s --check-prefix=HOTFUNC +# HOTFUNC: 24753993 out of 24754010 profile counts (100.00%) are from hot functions. +# HOTFUNC: Total sample (%) Max sample Entry sample Function name +# HOTFUNC-NEXT: 24753993 (100.00%) 1284671 1284671 16429767378996342100 + +# Make sure "llvm-profdata overlap" works for sample profile in binary compact format +# RUN: llvm-profdata overlap -sample %S/Inputs/compat-sample.profdata %S/Inputs/compat-sample.profdata | FileCheck %s --check-prefix=OVERLAP + +# OVERLAP: Program level: +# OVERLAP-NEXT: Whole program profile similarity: 100.000% +# OVERLAP-NEXT: Whole program sample overlap: 100.000% diff --git a/llvm/tools/llvm-profdata/llvm-profdata.cpp b/llvm/tools/llvm-profdata/llvm-profdata.cpp --- a/llvm/tools/llvm-profdata/llvm-profdata.cpp +++ b/llvm/tools/llvm-profdata/llvm-profdata.cpp @@ -1540,14 +1540,14 @@ StringMap BaseFuncProf; const auto &BaseProfiles = BaseReader->getProfiles(); for (const auto &BaseFunc : BaseProfiles) { - BaseFuncProf.try_emplace(BaseFunc.second.getFuncName(), &(BaseFunc.second)); + BaseFuncProf.try_emplace(BaseFunc.second.getName(), &(BaseFunc.second)); } ProfOverlap.UnionCount = BaseFuncProf.size(); const auto &TestProfiles = TestReader->getProfiles(); for (const auto &TestFunc : TestProfiles) { SampleOverlapStats FuncOverlap; - FuncOverlap.TestName = TestFunc.second.getFuncName(); + FuncOverlap.TestName = TestFunc.second.getName(); assert(TestStats.count(FuncOverlap.TestName) && "TestStats should have records for all functions in test profile " "except inlinees"); @@ -1574,7 +1574,7 @@ // Two functions match with each other. Compute function-level overlap and // aggregate them into profile-level overlap. - FuncOverlap.BaseName = Match->second->getFuncName(); + FuncOverlap.BaseName = Match->second->getName(); assert(BaseStats.count(FuncOverlap.BaseName) && "BaseStats should have records for all functions in base profile " "except inlinees"); @@ -1623,10 +1623,10 @@ // Traverse through functions in base profile but not in test profile. for (const auto &F : BaseFuncProf) { - assert(BaseStats.count(F.second->getFuncName()) && + assert(BaseStats.count(F.second->getName()) && "BaseStats should have records for all functions in base profile " "except inlinees"); - const FuncSampleStats &FuncStats = BaseStats[F.second->getFuncName()]; + const FuncSampleStats &FuncStats = BaseStats[F.second->getName()]; ++ProfOverlap.BaseUniqueCount; ProfOverlap.BaseUniqueSample += FuncStats.SampleSum; @@ -1657,7 +1657,7 @@ FuncSampleStats FuncStats; getFuncSampleStats(I.second, FuncStats, BaseHotThreshold); ProfOverlap.BaseSample += FuncStats.SampleSum; - BaseStats.try_emplace(I.second.getFuncName(), FuncStats); + BaseStats.try_emplace(I.second.getName(), FuncStats); } const auto &TestProf = TestReader->getProfiles(); @@ -1666,7 +1666,7 @@ FuncSampleStats FuncStats; getFuncSampleStats(I.second, FuncStats, TestHotThreshold); ProfOverlap.TestSample += FuncStats.SampleSum; - TestStats.try_emplace(I.second.getFuncName(), FuncStats); + TestStats.try_emplace(I.second.getName(), FuncStats); } ProfOverlap.BaseName = StringRef(BaseFilename); @@ -2297,9 +2297,9 @@ (ProfileTotalSample > 0) ? (Func.getTotalSamples() * 100.0) / ProfileTotalSample : 0; - PrintValues.emplace_back(HotFuncInfo( - Func.getFuncName(), Func.getTotalSamples(), TotalSamplePercent, - FuncPair.second.second, Func.getEntrySamples())); + PrintValues.emplace_back( + HotFuncInfo(Func.getName(), Func.getTotalSamples(), TotalSamplePercent, + FuncPair.second.second, Func.getEntrySamples())); } dumpHotFunctionList(ColumnTitle, ColumnOffset, PrintValues, HotFuncCount, Profiles.size(), HotFuncSample, ProfileTotalSample,