Skip to content

Commit 2c38b47

Browse files
resolve review feedback
1 parent c5e168e commit 2c38b47

File tree

3 files changed

+23
-34
lines changed

3 files changed

+23
-34
lines changed

llvm/include/llvm/Bitcode/BitcodeWriter.h

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ class raw_ostream;
103103
void writeIndex(
104104
const ModuleSummaryIndex *Index,
105105
const std::map<std::string, GVSummaryMapTy> *ModuleToSummariesForIndex,
106-
const ModuleToGVSummaryPtrSet *ModuleToDecSummaries);
106+
const GVSummaryPtrSet *DecSummaries);
107107
};
108108

109109
/// Write the specified module to the specified raw output stream.
@@ -148,14 +148,12 @@ class raw_ostream;
148148
/// where it will be written in a new bitcode block. This is used when
149149
/// writing the combined index file for ThinLTO. When writing a subset of the
150150
/// index for a distributed backend, provide the \p ModuleToSummariesForIndex
151-
/// map. For each module, \p ModuleToDecSummaries specifies the set of
152-
/// summaries for which the corresponding value should be imported as a
153-
/// declaration (prototype).
154-
void writeIndexToFile(
155-
const ModuleSummaryIndex &Index, raw_ostream &Out,
156-
const std::map<std::string, GVSummaryMapTy> *ModuleToSummariesForIndex =
157-
nullptr,
158-
const ModuleToGVSummaryPtrSet *ModuleToDecSummaries = nullptr);
151+
/// map. \p DecSummaries specifies the set of summaries for which the
152+
/// corresponding value should be imported as a declaration (prototype).
153+
void writeIndexToFile(const ModuleSummaryIndex &Index, raw_ostream &Out,
154+
const std::map<std::string, GVSummaryMapTy>
155+
*ModuleToSummariesForIndex = nullptr,
156+
const GVSummaryPtrSet *DecSummaries = nullptr);
159157

160158
/// If EmbedBitcode is set, save a copy of the llvm IR as data in the
161159
/// __LLVM,__bitcode section (.llvmbc on non-MacOS).

llvm/include/llvm/IR/ModuleSummaryIndex.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1275,9 +1275,6 @@ using GVSummaryMapTy = DenseMap<GlobalValue::GUID, GlobalValueSummary *>;
12751275
/// A set of global value summary pointers.
12761276
using GVSummaryPtrSet = SmallPtrSet<GlobalValueSummary *, 4>;
12771277

1278-
/// The key is module path, and value is a set of global value summary pointers.
1279-
using ModuleToGVSummaryPtrSet = std::map<std::string, GVSummaryPtrSet>;
1280-
12811278
/// Map of a type GUID to type id string and summary (multimap used
12821279
/// in case of GUID conflicts).
12831280
using TypeIdSummaryMapTy =

llvm/lib/Bitcode/Writer/BitcodeWriter.cpp

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -428,9 +428,10 @@ class IndexBitcodeWriter : public BitcodeWriterBase {
428428
/// The combined index to write to bitcode.
429429
const ModuleSummaryIndex &Index;
430430

431-
/// For each module, provides the set of global value summaries for which the
432-
/// value (function, function alias, etc) should be imported as a declaration.
433-
const ModuleToGVSummaryPtrSet *ModuleToDecSummaries = nullptr;
431+
/// When writing combined summaries, provides the set of global value
432+
/// summaries for which the value (function, function alias, etc) should be
433+
/// imported as a declaration.
434+
const GVSummaryPtrSet *DecSummaries = nullptr;
434435

435436
/// When writing a subset of the index for distributed backends, client
436437
/// provides a map of modules to the corresponding GUIDs/summaries to write.
@@ -459,14 +460,13 @@ class IndexBitcodeWriter : public BitcodeWriterBase {
459460
/// If provided, \p ModuleToDecSummaries specifies the set of summaries for
460461
/// which the corresponding functions or aliased functions should be imported
461462
/// as a declaration (but not definition) for each module.
462-
IndexBitcodeWriter(
463-
BitstreamWriter &Stream, StringTableBuilder &StrtabBuilder,
464-
const ModuleSummaryIndex &Index,
465-
const ModuleToGVSummaryPtrSet *ModuleToDecSummaries = nullptr,
466-
const std::map<std::string, GVSummaryMapTy> *ModuleToSummariesForIndex =
467-
nullptr)
463+
IndexBitcodeWriter(BitstreamWriter &Stream, StringTableBuilder &StrtabBuilder,
464+
const ModuleSummaryIndex &Index,
465+
const GVSummaryPtrSet *DecSummaries = nullptr,
466+
const std::map<std::string, GVSummaryMapTy>
467+
*ModuleToSummariesForIndex = nullptr)
468468
: BitcodeWriterBase(Stream, StrtabBuilder), Index(Index),
469-
ModuleToDecSummaries(ModuleToDecSummaries),
469+
DecSummaries(DecSummaries),
470470
ModuleToSummariesForIndex(ModuleToSummariesForIndex) {
471471
// Assign unique value ids to all summaries to be written, for use
472472
// in writing out the call graph edges. Save the mapping from GUID
@@ -4556,14 +4556,9 @@ void IndexBitcodeWriter::writeCombinedGlobalValueSummary() {
45564556
unsigned AllocAbbrev = Stream.EmitAbbrev(std::move(Abbv));
45574557

45584558
auto shouldImportValueAsDecl = [&](GlobalValueSummary *GVS) -> bool {
4559-
if (ModuleToDecSummaries == nullptr)
4559+
if (DecSummaries == nullptr)
45604560
return false;
4561-
auto Iter = ModuleToDecSummaries->find(GVS->modulePath().str());
4562-
if (Iter == ModuleToDecSummaries->end())
4563-
return false;
4564-
// For the current module, the value for GVS should be imported as a
4565-
// declaration.
4566-
return Iter->second.contains(GVS);
4561+
return DecSummaries->contains(GVS);
45674562
};
45684563

45694564
// The aliases are emitted as a post-pass, and will point to the value
@@ -5062,9 +5057,8 @@ void BitcodeWriter::writeModule(const Module &M,
50625057
void BitcodeWriter::writeIndex(
50635058
const ModuleSummaryIndex *Index,
50645059
const std::map<std::string, GVSummaryMapTy> *ModuleToSummariesForIndex,
5065-
const ModuleToGVSummaryPtrSet *ModuleToDecSummaries) {
5066-
IndexBitcodeWriter IndexWriter(*Stream, StrtabBuilder, *Index,
5067-
ModuleToDecSummaries,
5060+
const GVSummaryPtrSet *DecSummaries) {
5061+
IndexBitcodeWriter IndexWriter(*Stream, StrtabBuilder, *Index, DecSummaries,
50685062
ModuleToSummariesForIndex);
50695063
IndexWriter.write();
50705064
}
@@ -5118,12 +5112,12 @@ void IndexBitcodeWriter::write() {
51185112
void llvm::writeIndexToFile(
51195113
const ModuleSummaryIndex &Index, raw_ostream &Out,
51205114
const std::map<std::string, GVSummaryMapTy> *ModuleToSummariesForIndex,
5121-
const ModuleToGVSummaryPtrSet *ModuleToDecSummaries) {
5115+
const GVSummaryPtrSet *DecSummaries) {
51225116
SmallVector<char, 0> Buffer;
51235117
Buffer.reserve(256 * 1024);
51245118

51255119
BitcodeWriter Writer(Buffer);
5126-
Writer.writeIndex(&Index, ModuleToSummariesForIndex, ModuleToDecSummaries);
5120+
Writer.writeIndex(&Index, ModuleToSummariesForIndex, DecSummaries);
51275121
Writer.writeStrtab();
51285122

51295123
Out.write((char *)&Buffer.front(), Buffer.size());

0 commit comments

Comments
 (0)