Go to the documentation of this file.
25 #include "llvm/Config/llvm-config.h"
50 #include "llvm/Support/VCSRevision.h"
66 #define DEBUG_TYPE "lto"
70 cl::desc(
"Dump the SCCs in the ThinLTO index's callgraph"));
75 cl::desc(
"Enable global value internalization in LTO"));
84 const std::map<GlobalValue::GUID, GlobalValue::LinkageTypes> &ResolvedODR,
86 const std::set<GlobalValue::GUID> &CfiFunctionDefs,
87 const std::set<GlobalValue::GUID> &CfiFunctionDecls) {
95 Hasher.
update(LLVM_VERSION_STRING);
97 Hasher.
update(LLVM_REVISION);
105 auto AddUnsigned = [&](
unsigned I) {
124 for (
auto &A : Conf.
MAttrs)
145 auto ModHash = Index.getModuleHash(ModuleID);
148 std::vector<uint64_t> ExportsGUID;
149 ExportsGUID.reserve(ExportList.
size());
150 for (
const auto &
VI : ExportList) {
151 auto GUID =
VI.getGUID();
152 ExportsGUID.push_back(GUID);
166 std::vector<ImportMapIteratorTy> ImportModulesVector;
167 ImportModulesVector.reserve(ImportList.
size());
169 for (ImportMapIteratorTy It = ImportList.
begin(); It != ImportList.
end();
171 ImportModulesVector.push_back(It);
174 [](
const ImportMapIteratorTy &Lhs,
const ImportMapIteratorTy &Rhs)
175 ->
bool {
return Lhs->getKey() < Rhs->getKey(); });
176 for (
const ImportMapIteratorTy &EntryIt : ImportModulesVector) {
177 auto ModHash = Index.getModuleHash(EntryIt->first());
180 AddUint64(EntryIt->second.size());
181 for (
auto &Fn : EntryIt->second)
186 for (
auto &Entry : ResolvedODR) {
195 std::set<GlobalValue::GUID> UsedCfiDefs;
196 std::set<GlobalValue::GUID> UsedCfiDecls;
199 std::set<GlobalValue::GUID> UsedTypeIds;
202 if (CfiFunctionDefs.count(ValueGUID))
203 UsedCfiDefs.insert(ValueGUID);
204 if (CfiFunctionDecls.count(ValueGUID))
205 UsedCfiDecls.insert(ValueGUID);
210 AddUnsigned(
GS->getVisibility());
211 AddUnsigned(
GS->isLive());
212 AddUnsigned(
GS->canAutoHide());
214 AddUnsigned(
VI.isDSOLocal(Index.withDSOLocalPropagation()));
215 AddUsedCfiGlobal(
VI.getGUID());
217 if (
auto *GVS = dyn_cast<GlobalVarSummary>(
GS)) {
218 AddUnsigned(GVS->maybeReadOnly());
219 AddUnsigned(GVS->maybeWriteOnly());
221 if (
auto *
FS = dyn_cast<FunctionSummary>(
GS)) {
222 for (
auto &TT :
FS->type_tests())
223 UsedTypeIds.insert(TT);
224 for (
auto &TT :
FS->type_test_assume_vcalls())
225 UsedTypeIds.insert(TT.GUID);
226 for (
auto &TT :
FS->type_checked_load_vcalls())
227 UsedTypeIds.insert(TT.GUID);
228 for (
auto &TT :
FS->type_test_assume_const_vcalls())
229 UsedTypeIds.insert(TT.VFunc.GUID);
230 for (
auto &TT :
FS->type_checked_load_const_vcalls())
231 UsedTypeIds.insert(TT.VFunc.GUID);
232 for (
auto &ET :
FS->calls()) {
233 AddUnsigned(ET.first.isDSOLocal(Index.withDSOLocalPropagation()));
234 AddUsedCfiGlobal(ET.first.getGUID());
241 for (
auto &
GS : DefinedGlobals) {
245 AddUsedCfiGlobal(
GS.first);
246 AddUsedThings(
GS.second);
251 for (
auto &ImpM : ImportList)
252 for (
auto &ImpF : ImpM.second) {
257 if (
auto *AS = dyn_cast_or_null<AliasSummary>(
S))
258 AddUsedThings(AS->getBaseObject());
264 AddUnsigned(
S.TTRes.TheKind);
265 AddUnsigned(
S.TTRes.SizeM1BitWidth);
267 AddUint64(
S.TTRes.AlignLog2);
268 AddUint64(
S.TTRes.SizeM1);
269 AddUint64(
S.TTRes.BitMask);
270 AddUint64(
S.TTRes.InlineBits);
272 AddUint64(
S.WPDRes.size());
273 for (
auto &WPD :
S.WPDRes) {
274 AddUnsigned(WPD.first);
275 AddUnsigned(WPD.second.TheKind);
276 AddString(WPD.second.SingleImplName);
278 AddUint64(WPD.second.ResByArg.size());
279 for (
auto &ByArg : WPD.second.ResByArg) {
280 AddUint64(ByArg.first.size());
283 AddUnsigned(ByArg.second.TheKind);
284 AddUint64(ByArg.second.Info);
285 AddUnsigned(ByArg.second.Byte);
286 AddUnsigned(ByArg.second.Bit);
293 auto TidIter = Index.typeIds().equal_range(TId);
294 for (
auto It = TidIter.first; It != TidIter.second; ++It)
295 AddTypeIdSummary(It->second.first, It->second.second);
298 AddUnsigned(UsedCfiDefs.size());
299 for (
auto &V : UsedCfiDefs)
302 AddUnsigned(UsedCfiDecls.size());
303 for (
auto &V : UsedCfiDecls)
309 Hasher.
update(FileOrErr.get()->getBuffer());
314 Hasher.
update(FileOrErr.get()->getBuffer());
333 for (
auto &
S :
VI.getSummaryList()) {
348 if (isPrevailing(
VI.getGUID(),
S.get())) {
361 S->setCanAutoHide(
VI.canAutoHide() &&
362 !GUIDPreservedSymbols.
count(
VI.getGUID()));
365 Visibility =
S->getVisibility();
368 else if (!isa<AliasSummary>(
S.get()) &&
369 !GlobalInvolvedWithAlias.
count(
S.get()))
376 S->setVisibility(Visibility);
378 if (
S->linkage() != OriginalLinkage)
379 recordNewLinkage(
S->modulePath(),
VI.getGUID(),
S->linkage());
383 for (
auto &
S :
VI.getSummaryList()) {
388 S->setVisibility(Visibility);
410 for (
auto &
I : Index)
411 for (
auto &
S :
I.second.SummaryList)
412 if (
auto AS = dyn_cast<AliasSummary>(
S.get()))
413 GlobalInvolvedWithAlias.
insert(&AS->getAliasee());
415 for (
auto &
I : Index)
417 GlobalInvolvedWithAlias, isPrevailing,
418 recordNewLinkage, GUIDPreservedSymbols);
422 if (
auto *VarSummary = dyn_cast<GlobalVarSummary>(GVS->
getBaseObject()))
423 return !VarSummary->maybeReadOnly() && !VarSummary->maybeWriteOnly() &&
433 for (
auto &
S :
VI.getSummaryList()) {
434 if (isExported(
S->modulePath(),
VI)) {
442 isPrevailing(
VI.getGUID(),
S.get())) &&
464 for (
auto &
I : Index)
473 std::unique_ptr<InputFile> File(
new InputFile);
479 File->TargetTriple = FOrErr->TheReader.getTargetTriple();
480 File->SourceFileName = FOrErr->TheReader.getSourceFileName();
481 File->COFFLinkerOpts = FOrErr->TheReader.getCOFFLinkerOpts();
482 File->DependentLibraries = FOrErr->TheReader.getDependentLibraries();
483 File->ComdatTable = FOrErr->TheReader.getComdatTable();
485 for (
unsigned I = 0;
I != FOrErr->Mods.size(); ++
I) {
486 size_t Begin = File->Symbols.size();
488 FOrErr->TheReader.module_symbols(
I))
491 if (Sym.isGlobal() && !Sym.isFormatSpecific())
492 File->Symbols.push_back(Sym);
493 File->ModuleSymIndices.push_back({Begin, File->Symbols.size()});
496 File->Mods = FOrErr->Mods;
497 File->Strtab =
std::move(FOrErr->Strtab);
502 return Mods[0].getModuleIdentifier();
506 assert(Mods.size() == 1 &&
"Expect only one bitcode module");
510 LTO::RegularLTOState::RegularLTOState(
unsigned ParallelCodeGenParallelismLevel,
512 : ParallelCodeGenParallelismLevel(ParallelCodeGenParallelismLevel),
513 Ctx(Conf), CombinedModule(
std::make_unique<
Module>(
"ld-temp.o", Ctx)),
514 Mover(
std::make_unique<
IRMover>(*CombinedModule)) {}
516 LTO::ThinLTOState::ThinLTOState(
ThinBackend Backend)
517 : Backend(Backend), CombinedIndex(
false) {
524 unsigned ParallelCodeGenParallelismLevel)
526 RegularLTO(ParallelCodeGenParallelismLevel,
this->Conf),
536 unsigned Partition,
bool InSummary) {
537 auto *ResI = Res.
begin();
538 auto *ResE = Res.
end();
540 const Triple TT(RegularLTO.CombinedModule->getTargetTriple());
549 if (TT.isOSBinFormatCOFF() &&
Name.startswith(
"__imp_"))
550 Name =
Name.substr(strlen(
"__imp_"));
551 auto &GlobalRes = GlobalResolutions[
Name];
552 GlobalRes.UnnamedAddr &= Sym.isUnnamedAddr();
554 assert(!GlobalRes.Prevailing &&
555 "Multiple prevailing defs are not allowed");
556 GlobalRes.Prevailing =
true;
557 GlobalRes.IRName = std::string(Sym.getIRName());
558 }
else if (!GlobalRes.Prevailing && GlobalRes.IRName.empty()) {
565 GlobalRes.IRName = std::string(Sym.getIRName());
574 GlobalRes.Partition != Partition)) {
575 GlobalRes.Partition = GlobalResolution::External;
578 GlobalRes.Partition = Partition;
582 GlobalRes.VisibleOutsideSummary |=
593 auto ResI = Res.
begin();
598 OS <<
"-r=" << Path <<
',' << Sym.getName() <<
',';
615 assert(!CalledGetMaxTasks);
620 if (RegularLTO.CombinedModule->getTargetTriple().empty()) {
621 RegularLTO.CombinedModule->setTargetTriple(Input->getTargetTriple());
627 for (
unsigned I = 0;
I != Input->Mods.size(); ++
I)
628 if (
Error Err = addModule(*Input,
I, ResI, Res.
end()))
642 if (EnableSplitLTOUnit.
hasValue()) {
646 if (EnableSplitLTOUnit.
getValue() != LTOInfo->EnableSplitLTOUnit)
647 ThinLTO.CombinedIndex.setPartiallySplitLTOUnits();
649 EnableSplitLTOUnit = LTOInfo->EnableSplitLTOUnit;
652 auto ModSyms = Input.module_symbols(ModI);
653 addModuleToGlobalRes(ModSyms, {ResI, ResE},
654 LTOInfo->IsThinLTO ? ThinLTO.ModuleMap.size() + 1 : 0,
655 LTOInfo->HasSummary);
657 if (LTOInfo->IsThinLTO)
658 return addThinLTO(BM, ModSyms, ResI, ResE);
660 RegularLTO.EmptyCombinedModule =
false;
662 addRegularLTO(BM, ModSyms, ResI, ResE);
666 if (!LTOInfo->HasSummary)
667 return linkRegularLTO(
std::move(*ModOrErr),
false);
673 RegularLTO.ModsWithSummaries.push_back(
std::move(*ModOrErr));
689 std::set<const Comdat *> &NonPrevailingComdats) {
694 if (!NonPrevailingComdats.count(
C))
703 if (
auto GO = dyn_cast<GlobalObject>(&GV))
704 GO->setComdat(
nullptr);
714 RegularLTOState::AddedModule
Mod;
723 if (
Error Err =
M.materializeMetadata())
731 if (GV.hasAppendingLinkage())
732 Mod.Keep.push_back(&GV);
735 for (
auto &GA :
M.aliases())
737 AliasedGlobals.
insert(GO);
746 auto MsymI = SymTab.
symbols().begin(), MsymE = SymTab.
symbols().end();
748 while (MsymI != MsymE) {
758 std::set<const Comdat *> NonPrevailingComdats;
770 if (Sym.isUndefined())
772 Mod.Keep.push_back(GV);
783 }
else if (isa<GlobalObject>(GV) &&
784 (GV->hasLinkOnceODRLinkage() || GV->hasWeakODRLinkage() ||
785 GV->hasAvailableExternallyLinkage()) &&
786 !AliasedGlobals.
count(cast<GlobalObject>(GV))) {
792 Mod.Keep.push_back(GV);
795 NonPrevailingComdats.insert(GV->getComdat());
796 cast<GlobalObject>(GV)->setComdat(
nullptr);
801 GV->setDSOLocal(
true);
802 if (GV->hasDLLImportStorageClass())
804 DefaultStorageClass);
809 NonPrevailingAsmSymbols.
insert(AS->first);
817 if (Sym.isCommon()) {
820 auto &CommonRes = RegularLTO.Commons[std::string(Sym.getIRName())];
821 CommonRes.Size =
std::max(CommonRes.Size, Sym.getCommonSize());
822 MaybeAlign SymAlign(Sym.getCommonAlignment());
824 CommonRes.Align =
max(*SymAlign, CommonRes.Align);
829 if (!
M.getComdatSymbolTable().empty())
835 if (!
M.getModuleInlineAsm().empty()) {
836 std::string NewIA =
".lto_discard";
837 if (!NonPrevailingAsmSymbols.
empty()) {
841 if (!NonPrevailingAsmSymbols.
count(Alias))
844 NewIA +=
" " + llvm::join(NonPrevailingAsmSymbols,
", ");
847 M.setModuleInlineAsm(NewIA +
M.getModuleInlineAsm());
854 Error LTO::linkRegularLTO(RegularLTOState::AddedModule Mod,
855 bool LivenessFromIndex) {
856 std::vector<GlobalValue *> Keep;
858 if (LivenessFromIndex && !ThinLTO.CombinedIndex.isGUIDLive(GV->
getGUID())) {
859 if (
Function *
F = dyn_cast<Function>(GV)) {
860 if (DiagnosticOutputFile) {
861 if (
Error Err =
F->materialize())
866 <<
" not added to the combined module ");
880 RegularLTO.CombinedModule->getNamedValue(GV->
getName());
887 return RegularLTO.Mover->move(
std::move(
Mod.M), Keep,
nullptr,
897 ThinLTO.ModuleMap.size()))
904 if (!Sym.getIRName().empty()) {
915 if (
auto S = ThinLTO.CombinedIndex.findSummaryInModule(
923 if (
auto S = ThinLTO.CombinedIndex.findSummaryInModule(
925 S->setDSOLocal(
true);
931 if (!ThinLTO.ModuleMap.insert({BM.getModuleIdentifier(), BM}).second)
932 return make_error<StringError>(
933 "Expected at most one ThinLTO module per bitcode file",
937 if (!ThinLTO.ModulesToCompile)
938 ThinLTO.ModulesToCompile = ModuleMapType();
954 CalledGetMaxTasks =
true;
955 auto ModuleCount = ThinLTO.ModulesToCompile ? ThinLTO.ModulesToCompile->size()
956 : ThinLTO.ModuleMap.size();
957 return RegularLTO.ParallelCodeGenParallelismLevel + ModuleCount;
962 Error LTO::checkPartiallySplit() {
963 if (!ThinLTO.CombinedIndex.partiallySplitLTOUnits())
966 Function *TypeTestFunc = RegularLTO.CombinedModule->getFunction(
968 Function *TypeCheckedLoadFunc = RegularLTO.CombinedModule->getFunction(
973 if ((TypeTestFunc && !TypeTestFunc->
use_empty()) ||
974 (TypeCheckedLoadFunc && !TypeCheckedLoadFunc->
use_empty()))
975 return make_error<StringError>(
976 "inconsistent LTO Unit splitting (recompile with -fsplit-lto-unit)",
981 for (
auto &
P : ThinLTO.CombinedIndex) {
982 for (
auto &
S :
P.second.SummaryList) {
983 auto *
FS = dyn_cast<FunctionSummary>(
S.get());
986 if (!
FS->type_test_assume_vcalls().empty() ||
987 !
FS->type_checked_load_vcalls().empty() ||
988 !
FS->type_test_assume_const_vcalls().empty() ||
989 !
FS->type_checked_load_const_vcalls().empty() ||
990 !
FS->type_tests().empty())
991 return make_error<StringError>(
992 "inconsistent LTO Unit splitting (recompile with -fsplit-lto-unit)",
1003 for (
auto &Res : GlobalResolutions) {
1006 if (Res.second.IRName.empty())
1012 if (Res.second.VisibleOutsideSummary && Res.second.
Prevailing)
1013 GUIDPreservedSymbols.
insert(GUID);
1016 DynamicExportSymbols.insert(GUID);
1018 GUIDPrevailingResolutions[GUID] =
1023 auto It = GUIDPrevailingResolutions.
find(
G);
1024 if (It == GUIDPrevailingResolutions.
end())
1033 if (!StatsFileOrErr)
1034 return StatsFileOrErr.takeError();
1035 std::unique_ptr<ToolOutputFile> StatsFile =
std::move(StatsFileOrErr.get());
1037 Error Result = runRegularLTO(AddStream);
1039 Result = runThinLTO(AddStream, Cache, GUIDPreservedSymbols);
1054 return DiagFileOrErr.takeError();
1055 DiagnosticOutputFile =
std::move(*DiagFileOrErr);
1059 for (
auto &M : RegularLTO.ModsWithSummaries)
1068 if (
Error Err = checkPartiallySplit())
1073 const DataLayout &
DL = RegularLTO.CombinedModule->getDataLayout();
1074 for (
auto &
I : RegularLTO.Commons) {
1075 if (!
I.second.Prevailing)
1078 GlobalVariable *OldGV = RegularLTO.CombinedModule->getNamedGlobal(
I.first);
1079 if (OldGV &&
DL.getTypeAllocSize(OldGV->
getValueType()) ==
I.second.Size) {
1087 auto *GV =
new GlobalVariable(*RegularLTO.CombinedModule, Ty,
false,
1090 GV->setAlignment(
I.second.Align);
1104 DynamicExportSymbols);
1111 for (
const auto &R : GlobalResolutions) {
1112 if (!
R.second.isPrevailingIRSymbol())
1114 if (
R.second.Partition != 0 &&
1115 R.second.Partition != GlobalResolution::External)
1119 RegularLTO.CombinedModule->getNamedValue(
R.second.IRName);
1130 RegularLTO.CombinedModule->addModuleFlag(
Module::Error,
"LTOPostLink", 1);
1139 backend(Conf, AddStream, RegularLTO.ParallelCodeGenParallelismLevel,
1140 *RegularLTO.CombinedModule, ThinLTO.CombinedIndex))
1148 #define HANDLE_LIBCALL(code, name) name,
1149 #include "llvm/IR/RuntimeLibcalls.def"
1150 #undef HANDLE_LIBCALL
1167 : Conf(Conf), CombinedIndex(CombinedIndex),
1168 ModuleToDefinedGVSummaries(ModuleToDefinedGVSummaries) {}
1171 virtual Error start(
1175 const std::map<GlobalValue::GUID, GlobalValue::LinkageTypes> &ResolvedODR,
1177 virtual Error wait() = 0;
1178 virtual unsigned getThreadCount() = 0;
1186 std::set<GlobalValue::GUID> CfiFunctionDefs;
1187 std::set<GlobalValue::GUID> CfiFunctionDecls;
1193 InProcessThinBackend(
1199 BackendThreadPool(ThinLTOParallelism), AddStream(
std::
move(AddStream)),
1202 CfiFunctionDefs.insert(
1205 CfiFunctionDecls.insert(
1209 Error runThinLTOBackendThread(
1214 const std::map<GlobalValue::GUID, GlobalValue::LinkageTypes> &ResolvedODR,
1217 auto RunThinBackend = [&](
AddStreamFn AddStream) {
1223 return thinBackend(Conf, Task, AddStream, **MOrErr, CombinedIndex,
1224 ImportList, DefinedGlobals, &ModuleMap);
1231 [](
uint32_t V) { return V == 0; }))
1234 return RunThinBackend(AddStream);
1239 ExportList, ResolvedODR, DefinedGlobals, CfiFunctionDefs,
1244 AddStreamFn &CacheAddStream = *CacheAddStreamOrErr;
1246 return RunThinBackend(CacheAddStream);
1255 const std::map<GlobalValue::GUID, GlobalValue::LinkageTypes> &ResolvedODR,
1258 assert(ModuleToDefinedGVSummaries.
count(ModulePath));
1260 ModuleToDefinedGVSummaries.
find(ModulePath)->second;
1261 BackendThreadPool.
async(
1265 const std::map<GlobalValue::GUID, GlobalValue::LinkageTypes>
1272 Error E = runThinLTOBackendThread(
1273 AddStream, Cache, Task, BM, CombinedIndex, ImportList, ExportList,
1274 ResolvedODR, DefinedGlobals, ModuleMap);
1276 std::unique_lock<std::mutex> L(ErrMu);
1285 BM, std::ref(CombinedIndex), std::ref(ImportList), std::ref(ExportList),
1286 std::ref(ResolvedODR), std::ref(DefinedGlobals), std::ref(ModuleMap));
1290 Error wait()
override {
1291 BackendThreadPool.
wait();
1298 unsigned getThreadCount()
override {
1308 return std::make_unique<InProcessThinBackend>(
1309 Conf, CombinedIndex, Parallelism, ModuleToDefinedGVSummaries, AddStream,
1318 const std::string &OldPrefix,
1319 const std::string &NewPrefix) {
1320 if (OldPrefix.empty() && NewPrefix.empty())
1325 if (!ParentPath.
empty()) {
1328 llvm::errs() <<
"warning: could not create directory '" << ParentPath
1329 <<
"': " << EC.message() <<
'\n';
1331 return std::string(NewPath.
str());
1336 std::string OldPrefix, NewPrefix;
1337 bool ShouldEmitImportsFiles;
1342 WriteIndexesThinBackend(
1345 std::string OldPrefix, std::string NewPrefix,
bool ShouldEmitImportsFiles,
1348 OldPrefix(OldPrefix), NewPrefix(NewPrefix),
1349 ShouldEmitImportsFiles(ShouldEmitImportsFiles),
1350 LinkedObjectsFile(LinkedObjectsFile), OnWrite(OnWrite) {}
1356 const std::map<GlobalValue::GUID, GlobalValue::LinkageTypes> &ResolvedODR,
1359 std::string NewModulePath =
1362 if (LinkedObjectsFile)
1363 *LinkedObjectsFile << NewModulePath <<
'\n';
1365 std::map<std::string, GVSummaryMapTy> ModuleToSummariesForIndex;
1367 ImportList, ModuleToSummariesForIndex);
1376 if (ShouldEmitImportsFiles) {
1378 ModuleToSummariesForIndex);
1384 OnWrite(std::string(ModulePath));
1392 unsigned getThreadCount()
override {
return 1; }
1397 std::string OldPrefix, std::string NewPrefix,
bool ShouldEmitImportsFiles,
1402 return std::make_unique<WriteIndexesThinBackend>(
1403 Conf, CombinedIndex, ModuleToDefinedGVSummaries, OldPrefix, NewPrefix,
1404 ShouldEmitImportsFiles, LinkedObjectsFile, OnWrite);
1415 if (ThinLTO.ModuleMap.empty())
1418 if (ThinLTO.ModulesToCompile && ThinLTO.ModulesToCompile->empty()) {
1419 llvm::errs() <<
"warning: [ThinLTO] No module compiled\n";
1430 ModuleToDefinedGVSummaries(ThinLTO.ModuleMap.size());
1431 ThinLTO.CombinedIndex.collectDefinedGVSummariesPerModule(
1432 ModuleToDefinedGVSummaries);
1440 for (
auto &Mod : ThinLTO.ModuleMap)
1441 if (!ModuleToDefinedGVSummaries.
count(
Mod.first))
1448 ThinLTO.ModuleMap.size());
1450 ThinLTO.ModuleMap.size());
1454 ThinLTO.CombinedIndex.dumpSCCs(
outs());
1456 std::set<GlobalValue::GUID> ExportedGUIDs;
1462 DynamicExportSymbols);
1467 std::map<ValueInfo, std::vector<VTableSlotSummary>> LocalWPDTargetsMap;
1469 LocalWPDTargetsMap);
1473 ImportLists, ExportLists);
1479 for (
auto &Res : GlobalResolutions) {
1482 if (Res.second.Partition != GlobalResolution::External ||
1483 !Res.second.isPrevailingIRSymbol())
1488 if (ThinLTO.CombinedIndex.isGUIDLive(GUID))
1489 ExportedGUIDs.insert(GUID);
1494 for (
auto &
Def : ThinLTO.CombinedIndex.cfiFunctionDefs())
1495 ExportedGUIDs.insert(
1497 for (
auto &Decl : ThinLTO.CombinedIndex.cfiFunctionDecls())
1498 ExportedGUIDs.insert(
1502 const auto &ExportList = ExportLists.
find(ModuleIdentifier);
1503 return (ExportList != ExportLists.end() && ExportList->second.
count(
VI)) ||
1504 ExportedGUIDs.count(
VI.getGUID());
1510 LocalWPDTargetsMap);
1514 return ThinLTO.PrevailingModuleForGUID[GUID] ==
S->modulePath();
1519 auto recordNewLinkage = [&](
StringRef ModuleIdentifier,
1522 ResolvedODR[ModuleIdentifier][GUID] = NewLinkage;
1525 recordNewLinkage, GUIDPreservedSymbols);
1534 TimeTraceScopeExit.release();
1536 std::unique_ptr<ThinBackendProc> BackendProc =
1537 ThinLTO.Backend(Conf, ThinLTO.CombinedIndex, ModuleToDefinedGVSummaries,
1541 ThinLTO.ModulesToCompile ? *ThinLTO.ModulesToCompile : ThinLTO.ModuleMap;
1543 auto ProcessOneModule = [&](
int I) ->
Error {
1547 return BackendProc->start(RegularLTO.ParallelCodeGenParallelismLevel +
I,
1548 Mod.second, ImportLists[
Mod.first],
1549 ExportLists[
Mod.first], ResolvedODR[
Mod.first],
1553 if (BackendProc->getThreadCount() == 1) {
1558 for (
int I = 0,
E = ModuleMap.
size();
I !=
E; ++
I)
1559 if (
Error E = ProcessOneModule(
I))
1566 std::vector<BitcodeModule *> ModulesVec;
1567 ModulesVec.reserve(ModuleMap.
size());
1568 for (
auto &Mod : ModuleMap)
1569 ModulesVec.push_back(&
Mod.second);
1571 if (
Error E = ProcessOneModule(
I))
1574 return BackendProc->wait();
1584 if (!Filename.empty() && Count != -1)
1592 if (
Error E = ResultOrErr.takeError())
1596 (*ResultOrErr)->keep();
1604 if (StatsFilename.
empty())
1622 auto Seq = llvm::seq<int>(0, R.size());
1623 std::vector<int> ModulesOrdering(Seq.begin(), Seq.end());
1624 llvm::sort(ModulesOrdering, [&](
int LeftIndex,
int RightIndex) {
1625 auto LSize = R[LeftIndex]->getBuffer().
size();
1626 auto RSize = R[RightIndex]->getBuffer().
size();
1627 return LSize > RSize;
1629 return ModulesOrdering;
cl::opt< std::string > RemarksPasses("lto-pass-remarks-filter", cl::desc("Only record optimization remarks from passes whose " "names match the given regular expression"), cl::value_desc("regex"))
void eraseFromParent()
eraseFromParent - This method unlinks 'this' from the containing module and deletes it.
Expected< std::unique_ptr< Module > > parseModule(LLVMContext &Context, DataLayoutCallbackTy DataLayoutCallback=[](StringRef) { return None;})
Read the entire bitcode module and return it.
std::function< Expected< AddStreamFn >(unsigned Task, StringRef Key)> FileCache
This is the type of a file cache.
This is an optimization pass for GlobalISel generic memory operations.
We currently emits eax Perhaps this is what we really should generate is Is imull three or four cycles eax eax The current instruction priority is based on pattern complexity The former is more complex because it folds a load so the latter will not be emitted Perhaps we should use AddedComplexity to give LEA32r a higher priority We should always try to match LEA first since the LEA matching code does some estimate to determine whether the match is profitable if we care more about code then imull is better It s two bytes shorter than movl leal On a Pentium M
std::pair< std::string, uint32_t > AsmSymbol
bool replace_path_prefix(SmallVectorImpl< char > &Path, StringRef OldPrefix, StringRef NewPrefix, Style style=Style::native)
Replace matching path prefix with another path.
Error readSummary(ModuleSummaryIndex &CombinedIndex, StringRef ModulePath, uint64_t ModuleId)
Parse the specified bitcode buffer and merge its module summary index into CombinedIndex.
A parsed version of the target data layout string in and methods for querying it.
std::string getGlobalIdentifier() const
Return the modified name for this global value suitable to be used as the key for a global lookup (e....
Expected< IRSymtabFile > readIRSymtab(MemoryBufferRef MBRef)
Reads a bitcode file, creating its irsymtab if necessary.
bool UpgradeDebugInfo(Module &M)
Check the debug info version number, if it is out-dated, drop the debug info.
const ModuleHash & getModuleHash(const StringRef ModPath) const
Get the module SHA1 hash recorded for the given module path.
Error finalizeOptimizationRemarks(std::unique_ptr< ToolOutputFile > DiagOutputFile)
static StringRef dropLLVMManglingEscape(StringRef Name)
If the given string begins with the GlobalValue name mangling escape character '\1',...
A ThreadPool for asynchronous parallel execution on a defined number of threads.
void computeLTOCacheKey(SmallString< 40 > &Key, const lto::Config &Conf, const ModuleSummaryIndex &Index, StringRef ModuleID, const FunctionImporter::ImportMapTy &ImportList, const FunctionImporter::ExportSetTy &ExportList, const std::map< GlobalValue::GUID, GlobalValue::LinkageTypes > &ResolvedODR, const GVSummaryMapTy &DefinedGlobals, const std::set< GlobalValue::GUID > &CfiFunctionDefs={}, const std::set< GlobalValue::GUID > &CfiFunctionDecls={})
Computes a unique hash for the Module considering the current list of export/import and other global ...
CodeGenOpt::Level CGOptLevel
unsigned TimeTraceGranularity
Time trace granularity.
This currently compiles esp xmm0 movsd esp eax eax esp ret We should use not the dag combiner This is because dagcombine2 needs to be able to see through the X86ISD::Wrapper which DAGCombine can t really do The code for turning x load into a single vector load is target independent and should be moved to the dag combiner The code for turning x load into a vector load can only handle a direct load from a global or a direct load from the stack It should be generalized to handle any load from P
std::string RemarksFormat
The format used for serializing remarks (default: YAML).
Optional< CodeModel::Model > CodeModel
bool RemarksWithHotness
Whether to emit optimization remarks with hotness informations.
static void handleNonPrevailingComdat(GlobalValue &GV, std::set< const Comdat * > &NonPrevailingComdats)
void write32le(void *P, uint32_t V)
static bool isLocalLinkage(LinkageTypes Linkage)
iterator find(const_arg_type_t< ValueT > V)
This tells how a thread pool will be used.
std::function< Expected< std::unique_ptr< CachedFileStream > >(unsigned Task)> AddStreamFn
This type defines the callback to add a file that is generated on the fly.
void runWholeProgramDevirtOnIndex(ModuleSummaryIndex &Summary, std::set< GlobalValue::GUID > &ExportedGUIDs, std::map< ValueInfo, std::vector< VTableSlotSummary >> &LocalWPDTargetsMap)
Perform index-based whole program devirtualization on the Summary index.
cl::opt< std::string > RemarksFilename("lto-pass-remarks-output", cl::desc("Output filename for pass remarks"), cl::value_desc("filename"))
StringRef getName(ID id)
Return the LLVM name for an intrinsic, such as "llvm.ppc.altivec.lvx".
static ErrorSuccess success()
Create a success value.
static Constant * getBitCast(Constant *C, Type *Ty, bool OnlyIfReduced=false)
Triple - Helper class for working with autoconf configuration names.
std::vector< std::string > ThinLTOModulesToCompile
Specific thinLTO modules to compile.
ThreadPoolStrategy heavyweight_hardware_concurrency(unsigned ThreadCount=0)
Returns a thread strategy for tasks requiring significant memory or other resources.
std::function< std::unique_ptr< ThinBackendProc >(const Config &C, ModuleSummaryIndex &CombinedIndex, StringMap< GVSummaryMapTy > &ModuleToDefinedGVSummaries, AddStreamFn AddStream, FileCache Cache)> ThinBackend
A ThinBackend defines what happens after the thin-link phase during ThinLTO.
unsigned Prevailing
The linker has chosen this definition of the symbol.
cl::opt< Optional< uint64_t >, false, remarks::HotnessThresholdParser > RemarksHotnessThreshold("lto-pass-remarks-hotness-threshold", cl::desc("Minimum profile count required for an " "optimization remark to be output." " Use 'auto' to apply the threshold from profile summary."), cl::value_desc("uint or 'auto'"), cl::init(0), cl::Hidden)
SmallSet - This maintains a set of unique values, optimizing for the case when the set is small (less...
bool Freestanding
Flag to indicate that the optimizer should not assume builtins are present on the target.
@ DefaultVisibility
The GV is visible.
cl::opt< bool > RemarksWithHotness("lto-pass-remarks-with-hotness", cl::desc("With PGO, include profile count in optimization remarks"), cl::Hidden)
raw_fd_ostream & errs()
This returns a reference to a raw_ostream for standard error.
Expected< std::unique_ptr< ToolOutputFile > > setupLLVMOptimizationRemarks(LLVMContext &Context, StringRef RemarksFilename, StringRef RemarksPasses, StringRef RemarksFormat, bool RemarksWithHotness, Optional< uint64_t > RemarksHotnessThreshold=0, int Count=-1)
Setup optimization remarks.
Tagged union holding either a T or a Error.
void thinLTOResolvePrevailingInIndex(const lto::Config &C, ModuleSummaryIndex &Index, function_ref< bool(GlobalValue::GUID, const GlobalValueSummary *)> isPrevailing, function_ref< void(StringRef, GlobalValue::GUID, GlobalValue::LinkageTypes)> recordNewLinkage, const DenseSet< GlobalValue::GUID > &GUIDPreservedSymbols)
Resolve linkage for prevailing symbols in the Index.
void setUnnamedAddr(UnnamedAddr Val)
LinkageTypes
An enumeration for the kinds of linkage for global values.
Class to represent array types.
iterator find(StringRef Key)
void gatherImportedSummariesForModule(StringRef ModulePath, const StringMap< GVSummaryMapTy > &ModuleToDefinedGVSummaries, const FunctionImporter::ImportMapTy &ImportList, std::map< std::string, GVSummaryMapTy > &ModuleToSummariesForIndex)
Compute the set of summaries needed for a ThinLTO backend compilation of ModulePath.
static bool isLinkOnceODRLinkage(LinkageTypes Linkage)
void generateParamAccessSummary(ModuleSummaryIndex &Index)
bool CodeGenOnly
Disable entirely the optimizer, including importing for ThinLTO.
std::pair< iterator, bool > insert(const ValueT &V)
size_type count(const_arg_type_t< ValueT > V) const
Return 1 if the specified key is in the set, 0 otherwise.
static IntegerType * getInt8Ty(LLVMContext &C)
void timeTraceProfilerFinishThread()
Finish a time trace profiler running on a worker thread.
std::error_code EmitImportsFiles(StringRef ModulePath, StringRef OutputFilename, const std::map< std::string, GVSummaryMapTy > &ModuleToSummariesForIndex)
Emit into OutputFilename the files module ModulePath will import from.
CombinedIndexHookFn CombinedIndexHook
Expected< std::unique_ptr< ToolOutputFile > > setupStatsFile(StringRef StatsFilename)
Setups the output file for saving statistics.
std::string getThinLTOOutputFile(const std::string &Path, const std::string &OldPrefix, const std::string &NewPrefix)
Given the original Path to an output file, replace any path prefix matching OldPrefix with NewPrefix.
void timeTraceProfilerInitialize(unsigned TimeTraceGranularity, StringRef ProcName)
Initialize the time trace profiler.
constexpr bool hasValue() const
StringRef getModuleIdentifier() const
amdgpu Simplify well known AMD library false FunctionCallee Value * Arg
Function and variable summary information to aid decisions and implementation of importing.
bool all_of(R &&range, UnaryPredicate P)
Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly.
static ErrorOr< std::unique_ptr< MemoryBuffer > > getFile(const Twine &Filename, bool IsText=false, bool RequiresNullTerminator=true, bool IsVolatile=false)
Open the specified file as a MemoryBuffer, returning a new MemoryBuffer if successful,...
bool isOSBinFormatELF() const
Tests whether the OS uses the ELF binary format.
bool isDeclaration() const
Return true if the primary definition of this global value is outside of the current translation unit...
VisibilityTypes
An enumeration for the kinds of visibility of global values.
raw_fd_ostream & outs()
This returns a reference to a raw_fd_ostream for standard output.
static bool isAppendingLinkage(LinkageTypes Linkage)
Expected< std::unique_ptr< ToolOutputFile > > setupLLVMOptimizationRemarks(LLVMContext &Context, StringRef RemarksFilename, StringRef RemarksPasses, StringRef RemarksFormat, bool RemarksWithHotness, Optional< uint64_t > RemarksHotnessThreshold=0)
Setup optimization remarks that output to a file.
std::string SampleProfile
Sample PGO profile path.
A class that wrap the SHA1 algorithm.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
void timeTraceProfilerBegin(StringRef Name, StringRef Detail)
Manually begin a time section, with the given Name and Detail.
(vector float) vec_cmpeq(*A, *B) C
Error errorCodeToError(std::error_code EC)
Helper for converting an std::error_code to a Error.
std::array< uint8_t, 20 > result()
Return the current raw 160-bits SHA1 for the digested data since the last call to init().
VisScheme VisibilityScheme
Allows non-imported definitions to get the potentially more constraining visibility from the prevaili...
This struct is a compact representation of a valid (power of two) or undefined (0) alignment.
void computeSyntheticCounts(ModuleSummaryIndex &Index)
Compute synthetic function entry counts.
void thinLTOInternalizeAndPromoteInIndex(ModuleSummaryIndex &Index, function_ref< bool(StringRef, ValueInfo)> isExported, function_ref< bool(GlobalValue::GUID, const GlobalValueSummary *)> isPrevailing)
Update the linkages in the given Index to mark exported values as external and non-exported values as...
LLVM_NODISCARD detail::scope_exit< typename std::decay< Callable >::type > make_scope_exit(Callable &&F)
std::error_code create_directories(const Twine &path, bool IgnoreExisting=true, perms Perms=owner_all|group_all)
Create all the non-existent directories in path.
cl::opt< bool > EnableLTOInternalization("enable-lto-internalization", cl::init(true), cl::Hidden, cl::desc("Enable global value internalization in LTO"))
Enable global value internalization in LTO.
LLVM_NODISCARD bool contains(StringRef Other) const
Return true if the given string is a substring of *this, and false otherwise.
std::unique_ptr< raw_ostream > ResolutionFile
If this field is set, LTO will write input file paths and symbol resolutions here in llvm-lto2 comman...
This class implements an extremely fast bulk output stream that can only output to a stream.
static void thinLTOResolvePrevailingGUID(const Config &C, ValueInfo VI, DenseSet< GlobalValueSummary * > &GlobalInvolvedWithAlias, function_ref< bool(GlobalValue::GUID, const GlobalValueSummary *)> isPrevailing, function_ref< void(StringRef, GlobalValue::GUID, GlobalValue::LinkageTypes)> recordNewLinkage, const DenseSet< GlobalValue::GUID > &GUIDPreservedSymbols)
void setName(const Twine &Name)
Change the name of the value.
unsigned RelaxELFRelocations
@ InternalLinkage
Rename collisions when linking (static functions).
ArrayRef< Symbol > symbols() const
static GUID getGUID(StringRef GlobalName)
Return a 64-bit global unique ID constructed from global value name (i.e.
void addModule(Module *M)
unsigned getMaxTasks() const
Returns an upper bound on the number of tasks that the client may expect.
std::string StatsFile
Statistics output file path.
ModuleHookFn PostInternalizeModuleHook
This hook is called after internalizing the module.
std::string OverrideTriple
Setting this field will replace target triples in input files with this triple.
unsigned getThreadCount() const
StringMap - This is an unconventional map that is specialized for handling keys that are "strings",...
Struct that holds a reference to a particular GUID in a global value summary.
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
cl::opt< std::string > RemarksFormat("lto-pass-remarks-format", cl::desc("The format used for serializing remarks (default: YAML)"), cl::value_desc("format"), cl::init("yaml"))
void updateVCallVisibilityInIndex(ModuleSummaryIndex &Index, bool WholeProgramVisibilityEnabledInLTO, const DenseSet< GlobalValue::GUID > &DynamicExportSymbols)
If whole program visibility asserted, then upgrade all public vcall visibility metadata on vtable def...
An efficient, type-erasing, non-owning reference to a callable.
Implements a dense probed hash-table based set.
std::string RemarksFilename
Optimization remarks file path.
bool hasAvailableExternallyLinkage() const
std::string DefaultTriple
Setting this field will replace unspecified target triples in input files with this triple.
void PrintStatisticsJSON(raw_ostream &OS)
Print statistics in JSON format.
Error backend(const Config &C, AddStreamFn AddStream, unsigned ParallelCodeGenParallelismLevel, Module &M, ModuleSummaryIndex &CombinedIndex)
Runs a regular LTO backend.
Used in the streaming interface as the general argument type.
bar al al movzbl eax ret Missed when stored in a memory object
size_type count(const T &V) const
count - Return 1 if the element is in the set, 0 otherwise.
constexpr LLVM_NODISCARD bool empty() const
empty - Check if the string is empty.
void computeDeadSymbolsWithConstProp(ModuleSummaryIndex &Index, const DenseSet< GlobalValue::GUID > &GUIDPreservedSymbols, function_ref< PrevailingType(GlobalValue::GUID)> isPrevailing, bool ImportEnabled)
Compute dead symbols and run constant propagation in combined index after that.
std::string DwoDir
The directory to store .dwo files.
@ WeakAnyLinkage
Keep one copy of named function when linking (weak)
T dyn_cast() const
Returns the current pointer if it is of the specified pointer type, otherwise returns null.
static std::string toHex(uint64_t V)
compiles ldr LCPI1_0 ldr ldr mov lsr tst moveq r1 ldr LCPI1_1 and r0 bx lr It would be better to do something like to fold the shift into the conditional move
This is an important class for using LLVM in a threaded context.
A derived class of LLVMContext that initializes itself according to a given Config object.
static ArrayRef< const char * > getRuntimeLibcallSymbols()
Static method that returns a list of libcall symbols that can be generated by LTO but might not be vi...
initializer< Ty > init(const Ty &Val)
Error joinErrors(Error E1, Error E2)
Concatenate errors.
void setLinkage(LinkageTypes LT)
void EnableStatistics(bool DoPrintOnExit=true)
Enable the collection and printing of statistics.
iterator find(const_arg_type_t< KeyT > Val)
const StringMap< std::pair< uint64_t, ModuleHash > > & modulePaths() const
Table of modules, containing module hash and id.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
StringRef parent_path(StringRef path, Style style=Style::native)
Get parent path.
static void thinLTOInternalizeAndPromoteGUID(ValueInfo VI, function_ref< bool(StringRef, ValueInfo)> isExported, function_ref< bool(GlobalValue::GUID, const GlobalValueSummary *)> isPrevailing)
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
constexpr const T & getValue() const &
bool hasLocalLinkage() const
void updateIndexWPDForExports(ModuleSummaryIndex &Summary, function_ref< bool(StringRef, ValueInfo)> isExported, std::map< ValueInfo, std::vector< VTableSlotSummary >> &LocalWPDTargetsMap)
Call after cross-module importing to update the recorded single impl devirt target names for any loca...
std::vector< std::string > MAttrs
static ArrayType * get(Type *ElementType, uint64_t NumElements)
This static method is the primary way to construct an ArrayType.
A Module instance is used to store all the information related to an LLVM module.
std::set< std::string > & cfiFunctionDefs()
std::string ProfileRemapping
Name remapping file for profile data.
@ AppendingLinkage
Special purpose, only applies to global arrays.
auto size(R &&Range, std::enable_if_t< std::is_base_of< std::random_access_iterator_tag, typename std::iterator_traits< decltype(Range.begin())>::iterator_category >::value, void > *=nullptr)
Get the size of a range.
void update(ArrayRef< uint8_t > Data)
Digest more data.
static LinkageTypes getWeakLinkage(bool ODR)
Optional< Reloc::Model > RelocModel
void updateVCallVisibilityInModule(Module &M, bool WholeProgramVisibilityEnabledInLTO, const DenseSet< GlobalValue::GUID > &DynamicExportSymbols)
If whole program visibility asserted, then upgrade all public vcall visibility metadata on vtable def...
llvm::Optional< uint64_t > RemarksHotnessThreshold
The minimum hotness value a diagnostic needs in order to be included in optimization diagnostics.
bool HasWholeProgramVisibility
Asserts whether we can assume whole program visibility during the LTO link.
Error thinBackend(const Config &C, unsigned Task, AddStreamFn AddStream, Module &M, const ModuleSummaryIndex &CombinedIndex, const FunctionImporter::ImportMapTy &ImportList, const GVSummaryMapTy &DefinedGlobals, MapVector< StringRef, BitcodeModule > *ModuleMap, const std::vector< uint8_t > &CmdArgs=std::vector< uint8_t >())
Runs a ThinLTO backend.
StringRef - Represent a constant reference to a string, i.e.
Analysis the ScalarEvolution expression for r is this
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
auto async(Function &&F, Args &&...ArgList)
Asynchronous submission of a task to the pool.
bool TimeTraceEnabled
Time trace enabled.
@ WeakODRLinkage
Same, but only replaced by something equivalent.
void replaceAllUsesWith(Value *V)
Change all uses of this to point to a new Value.
ThinBackend createWriteIndexesThinBackend(std::string OldPrefix, std::string NewPrefix, bool ShouldEmitImportsFiles, raw_fd_ostream *LinkedObjectsFile, IndexWriteCallback OnWrite)
Error run(AddStreamFn AddStream, FileCache Cache=nullptr)
Runs the LTO pipeline.
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
add sub stmia L5 ldr r0 bl L_printf $stub Instead of a and a wouldn t it be better to do three moves *Return an aggregate type is even return S
bool AlwaysEmitRegularLTOObj
Always emit a Regular LTO object even when it is empty because no Regular LTO modules were linked.
std::string OptPipeline
If this field is set, the set of passes run in the middle-end optimizer will be the one specified by ...
std::set< std::string > & cfiFunctionDecls()
@ AvailableExternallyLinkage
Available for inspection, not emission.
std::pair< NoneType, bool > insert(const T &V)
insert - Insert an element into the set if it isn't already there.
const GlobalObject * getAliaseeObject() const
@ Error
Emits an error if two values disagree, otherwise the resulting value is that of the operands.
StringRef getName() const
Return a constant reference to the value's name.
A raw_ostream that writes to a file descriptor.
@ CommonLinkage
Tentative definitions.
A discriminated union of two or more pointer types, with the discriminator in the low bit of the poin...
uint32_t getSymbolFlags(Symbol S) const
static bool isLinkOnceLinkage(LinkageTypes Linkage)
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
LTO(Config Conf, ThinBackend Backend=nullptr, unsigned ParallelCodeGenParallelismLevel=1)
Create an LTO object.
Expected< std::unique_ptr< Module > > getLazyModule(LLVMContext &Context, bool ShouldLazyLoadMetadata, bool IsImporting)
Read the bitcode module and prepare for lazy deserialization of function bodies.
DebuggerKind DebuggerTuning
Which debugger to tune for.
void writeIndexToFile(const ModuleSummaryIndex &Index, raw_ostream &Out, const std::map< std::string, GVSummaryMapTy > *ModuleToSummariesForIndex=nullptr)
Write the specified module summary index to the given raw output stream, where it will be written in ...
std::error_code inconvertibleErrorCode()
The value returned by this function can be returned from convertToErrorCode for Error values where no...
static bool isInterposableLinkage(LinkageTypes Linkage)
Whether the definition of this global may be replaced by something non-equivalent at link time.
static void CollectAsmSymvers(const Module &M, function_ref< void(StringRef, StringRef)> AsmSymver)
Parse inline ASM and collect the symvers directives that are defined in the current module.
static bool isWeakObjectWithRWAccess(GlobalValueSummary *GVS)
Ephemeral symbols produced by Reader::symbols() and Reader::module_symbols().
Lightweight error class with error context and mandatory checking.
bool thinLTOPropagateFunctionAttrs(ModuleSummaryIndex &Index, function_ref< bool(GlobalValue::GUID, const GlobalValueSummary *)> isPrevailing)
Propagate function attributes for function summaries along the index's callgraph during thinlink.
bool timeTraceProfilerEnabled()
Is the time trace profiler enabled, i.e. initialized?
const Comdat * getComdat() const
GUID getGUID() const
Return a 64-bit global unique ID constructed from global value name (i.e.
unsigned FinalDefinitionInLinkageUnit
The definition of this symbol is unpreemptable at runtime and is known to be in this linkage unit.
void sort(IteratorTy Start, IteratorTy End)
unsigned DataSections
Emit data into separate sections.
std::function< void(const std::string &)> IndexWriteCallback
This ThinBackend writes individual module indexes to files, instead of running the individual backend...
ModuleHookFn PreOptModuleHook
This module hook is called after linking (regular LTO) or loading (ThinLTO) the module,...
The resolution for a symbol.
const StringMap< GVSummaryMapTy > & ModuleToDefinedGVSummaries
size_type count(StringRef Key) const
count - Return 1 if the element is in the map, 0 otherwise.
ModuleSummaryIndex & CombinedIndex
StringRef str() const
Explicit conversion to StringRef.
static const char * libcallRoutineNames[]
unsigned VisibleToRegularObj
The definition of this symbol is visible outside of the LTO unit.
ArrayRef< T > makeArrayRef(const T &OneElt)
Construct an ArrayRef from a single element.
@ ExternalLinkage
Externally visible function.
DLLStorageClassTypes
Storage classes of global values for PE targets.
Error takeError()
Take ownership of the stored error.
void wait()
Blocking wait for all the threads to complete and the queue to be empty.
std::vector< int > generateModulesOrdering(ArrayRef< BitcodeModule * > R)
Produces a container ordering for optimal multi-threaded processing.
CodeGenFileType CGFileType
void write64le(void *P, uint64_t V)
GlobalValueSummary * getBaseObject()
If this is an alias summary, returns the summary of the aliased object (a global variable or function...
Class to hold module path string table and global value map, and encapsulate methods for operating on...
Align max(MaybeAlign Lhs, Align Rhs)
LLVM_NODISCARD bool empty() const
ThinBackendProc(const Config &Conf, ModuleSummaryIndex &CombinedIndex, const StringMap< GVSummaryMapTy > &ModuleToDefinedGVSummaries)
void ComputeCrossModuleImport(const ModuleSummaryIndex &Index, const StringMap< GVSummaryMapTy > &ModuleToDefinedGVSummaries, StringMap< FunctionImporter::ImportMapTy > &ImportLists, StringMap< FunctionImporter::ExportSetTy > &ExportLists)
Compute all the imports and exports for every module in the Index.
PointerType * getType() const
Global values are always pointers.
void timeTraceProfilerEnd()
Manually end the last time section.
Type * getValueType() const
ThinBackend createInProcessThinBackend(ThreadPoolStrategy Parallelism)
This ThinBackend runs the individual backend jobs in-process.
This class defines the interface to the ThinLTO backend.
Represents a module in a bitcode file.
unsigned FunctionSections
Emit functions into separate sections.
void takeName(Value *V)
Transfer the name from V to this value.
static cl::opt< bool > DumpThinCGSCCs("dump-thin-cg-sccs", cl::init(false), cl::Hidden, cl::desc("Dump the SCCs in the ThinLTO index's callgraph"))
Error add(std::unique_ptr< InputFile > Obj, ArrayRef< SymbolResolution > Res)
Add an input file to the LTO link, using the provided symbol resolutions.
void setAlignment(MaybeAlign Align)
unsigned ExportDynamic
The symbol was exported dynamically, and therefore could be referenced by a shared library not visibl...
StringMapConstIterator< ValueTy > const_iterator
static ConstantAggregateZero * get(Type *Ty)
@ LinkOnceODRLinkage
Same, but only replaced by something equivalent.
unsigned LinkerRedefined
Linker redefined version of the symbol which appeared in -wrap or -defsym linker option.
std::pair< iterator, bool > try_emplace(StringRef Key, ArgsTy &&... Args)
Emplace a new element for the specified key into the map if the key isn't already in the map.
std::string RemarksPasses
Optimization remarks pass filter.
static void writeToResolutionFile(raw_ostream &OS, InputFile *Input, ArrayRef< SymbolResolution > Res)