diff options
Diffstat (limited to 'llvm/tools')
-rw-r--r-- | llvm/tools/llvm-profgen/ProfileGenerator.cpp | 44 | ||||
-rw-r--r-- | llvm/tools/llvm-profgen/ProfileGenerator.h | 2 | ||||
-rw-r--r-- | llvm/tools/llvm-profgen/llvm-profgen.cpp | 5 |
3 files changed, 29 insertions, 22 deletions
diff --git a/llvm/tools/llvm-profgen/ProfileGenerator.cpp b/llvm/tools/llvm-profgen/ProfileGenerator.cpp index ef66160..41ed191 100644 --- a/llvm/tools/llvm-profgen/ProfileGenerator.cpp +++ b/llvm/tools/llvm-profgen/ProfileGenerator.cpp @@ -539,22 +539,7 @@ void ProfileGenerator::generateLineNumBasedProfile() { populateBodySamplesForAllFunctions(SC.RangeCounter); // Fill in boundary sample counts as well as call site samples for calls populateBoundarySamplesForAllFunctions(SC.BranchCounter); - - // For each instruction with vtable accesses, get its symbolized inline - // stack, and add the vtable counters to the function samples. - for (const auto &[IpData, Count] : SC.DataAccessCounter) { - uint64_t InstAddr = IpData.first; - const SampleContextFrameVector &FrameVec = - Binary->getCachedFrameLocationStack(InstAddr, false); - if (!FrameVec.empty()) { - FunctionSamples &FunctionProfile = - getLeafProfileAndAddTotalSamples(FrameVec, 0); - LineLocation Loc( - FrameVec.back().Location.LineOffset, - getBaseDiscriminator(FrameVec.back().Location.Discriminator)); - FunctionProfile.addTypeSamplesAt(Loc, FunctionId(IpData.second), Count); - } - } + populateTypeSamplesForAllFunctions(SC.DataAccessCounter); updateFunctionSamples(); } @@ -621,8 +606,8 @@ void ProfileGenerator::populateBoundarySamplesWithProbesForAllFunctions( getLeafProfileAndAddTotalSamples(FrameVec, 0); FunctionProfile.addCalledTargetSamples( FrameVec.back().Location.LineOffset, - FrameVec.back().Location.Discriminator, - FunctionId(CalleeName), Count); + FrameVec.back().Location.Discriminator, FunctionId(CalleeName), + Count); } } } @@ -645,8 +630,7 @@ FunctionSamples &ProfileGenerator::getLeafProfileAndAddTotalSamples( getBaseDiscriminator(FrameVec[I - 1].Location.Discriminator)); FunctionSamplesMap &SamplesMap = FunctionProfile->functionSamplesAt(Callsite); - auto Ret = - SamplesMap.emplace(FrameVec[I].Func, FunctionSamples()); + auto Ret = SamplesMap.emplace(FrameVec[I].Func, FunctionSamples()); if (Ret.second) { SampleContext Context(FrameVec[I].Func); Ret.first->second.setContext(Context); @@ -761,6 +745,26 @@ void ProfileGenerator::populateBoundarySamplesForAllFunctions( } } +void ProfileGenerator::populateTypeSamplesForAllFunctions( + const DataAccessSample &DataAccessSamples) { + // For each instruction with vtable accesses, get its symbolized inline + // stack, and add the vtable counters to the function samples. + for (const auto &[IpData, Count] : DataAccessSamples) { + uint64_t InstAddr = IpData.first; + const SampleContextFrameVector &FrameVec = + Binary->getCachedFrameLocationStack(InstAddr, + /* UseProbeDiscriminator=*/false); + if (!FrameVec.empty()) { + FunctionSamples &FunctionProfile = + getLeafProfileAndAddTotalSamples(FrameVec, 0); + LineLocation Loc( + FrameVec.back().Location.LineOffset, + getBaseDiscriminator(FrameVec.back().Location.Discriminator)); + FunctionProfile.addTypeSamplesAt(Loc, FunctionId(IpData.second), Count); + } + } +} + void ProfileGeneratorBase::calculateBodySamplesAndSize( const FunctionSamples &FSamples, uint64_t &TotalBodySamples, uint64_t &FuncBodySize) { diff --git a/llvm/tools/llvm-profgen/ProfileGenerator.h b/llvm/tools/llvm-profgen/ProfileGenerator.h index 5e361285..bafdc18 100644 --- a/llvm/tools/llvm-profgen/ProfileGenerator.h +++ b/llvm/tools/llvm-profgen/ProfileGenerator.h @@ -182,6 +182,8 @@ private: populateBodySamplesWithProbesForAllFunctions(const RangeSample &RangeCounter); void populateBoundarySamplesWithProbesForAllFunctions( const BranchSample &BranchCounters); + void + populateTypeSamplesForAllFunctions(const DataAccessSample &DataAccessSamples); void postProcessProfiles(); void trimColdProfiles(const SampleProfileMap &Profiles, uint64_t ColdCntThreshold); diff --git a/llvm/tools/llvm-profgen/llvm-profgen.cpp b/llvm/tools/llvm-profgen/llvm-profgen.cpp index 7924844..d36e29e 100644 --- a/llvm/tools/llvm-profgen/llvm-profgen.cpp +++ b/llvm/tools/llvm-profgen/llvm-profgen.cpp @@ -68,8 +68,9 @@ static cl::opt<std::string> DebugBinPath( cl::cat(ProfGenCategory)); static cl::opt<std::string> DataAccessProfileFilename( - "data-access-profile", cl::value_desc("data-access-profile"), - cl::desc("Path to the data access profile to be generated."), + "data-access-perftrace", cl::value_desc("data-access-perftrace"), + cl::desc("File path of a Linux perf raw trace (generated by `perf report " + "-D`) consisting of memory access events."), cl::cat(ProfGenCategory)); extern cl::opt<bool> ShowDisassemblyOnly; |