aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
diff options
context:
space:
mode:
authorMingming Liu <mingmingl@google.com>2024-06-05 09:59:46 -0700
committerGitHub <noreply@github.com>2024-06-05 09:59:46 -0700
commit53061eecdbd9ffc77a43f85b6c4e145a242a27a4 (patch)
tree4de5c83683863b26008d2189ad343b35471e3edc /llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
parent61589b859974a3a4055c1065ad43b4899ee7bbcf (diff)
downloadllvm-53061eecdbd9ffc77a43f85b6c4e145a242a27a4.zip
llvm-53061eecdbd9ffc77a43f85b6c4e145a242a27a4.tar.gz
llvm-53061eecdbd9ffc77a43f85b6c4e145a242a27a4.tar.bz2
Revert "[ThinLTO][Bitcode] Generate import type in bitcode (#87600)" (#94502)
This reverts commit 6262763341fcd71a2b0708cf7485f9abd1d26ba8, to prepare for the revert of https://github.com/llvm/llvm-project/pull/92718. https://github.com/llvm/llvm-project/pull/92718 causes LTO indexing OOM in some applications.
Diffstat (limited to 'llvm/lib/Bitcode/Writer/BitcodeWriter.cpp')
-rw-r--r--llvm/lib/Bitcode/Writer/BitcodeWriter.cpp38
1 files changed, 8 insertions, 30 deletions
diff --git a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
index 3c99bde..35ea3c1 100644
--- a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
+++ b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
@@ -424,11 +424,6 @@ class IndexBitcodeWriter : public BitcodeWriterBase {
/// The combined index to write to bitcode.
const ModuleSummaryIndex &Index;
- /// When writing combined summaries, provides the set of global value
- /// summaries for which the value (function, function alias, etc) should be
- /// imported as a declaration.
- const GVSummaryPtrSet *DecSummaries = nullptr;
-
/// When writing a subset of the index for distributed backends, client
/// provides a map of modules to the corresponding GUIDs/summaries to write.
const std::map<std::string, GVSummaryMapTy> *ModuleToSummariesForIndex;
@@ -457,16 +452,11 @@ public:
/// Constructs a IndexBitcodeWriter object for the given combined index,
/// writing to the provided \p Buffer. When writing a subset of the index
/// for a distributed backend, provide a \p ModuleToSummariesForIndex map.
- /// If provided, \p ModuleToDecSummaries specifies the set of summaries for
- /// which the corresponding functions or aliased functions should be imported
- /// as a declaration (but not definition) for each module.
IndexBitcodeWriter(BitstreamWriter &Stream, StringTableBuilder &StrtabBuilder,
const ModuleSummaryIndex &Index,
- const GVSummaryPtrSet *DecSummaries = nullptr,
const std::map<std::string, GVSummaryMapTy>
*ModuleToSummariesForIndex = nullptr)
: BitcodeWriterBase(Stream, StrtabBuilder), Index(Index),
- DecSummaries(DecSummaries),
ModuleToSummariesForIndex(ModuleToSummariesForIndex) {
// See if the StackIdIndex was already added to the StackId map and
@@ -1221,8 +1211,7 @@ static uint64_t getEncodedFFlags(FunctionSummary::FFlags Flags) {
// Decode the flags for GlobalValue in the summary. See getDecodedGVSummaryFlags
// in BitcodeReader.cpp.
-static uint64_t getEncodedGVSummaryFlags(GlobalValueSummary::GVFlags Flags,
- bool ImportAsDecl = false) {
+static uint64_t getEncodedGVSummaryFlags(GlobalValueSummary::GVFlags Flags) {
uint64_t RawFlags = 0;
RawFlags |= Flags.NotEligibleToImport; // bool
@@ -1237,8 +1226,7 @@ static uint64_t getEncodedGVSummaryFlags(GlobalValueSummary::GVFlags Flags,
RawFlags |= (Flags.Visibility << 8); // 2 bits
- unsigned ImportType = Flags.ImportType | ImportAsDecl;
- RawFlags |= (ImportType << 10); // 1 bit
+ RawFlags |= (Flags.ImportType << 10); // 1 bit
return RawFlags;
}
@@ -4565,12 +4553,6 @@ void IndexBitcodeWriter::writeCombinedGlobalValueSummary() {
Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
unsigned AllocAbbrev = Stream.EmitAbbrev(std::move(Abbv));
- auto shouldImportValueAsDecl = [&](GlobalValueSummary *GVS) -> bool {
- if (DecSummaries == nullptr)
- return false;
- return DecSummaries->contains(GVS);
- };
-
// The aliases are emitted as a post-pass, and will point to the value
// id of the aliasee. Save them in a vector for post-processing.
SmallVector<AliasSummary *, 64> Aliases;
@@ -4681,8 +4663,7 @@ void IndexBitcodeWriter::writeCombinedGlobalValueSummary() {
NameVals.push_back(*ValueId);
assert(ModuleIdMap.count(FS->modulePath()));
NameVals.push_back(ModuleIdMap[FS->modulePath()]);
- NameVals.push_back(
- getEncodedGVSummaryFlags(FS->flags(), shouldImportValueAsDecl(FS)));
+ NameVals.push_back(getEncodedGVSummaryFlags(FS->flags()));
NameVals.push_back(FS->instCount());
NameVals.push_back(getEncodedFFlags(FS->fflags()));
NameVals.push_back(FS->entryCount());
@@ -4731,8 +4712,7 @@ void IndexBitcodeWriter::writeCombinedGlobalValueSummary() {
NameVals.push_back(AliasValueId);
assert(ModuleIdMap.count(AS->modulePath()));
NameVals.push_back(ModuleIdMap[AS->modulePath()]);
- NameVals.push_back(
- getEncodedGVSummaryFlags(AS->flags(), shouldImportValueAsDecl(AS)));
+ NameVals.push_back(getEncodedGVSummaryFlags(AS->flags()));
auto AliaseeValueId = SummaryToValueIdMap[&AS->getAliasee()];
assert(AliaseeValueId);
NameVals.push_back(AliaseeValueId);
@@ -5073,9 +5053,8 @@ void BitcodeWriter::writeModule(const Module &M,
void BitcodeWriter::writeIndex(
const ModuleSummaryIndex *Index,
- const std::map<std::string, GVSummaryMapTy> *ModuleToSummariesForIndex,
- const GVSummaryPtrSet *DecSummaries) {
- IndexBitcodeWriter IndexWriter(*Stream, StrtabBuilder, *Index, DecSummaries,
+ const std::map<std::string, GVSummaryMapTy> *ModuleToSummariesForIndex) {
+ IndexBitcodeWriter IndexWriter(*Stream, StrtabBuilder, *Index,
ModuleToSummariesForIndex);
IndexWriter.write();
}
@@ -5130,13 +5109,12 @@ void IndexBitcodeWriter::write() {
// index for a distributed backend, provide a \p ModuleToSummariesForIndex map.
void llvm::writeIndexToFile(
const ModuleSummaryIndex &Index, raw_ostream &Out,
- const std::map<std::string, GVSummaryMapTy> *ModuleToSummariesForIndex,
- const GVSummaryPtrSet *DecSummaries) {
+ const std::map<std::string, GVSummaryMapTy> *ModuleToSummariesForIndex) {
SmallVector<char, 0> Buffer;
Buffer.reserve(256 * 1024);
BitcodeWriter Writer(Buffer);
- Writer.writeIndex(&Index, ModuleToSummariesForIndex, DecSummaries);
+ Writer.writeIndex(&Index, ModuleToSummariesForIndex);
Writer.writeStrtab();
Out.write((char *)&Buffer.front(), Buffer.size());