1
Fork 0

Update ThinLTO (internalization) for LLVM 5

Ref: ccb80b9c0f
This commit is contained in:
Tatsuyuki Ishi 2017-10-17 14:41:56 +09:00
parent 56f5a19e45
commit 3efa00365f

View file

@ -902,7 +902,7 @@ addPreservedGUID(const ModuleSummaryIndex &Index,
GlobalValueSummary *GVSummary = Summary.get(); GlobalValueSummary *GVSummary = Summary.get();
if (isa<FunctionSummary>(GVSummary)) { if (isa<FunctionSummary>(GVSummary)) {
FunctionSummary *FS = cast<FunctionSummary>(GVSummary); auto *FS = cast<FunctionSummary>(GVSummary);
for (auto &Call: FS->calls()) { for (auto &Call: FS->calls()) {
addPreservedGUID(Index, Preserved, Call.first.getGUID()); addPreservedGUID(Index, Preserved, Call.first.getGUID());
} }
@ -910,6 +910,11 @@ addPreservedGUID(const ModuleSummaryIndex &Index,
addPreservedGUID(Index, Preserved, GUID); addPreservedGUID(Index, Preserved, GUID);
} }
} }
if (isa<AliasSummary>(GVSummary)) {
auto *AS = cast<AliasSummary>(GVSummary);
auto GUID = AS->getAliasee().getOriginalName();
addPreservedGUID(Index, Preserved, GUID);
}
} }
#else #else
auto SummaryList = Index.findGlobalValueSummaryList(GUID); auto SummaryList = Index.findGlobalValueSummaryList(GUID);
@ -997,6 +1002,15 @@ LLVMRustCreateThinLTOData(LLVMRustThinLTOModule *modules,
// combined index // combined index
// //
// This is copied from `lib/LTO/ThinLTOCodeGenerator.cpp` // This is copied from `lib/LTO/ThinLTOCodeGenerator.cpp`
#if LLVM_VERSION_GE(5, 0)
computeDeadSymbols(Ret->Index, Ret->GUIDPreservedSymbols);
ComputeCrossModuleImport(
Ret->Index,
Ret->ModuleToDefinedGVSummaries,
Ret->ImportLists,
Ret->ExportLists
);
#else
auto DeadSymbols = computeDeadSymbols(Ret->Index, Ret->GUIDPreservedSymbols); auto DeadSymbols = computeDeadSymbols(Ret->Index, Ret->GUIDPreservedSymbols);
ComputeCrossModuleImport( ComputeCrossModuleImport(
Ret->Index, Ret->Index,
@ -1005,6 +1019,7 @@ LLVMRustCreateThinLTOData(LLVMRustThinLTOModule *modules,
Ret->ExportLists, Ret->ExportLists,
&DeadSymbols &DeadSymbols
); );
#endif
// Resolve LinkOnce/Weak symbols, this has to be computed early be cause it // Resolve LinkOnce/Weak symbols, this has to be computed early be cause it
// impacts the caching. // impacts the caching.