@@ -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,
50625057void 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() {
51185112void 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