diff options
author | Jan Voung <jvoung@gmail.com> | 2024-08-27 13:53:25 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-27 13:53:25 -0400 |
commit | fa4fbaefde8569ca64594fc3845340536ec8eb02 (patch) | |
tree | 29f8266d76a885f580486ff815f0e26d08ec52a9 /llvm/lib/Bitcode/Writer/BitcodeWriter.cpp | |
parent | 81cd7358a2ce411c99512d055e98d0b9dc119c14 (diff) | |
download | llvm-fa4fbaefde8569ca64594fc3845340536ec8eb02.zip llvm-fa4fbaefde8569ca64594fc3845340536ec8eb02.tar.gz llvm-fa4fbaefde8569ca64594fc3845340536ec8eb02.tar.bz2 |
Reapply: Use an abbrev to reduce size of VALUE_GUID records in ThinLTO summaries (#106165)
This retries #90692 which was reverted previously due to issues with
lld-available being set, even if the copy of lld is not built from
source.
This does not change any code compared to #90692 to address the
lld-available issue.
The main change w.r.t, lld-available is xfailing tests in PR #99056
(until a longer term fix is available).
Diffstat (limited to 'llvm/lib/Bitcode/Writer/BitcodeWriter.cpp')
-rw-r--r-- | llvm/lib/Bitcode/Writer/BitcodeWriter.cpp | 30 |
1 files changed, 26 insertions, 4 deletions
diff --git a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp index d21ff10..3c5097f 100644 --- a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp +++ b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp @@ -4350,9 +4350,20 @@ void ModuleBitcodeWriterBase::writePerModuleGlobalValueSummary() { return; } + auto Abbv = std::make_shared<BitCodeAbbrev>(); + Abbv->Add(BitCodeAbbrevOp(bitc::FS_VALUE_GUID)); + Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); + // GUIDS often use up most of 64-bits, so encode as two Fixed 32. + Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32)); + Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32)); + unsigned ValueGuidAbbrev = Stream.EmitAbbrev(std::move(Abbv)); + for (const auto &GVI : valueIds()) { Stream.EmitRecord(bitc::FS_VALUE_GUID, - ArrayRef<uint64_t>{GVI.second, GVI.first}); + ArrayRef<uint32_t>{GVI.second, + static_cast<uint32_t>(GVI.first >> 32), + static_cast<uint32_t>(GVI.first)}, + ValueGuidAbbrev); } if (!Index->stackIds().empty()) { @@ -4366,7 +4377,7 @@ void ModuleBitcodeWriterBase::writePerModuleGlobalValueSummary() { } // Abbrev for FS_PERMODULE_PROFILE. - auto Abbv = std::make_shared<BitCodeAbbrev>(); + Abbv = std::make_shared<BitCodeAbbrev>(); Abbv->Add(BitCodeAbbrevOp(bitc::FS_PERMODULE_PROFILE)); Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // valueid Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // flags @@ -4520,9 +4531,20 @@ void IndexBitcodeWriter::writeCombinedGlobalValueSummary() { // Write the index flags. Stream.EmitRecord(bitc::FS_FLAGS, ArrayRef<uint64_t>{Index.getFlags()}); + auto Abbv = std::make_shared<BitCodeAbbrev>(); + Abbv->Add(BitCodeAbbrevOp(bitc::FS_VALUE_GUID)); + Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); + // GUIDS often use up most of 64-bits, so encode as two Fixed 32. + Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32)); + Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32)); + unsigned ValueGuidAbbrev = Stream.EmitAbbrev(std::move(Abbv)); + for (const auto &GVI : valueIds()) { Stream.EmitRecord(bitc::FS_VALUE_GUID, - ArrayRef<uint64_t>{GVI.second, GVI.first}); + ArrayRef<uint32_t>{GVI.second, + static_cast<uint32_t>(GVI.first >> 32), + static_cast<uint32_t>(GVI.first)}, + ValueGuidAbbrev); } // Write the stack ids used by this index, which will be a subset of those in @@ -4538,7 +4560,7 @@ void IndexBitcodeWriter::writeCombinedGlobalValueSummary() { } // Abbrev for FS_COMBINED_PROFILE. - auto Abbv = std::make_shared<BitCodeAbbrev>(); + Abbv = std::make_shared<BitCodeAbbrev>(); Abbv->Add(BitCodeAbbrevOp(bitc::FS_COMBINED_PROFILE)); Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // valueid Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // modid |