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();
if (isa<FunctionSummary>(GVSummary)) {
FunctionSummary *FS = cast<FunctionSummary>(GVSummary);
auto *FS = cast<FunctionSummary>(GVSummary);
for (auto &Call: FS->calls()) {
addPreservedGUID(Index, Preserved, Call.first.getGUID());
}
@ -910,6 +910,11 @@ addPreservedGUID(const ModuleSummaryIndex &Index,
addPreservedGUID(Index, Preserved, GUID);
}
}
if (isa<AliasSummary>(GVSummary)) {
auto *AS = cast<AliasSummary>(GVSummary);
auto GUID = AS->getAliasee().getOriginalName();
addPreservedGUID(Index, Preserved, GUID);
}
}
#else
auto SummaryList = Index.findGlobalValueSummaryList(GUID);
@ -997,6 +1002,15 @@ LLVMRustCreateThinLTOData(LLVMRustThinLTOModule *modules,
// combined index
//
// 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);
ComputeCrossModuleImport(
Ret->Index,
@ -1005,6 +1019,7 @@ LLVMRustCreateThinLTOData(LLVMRustThinLTOModule *modules,
Ret->ExportLists,
&DeadSymbols
);
#endif
// Resolve LinkOnce/Weak symbols, this has to be computed early be cause it
// impacts the caching.