aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Bitcode
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/Bitcode')
-rw-r--r--llvm/lib/Bitcode/Reader/BitcodeReader.cpp11
-rw-r--r--llvm/lib/Bitcode/Writer/BitcodeWriter.cpp27
2 files changed, 30 insertions, 8 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;
}
diff --git a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
index 5829af3..24a4c2e 100644
--- a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
+++ b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
@@ -4429,12 +4429,17 @@ void ModuleBitcodeWriterBase::writePerModuleGlobalValueSummary() {
StackIdAbbv->Add(BitCodeAbbrevOp(bitc::FS_STACK_IDS));
// numids x stackid
StackIdAbbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
- // FIXME: The stack ids are hashes that are close to 64 bits in size, so
- // emitting as a pair of 32-bit fixed-width values, as we do for context
- // ids, would be more efficient.
- StackIdAbbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
+ // 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.
+ StackIdAbbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
unsigned StackIdAbbvId = Stream.EmitAbbrev(std::move(StackIdAbbv));
- Stream.EmitRecord(bitc::FS_STACK_IDS, Index->stackIds(), StackIdAbbvId);
+ SmallVector<uint32_t> Vals;
+ Vals.reserve(Index->stackIds().size() * 2);
+ for (auto Id : Index->stackIds()) {
+ Vals.push_back(static_cast<uint32_t>(Id >> 32));
+ Vals.push_back(static_cast<uint32_t>(Id));
+ }
+ Stream.EmitRecord(bitc::FS_STACK_IDS, Vals, StackIdAbbvId);
}
// n x context id
@@ -4624,9 +4629,17 @@ void IndexBitcodeWriter::writeCombinedGlobalValueSummary() {
StackIdAbbv->Add(BitCodeAbbrevOp(bitc::FS_STACK_IDS));
// numids x stackid
StackIdAbbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
- StackIdAbbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
+ // 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.
+ StackIdAbbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
unsigned StackIdAbbvId = Stream.EmitAbbrev(std::move(StackIdAbbv));
- Stream.EmitRecord(bitc::FS_STACK_IDS, StackIds, StackIdAbbvId);
+ SmallVector<uint32_t> Vals;
+ Vals.reserve(StackIds.size() * 2);
+ for (auto Id : StackIds) {
+ Vals.push_back(static_cast<uint32_t>(Id >> 32));
+ Vals.push_back(static_cast<uint32_t>(Id));
+ }
+ Stream.EmitRecord(bitc::FS_STACK_IDS, Vals, StackIdAbbvId);
}
// Abbrev for FS_COMBINED_PROFILE.