[llvm-branch-commits] [llvm] [llvm-profgen] Extend llvm-profgen to generate vtable profiles with data access events for non context-sensitive profiles using debug info (PR #148013)
Mingming Liu via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Tue Aug 26 10:52:37 PDT 2025
================
@@ -540,6 +540,22 @@ void ProfileGenerator::generateLineNumBasedProfile() {
// 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);
+ }
+ }
+
----------------
mingmingl-llvm wrote:
The environment issue is fixed (with a manual machine restart after some system maintenances..) , and I can collect LBR. https://github.com/llvm/llvm-project/pull/148013/commits/e58708972695a0300b0472298d5eb8819d0e2928#diff-22e592380f9deced00e432033744b4bbd34f8490b5aeb6f35356e95dd51c821a adds a context-sensitive perf script after running `llvm/test/tools/llvm-profgen/Inputs/dap.bin`, and verified that `llvm-profgen` reports error when it sees a context-sensitive script.
https://github.com/llvm/llvm-project/pull/148013
More information about the llvm-branch-commits
mailing list