diff options
author | Teresa Johnson <tejohnson@google.com> | 2025-06-04 13:08:56 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-06-04 13:08:56 -0700 |
commit | 3ec2de2753388c83fa31bb65f0583aed625a2b32 (patch) | |
tree | b955fac97c03c4b815a4e490fe88a86583f2660d /llvm/lib/Bitcode/Reader/BitcodeReader.cpp | |
parent | e0909003ff9d8b1606fb76b25bf779443d086b3c (diff) | |
download | llvm-3ec2de2753388c83fa31bb65f0583aed625a2b32.zip llvm-3ec2de2753388c83fa31bb65f0583aed625a2b32.tar.gz llvm-3ec2de2753388c83fa31bb65f0583aed625a2b32.tar.bz2 |
[MemProf] Optionally save context size info on largest cold allocations (#142837)
Reapply PR142507 with fix for test: add in the same x86_64-linux
requirement as other tests as the stack ids are currently computed
differently on big endian systems. This will be investigated separately.
In order to allow selective reporting of context hinting during the LTO
link, and in the future to allow selective more aggressive cloning, add
an option to specify a minimum percent of the max cold size in the
profile summary. Contexts that meet that threshold will get context size
info metadata (and ThinLTO summary information) on the associated
allocations.
Specifying -memprof-report-hinted-sizes during the pre-LTO compile step
will continue to cause all contexts to receive this metadata. But
specifying -memprof-report-hinted-sizes only during the LTO link will
cause only those that meet the new threshold and have the metadata to
get reported.
To support this, because the alloc info summary and associated bitcode
requires the context size information to be in the same order as the
other context information, 0s are inserted for contexts without this
metadata. The bitcode writer uses a more compact format for the context
ids to allow better compression of the 0s.
As part of this change several helper methods are added to query whether
metadata contains context size info on any or all contexts.
Diffstat (limited to 'llvm/lib/Bitcode/Reader/BitcodeReader.cpp')
-rw-r--r-- | llvm/lib/Bitcode/Reader/BitcodeReader.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp index 47388c2..105edb9 100644 --- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp +++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp @@ -8164,6 +8164,14 @@ Error ModuleSummaryIndexBitcodeReader::parseEntireSummary(unsigned ID) { ContextSizes.reserve(NumContextSizeInfoEntries); for (unsigned J = 0; J < NumContextSizeInfoEntries; J++) { assert(ContextIdIndex < PendingContextIds.size()); + // Skip any 0 entries for MIBs without the context size info. + if (PendingContextIds[ContextIdIndex] == 0) { + // The size should also be 0 if the context was 0. + assert(!Record[I]); + ContextIdIndex++; + I++; + continue; + } // PendingContextIds read from the preceding FS_ALLOC_CONTEXT_IDS // should be in the same order as the total sizes. ContextSizes.push_back( |