Skip to content

Commit 9b23100

Browse files
author
git apple-llvm automerger
committed
Merge commit '53061eecdbd9' from llvm.org/main into next
2 parents ae23975 + 53061ee commit 9b23100

File tree

9 files changed

+41
-119
lines changed

9 files changed

+41
-119
lines changed

llvm/include/llvm/Bitcode/BitcodeWriter.h

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,7 @@ class BitcodeWriter {
102102

103103
void writeIndex(
104104
const ModuleSummaryIndex *Index,
105-
const std::map<std::string, GVSummaryMapTy> *ModuleToSummariesForIndex,
106-
const GVSummaryPtrSet *DecSummaries);
105+
const std::map<std::string, GVSummaryMapTy> *ModuleToSummariesForIndex);
107106
};
108107

109108
/// Write the specified module to the specified raw output stream.
@@ -148,12 +147,10 @@ void writeThinLinkBitcodeToFile(const Module &M, raw_ostream &Out,
148147
/// where it will be written in a new bitcode block. This is used when
149148
/// writing the combined index file for ThinLTO. When writing a subset of the
150149
/// index for a distributed backend, provide the \p ModuleToSummariesForIndex
151-
/// map. \p DecSummaries specifies the set of summaries for which the
152-
/// corresponding value should be imported as a declaration (prototype).
150+
/// map.
153151
void writeIndexToFile(const ModuleSummaryIndex &Index, raw_ostream &Out,
154152
const std::map<std::string, GVSummaryMapTy>
155-
*ModuleToSummariesForIndex = nullptr,
156-
const GVSummaryPtrSet *DecSummaries = nullptr);
153+
*ModuleToSummariesForIndex = nullptr);
157154

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

llvm/include/llvm/LTO/legacy/ThinLTOCodeGenerator.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -319,13 +319,12 @@ class ThinLTOCodeGenerator {
319319
const lto::InputFile &File);
320320

321321
/**
322-
* Compute the list of summaries and the subset of declaration summaries
323-
* needed for importing into module.
322+
* Compute the list of summaries needed for importing into module.
324323
*/
325324
void gatherImportedSummariesForModule(
326325
Module &Module, ModuleSummaryIndex &Index,
327326
std::map<std::string, GVSummaryMapTy> &ModuleToSummariesForIndex,
328-
GVSummaryPtrSet &DecSummaries, const lto::InputFile &File);
327+
const lto::InputFile &File);
329328

330329
/**
331330
* Perform internalization. Index is updated to reflect linkage changes.

llvm/include/llvm/Transforms/IPO/FunctionImport.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -212,15 +212,11 @@ bool convertToDeclaration(GlobalValue &GV);
212212
/// \p ModuleToSummariesForIndex will be populated with the needed summaries
213213
/// from each required module path. Use a std::map instead of StringMap to get
214214
/// stable order for bitcode emission.
215-
///
216-
/// \p DecSummaries will be popluated with the subset of of summary pointers
217-
/// that have 'declaration' import type among all summaries the module need.
218215
void gatherImportedSummariesForModule(
219216
StringRef ModulePath,
220217
const DenseMap<StringRef, GVSummaryMapTy> &ModuleToDefinedGVSummaries,
221218
const FunctionImporter::ImportMapTy &ImportList,
222-
std::map<std::string, GVSummaryMapTy> &ModuleToSummariesForIndex,
223-
GVSummaryPtrSet &DecSummaries);
219+
std::map<std::string, GVSummaryMapTy> &ModuleToSummariesForIndex);
224220

225221
/// Emit into \p OutputFilename the files module \p ModulePath will import from.
226222
std::error_code EmitImportsFiles(

llvm/lib/Bitcode/Writer/BitcodeWriter.cpp

Lines changed: 8 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -424,11 +424,6 @@ class IndexBitcodeWriter : public BitcodeWriterBase {
424424
/// The combined index to write to bitcode.
425425
const ModuleSummaryIndex &Index;
426426

427-
/// When writing combined summaries, provides the set of global value
428-
/// summaries for which the value (function, function alias, etc) should be
429-
/// imported as a declaration.
430-
const GVSummaryPtrSet *DecSummaries = nullptr;
431-
432427
/// When writing a subset of the index for distributed backends, client
433428
/// provides a map of modules to the corresponding GUIDs/summaries to write.
434429
const std::map<std::string, GVSummaryMapTy> *ModuleToSummariesForIndex;
@@ -457,16 +452,11 @@ class IndexBitcodeWriter : public BitcodeWriterBase {
457452
/// Constructs a IndexBitcodeWriter object for the given combined index,
458453
/// writing to the provided \p Buffer. When writing a subset of the index
459454
/// for a distributed backend, provide a \p ModuleToSummariesForIndex map.
460-
/// If provided, \p ModuleToDecSummaries specifies the set of summaries for
461-
/// which the corresponding functions or aliased functions should be imported
462-
/// as a declaration (but not definition) for each module.
463455
IndexBitcodeWriter(BitstreamWriter &Stream, StringTableBuilder &StrtabBuilder,
464456
const ModuleSummaryIndex &Index,
465-
const GVSummaryPtrSet *DecSummaries = nullptr,
466457
const std::map<std::string, GVSummaryMapTy>
467458
*ModuleToSummariesForIndex = nullptr)
468459
: BitcodeWriterBase(Stream, StrtabBuilder), Index(Index),
469-
DecSummaries(DecSummaries),
470460
ModuleToSummariesForIndex(ModuleToSummariesForIndex) {
471461

472462
// See if the StackIdIndex was already added to the StackId map and
@@ -1221,8 +1211,7 @@ static uint64_t getEncodedFFlags(FunctionSummary::FFlags Flags) {
12211211

12221212
// Decode the flags for GlobalValue in the summary. See getDecodedGVSummaryFlags
12231213
// in BitcodeReader.cpp.
1224-
static uint64_t getEncodedGVSummaryFlags(GlobalValueSummary::GVFlags Flags,
1225-
bool ImportAsDecl = false) {
1214+
static uint64_t getEncodedGVSummaryFlags(GlobalValueSummary::GVFlags Flags) {
12261215
uint64_t RawFlags = 0;
12271216

12281217
RawFlags |= Flags.NotEligibleToImport; // bool
@@ -1237,8 +1226,7 @@ static uint64_t getEncodedGVSummaryFlags(GlobalValueSummary::GVFlags Flags,
12371226

12381227
RawFlags |= (Flags.Visibility << 8); // 2 bits
12391228

1240-
unsigned ImportType = Flags.ImportType | ImportAsDecl;
1241-
RawFlags |= (ImportType << 10); // 1 bit
1229+
RawFlags |= (Flags.ImportType << 10); // 1 bit
12421230

12431231
return RawFlags;
12441232
}
@@ -4585,12 +4573,6 @@ void IndexBitcodeWriter::writeCombinedGlobalValueSummary() {
45854573
Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
45864574
unsigned AllocAbbrev = Stream.EmitAbbrev(std::move(Abbv));
45874575

4588-
auto shouldImportValueAsDecl = [&](GlobalValueSummary *GVS) -> bool {
4589-
if (DecSummaries == nullptr)
4590-
return false;
4591-
return DecSummaries->contains(GVS);
4592-
};
4593-
45944576
// The aliases are emitted as a post-pass, and will point to the value
45954577
// id of the aliasee. Save them in a vector for post-processing.
45964578
SmallVector<AliasSummary *, 64> Aliases;
@@ -4701,8 +4683,7 @@ void IndexBitcodeWriter::writeCombinedGlobalValueSummary() {
47014683
NameVals.push_back(*ValueId);
47024684
assert(ModuleIdMap.count(FS->modulePath()));
47034685
NameVals.push_back(ModuleIdMap[FS->modulePath()]);
4704-
NameVals.push_back(
4705-
getEncodedGVSummaryFlags(FS->flags(), shouldImportValueAsDecl(FS)));
4686+
NameVals.push_back(getEncodedGVSummaryFlags(FS->flags()));
47064687
NameVals.push_back(FS->instCount());
47074688
NameVals.push_back(getEncodedFFlags(FS->fflags()));
47084689
NameVals.push_back(FS->entryCount());
@@ -4751,8 +4732,7 @@ void IndexBitcodeWriter::writeCombinedGlobalValueSummary() {
47514732
NameVals.push_back(AliasValueId);
47524733
assert(ModuleIdMap.count(AS->modulePath()));
47534734
NameVals.push_back(ModuleIdMap[AS->modulePath()]);
4754-
NameVals.push_back(
4755-
getEncodedGVSummaryFlags(AS->flags(), shouldImportValueAsDecl(AS)));
4735+
NameVals.push_back(getEncodedGVSummaryFlags(AS->flags()));
47564736
auto AliaseeValueId = SummaryToValueIdMap[&AS->getAliasee()];
47574737
assert(AliaseeValueId);
47584738
NameVals.push_back(AliaseeValueId);
@@ -5093,9 +5073,8 @@ void BitcodeWriter::writeModule(const Module &M,
50935073

50945074
void BitcodeWriter::writeIndex(
50955075
const ModuleSummaryIndex *Index,
5096-
const std::map<std::string, GVSummaryMapTy> *ModuleToSummariesForIndex,
5097-
const GVSummaryPtrSet *DecSummaries) {
5098-
IndexBitcodeWriter IndexWriter(*Stream, StrtabBuilder, *Index, DecSummaries,
5076+
const std::map<std::string, GVSummaryMapTy> *ModuleToSummariesForIndex) {
5077+
IndexBitcodeWriter IndexWriter(*Stream, StrtabBuilder, *Index,
50995078
ModuleToSummariesForIndex);
51005079
IndexWriter.write();
51015080
}
@@ -5150,13 +5129,12 @@ void IndexBitcodeWriter::write() {
51505129
// index for a distributed backend, provide a \p ModuleToSummariesForIndex map.
51515130
void llvm::writeIndexToFile(
51525131
const ModuleSummaryIndex &Index, raw_ostream &Out,
5153-
const std::map<std::string, GVSummaryMapTy> *ModuleToSummariesForIndex,
5154-
const GVSummaryPtrSet *DecSummaries) {
5132+
const std::map<std::string, GVSummaryMapTy> *ModuleToSummariesForIndex) {
51555133
SmallVector<char, 0> Buffer;
51565134
Buffer.reserve(256 * 1024);
51575135

51585136
BitcodeWriter Writer(Buffer);
5159-
Writer.writeIndex(&Index, ModuleToSummariesForIndex, DecSummaries);
5137+
Writer.writeIndex(&Index, ModuleToSummariesForIndex);
51605138
Writer.writeStrtab();
51615139

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

llvm/lib/LTO/LTO.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1400,20 +1400,18 @@ class lto::ThinBackendProc {
14001400
llvm::StringRef ModulePath,
14011401
const std::string &NewModulePath) {
14021402
std::map<std::string, GVSummaryMapTy> ModuleToSummariesForIndex;
1403-
GVSummaryPtrSet DeclarationSummaries;
14041403

14051404
std::error_code EC;
14061405
gatherImportedSummariesForModule(ModulePath, ModuleToDefinedGVSummaries,
1407-
ImportList, ModuleToSummariesForIndex,
1408-
DeclarationSummaries);
1406+
ImportList, ModuleToSummariesForIndex);
14091407

14101408
raw_fd_ostream OS(NewModulePath + ".thinlto.bc", EC,
14111409
sys::fs::OpenFlags::OF_None);
14121410
if (EC)
14131411
return errorCodeToError(EC);
14141412

1415-
writeIndexToFile(CombinedIndex, OS, &ModuleToSummariesForIndex,
1416-
&DeclarationSummaries);
1413+
// TODO: Serialize declaration bits to bitcode.
1414+
writeIndexToFile(CombinedIndex, OS, &ModuleToSummariesForIndex);
14171415

14181416
if (ShouldEmitImportsFiles) {
14191417
EC = EmitImportsFiles(ModulePath, NewModulePath + ".imports",

llvm/lib/LTO/ThinLTOCodeGenerator.cpp

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1350,7 +1350,7 @@ void ThinLTOCodeGenerator::crossModuleImport(Module &TheModule,
13501350
void ThinLTOCodeGenerator::gatherImportedSummariesForModule(
13511351
Module &TheModule, ModuleSummaryIndex &Index,
13521352
std::map<std::string, GVSummaryMapTy> &ModuleToSummariesForIndex,
1353-
GVSummaryPtrSet &DecSummaries, const lto::InputFile &File) {
1353+
const lto::InputFile &File) {
13541354
auto ModuleCount = Index.modulePaths().size();
13551355
auto ModuleIdentifier = TheModule.getModuleIdentifier();
13561356

@@ -1380,7 +1380,7 @@ void ThinLTOCodeGenerator::gatherImportedSummariesForModule(
13801380

13811381
llvm::gatherImportedSummariesForModule(
13821382
ModuleIdentifier, ModuleToDefinedGVSummaries,
1383-
ImportLists[ModuleIdentifier], ModuleToSummariesForIndex, DecSummaries);
1383+
ImportLists[ModuleIdentifier], ModuleToSummariesForIndex);
13841384
}
13851385

13861386
/**
@@ -1416,14 +1416,10 @@ void ThinLTOCodeGenerator::emitImports(Module &TheModule, StringRef OutputName,
14161416
IsPrevailing(PrevailingCopy), ImportLists,
14171417
ExportLists);
14181418

1419-
// 'EmitImportsFiles' emits the list of modules from which to import from, and
1420-
// the set of keys in `ModuleToSummariesForIndex` should be a superset of keys
1421-
// in `DecSummaries`, so no need to use `DecSummaries` in `EmitImportFiles`.
1422-
GVSummaryPtrSet DecSummaries;
14231419
std::map<std::string, GVSummaryMapTy> ModuleToSummariesForIndex;
14241420
llvm::gatherImportedSummariesForModule(
14251421
ModuleIdentifier, ModuleToDefinedGVSummaries,
1426-
ImportLists[ModuleIdentifier], ModuleToSummariesForIndex, DecSummaries);
1422+
ImportLists[ModuleIdentifier], ModuleToSummariesForIndex);
14271423

14281424
std::error_code EC;
14291425
if ((EC = EmitImportsFiles(ModuleIdentifier, OutputName,

llvm/lib/Transforms/IPO/FunctionImport.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1435,8 +1435,7 @@ void llvm::gatherImportedSummariesForModule(
14351435
StringRef ModulePath,
14361436
const DenseMap<StringRef, GVSummaryMapTy> &ModuleToDefinedGVSummaries,
14371437
const FunctionImporter::ImportMapTy &ImportList,
1438-
std::map<std::string, GVSummaryMapTy> &ModuleToSummariesForIndex,
1439-
GVSummaryPtrSet &DecSummaries) {
1438+
std::map<std::string, GVSummaryMapTy> &ModuleToSummariesForIndex) {
14401439
// Include all summaries from the importing module.
14411440
ModuleToSummariesForIndex[std::string(ModulePath)] =
14421441
ModuleToDefinedGVSummaries.lookup(ModulePath);
@@ -1451,7 +1450,7 @@ void llvm::gatherImportedSummariesForModule(
14511450
assert(DS != DefinedGVSummaries.end() &&
14521451
"Expected a defined summary for imported global value");
14531452
if (Type == GlobalValueSummary::Declaration)
1454-
DecSummaries.insert(DS->second);
1453+
continue;
14551454

14561455
SummariesForIndex[GUID] = DS->second;
14571456
}

0 commit comments

Comments
 (0)