aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
diff options
context:
space:
mode:
authorTeresa Johnson <tejohnson@google.com>2024-11-18 15:16:48 -0800
committerGitHub <noreply@github.com>2024-11-18 15:16:48 -0800
commitb35f40688e3079d888932e0a35caa0b02d90db97 (patch)
treeeeb0f2251032272b6993f25c2e52a1a014f1b118 /llvm/lib/Bitcode/Reader/BitcodeReader.cpp
parent94d100f2ba81c2bf0ef495f68d66ba8c94c71d2a (diff)
downloadllvm-b35f40688e3079d888932e0a35caa0b02d90db97.zip
llvm-b35f40688e3079d888932e0a35caa0b02d90db97.tar.gz
llvm-b35f40688e3079d888932e0a35caa0b02d90db97.tar.bz2
[MemProf] Change the STACK_ID record to fixed width values (#116448)
The stack ids are hashes that are close to 64 bits in size, so emitting as a pair of 32-bit fixed-width values is more efficient than a VBR. This reduced the summary bitcode size for a large target by about 1%. Bump the index version and ensure we can read the old format.
Diffstat (limited to 'llvm/lib/Bitcode/Reader/BitcodeReader.cpp')
-rw-r--r--llvm/lib/Bitcode/Reader/BitcodeReader.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
index 9ca76b5..3e6abac 100644
--- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
+++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
@@ -7997,7 +7997,16 @@ Error ModuleSummaryIndexBitcodeReader::parseEntireSummary(unsigned ID) {
case bitc::FS_STACK_IDS: { // [n x stackid]
// Save stack ids in the reader to consult when adding stack ids from the
// lists in the stack node and alloc node entries.
- StackIds = ArrayRef<uint64_t>(Record);
+ if (Version <= 11) {
+ StackIds = ArrayRef<uint64_t>(Record);
+ break;
+ }
+ // This is an array of 32-bit fixed-width values, holding each 64-bit
+ // context id as a pair of adjacent (most significant first) 32-bit words.
+ assert(Record.size() % 2 == 0);
+ StackIds.reserve(Record.size() / 2);
+ for (auto R = Record.begin(); R != Record.end(); R += 2)
+ StackIds.push_back(*R << 32 | *(R + 1));
break;
}