diff options
author | Teresa Johnson <tejohnson@google.com> | 2024-07-11 16:10:30 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-07-11 16:10:30 -0700 |
commit | 9f8205d9d8ddccd5c821c2a654805434706a43c2 (patch) | |
tree | 2340b0084eef97beb8caae47a757737d0ba0a1d3 /llvm/lib/Analysis/ModuleSummaryAnalysis.cpp | |
parent | 1cafde234865cdcd37311dcd77d3ef9a3e12f177 (diff) | |
download | llvm-9f8205d9d8ddccd5c821c2a654805434706a43c2.zip llvm-9f8205d9d8ddccd5c821c2a654805434706a43c2.tar.gz llvm-9f8205d9d8ddccd5c821c2a654805434706a43c2.tar.bz2 |
[MemProf] Track and report profiled sizes through cloning (#98382)
If requested, via the -memprof-report-hinted-sizes option, track the
total profiled size of each MIB through the thin link, then report on
the corresponding allocation coldness after all cloning is complete.
To save size, a different bitcode record type is used for the allocation
info when the option is specified, and the sizes are kept separate from
the MIBs in the index.
Diffstat (limited to 'llvm/lib/Analysis/ModuleSummaryAnalysis.cpp')
-rw-r--r-- | llvm/lib/Analysis/ModuleSummaryAnalysis.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp b/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp index 94ac048..e9490cc 100644 --- a/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp +++ b/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp @@ -85,6 +85,8 @@ extern cl::opt<bool> ScalePartialSampleProfileWorkingSetSize; extern cl::opt<unsigned> MaxNumVTableAnnotations; +extern cl::opt<bool> MemProfReportHintedSizes; + // Walk through the operands of a given User via worklist iteration and populate // the set of GlobalValue references encountered. Invoked either on an // Instruction or a GlobalVariable (which walks its initializer). @@ -517,6 +519,7 @@ static void computeFunctionSummary( auto *MemProfMD = I.getMetadata(LLVMContext::MD_memprof); if (MemProfMD) { std::vector<MIBInfo> MIBs; + std::vector<uint64_t> TotalSizes; for (auto &MDOp : MemProfMD->operands()) { auto *MIBMD = cast<const MDNode>(MDOp); MDNode *StackNode = getMIBStackNode(MIBMD); @@ -536,8 +539,17 @@ static void computeFunctionSummary( } MIBs.push_back( MIBInfo(getMIBAllocType(MIBMD), std::move(StackIdIndices))); + if (MemProfReportHintedSizes) { + auto TotalSize = getMIBTotalSize(MIBMD); + assert(TotalSize); + TotalSizes.push_back(TotalSize); + } } Allocs.push_back(AllocInfo(std::move(MIBs))); + if (MemProfReportHintedSizes) { + assert(Allocs.back().MIBs.size() == TotalSizes.size()); + Allocs.back().TotalSizes = std::move(TotalSizes); + } } else if (!InstCallsite.empty()) { SmallVector<unsigned> StackIdIndices; for (auto StackId : InstCallsite) |