LLVM  16.0.0git
LTO.cpp
Go to the documentation of this file.
1 //===-LTO.cpp - LLVM Link Time Optimizer ----------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file implements functions and classes used to support LTO.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #include "llvm/LTO/LTO.h"
14 #include "llvm/ADT/ScopeExit.h"
15 #include "llvm/ADT/SmallSet.h"
16 #include "llvm/ADT/Statistic.h"
17 #include "llvm/ADT/StringExtras.h"
24 #include "llvm/CodeGen/Analysis.h"
25 #include "llvm/Config/llvm-config.h"
26 #include "llvm/IR/AutoUpgrade.h"
28 #include "llvm/IR/Intrinsics.h"
31 #include "llvm/IR/Mangler.h"
32 #include "llvm/IR/Metadata.h"
33 #include "llvm/LTO/LTOBackend.h"
35 #include "llvm/Linker/IRMover.h"
36 #include "llvm/MC/TargetRegistry.h"
39 #include "llvm/Support/Error.h"
43 #include "llvm/Support/Path.h"
44 #include "llvm/Support/SHA1.h"
45 #include "llvm/Support/SourceMgr.h"
47 #include "llvm/Support/Threading.h"
50 #include "llvm/Support/VCSRevision.h"
54 #include "llvm/Transforms/IPO.h"
59 
60 #include <set>
61 
62 using namespace llvm;
63 using namespace lto;
64 using namespace object;
65 
66 #define DEBUG_TYPE "lto"
67 
68 static cl::opt<bool>
69  DumpThinCGSCCs("dump-thin-cg-sccs", cl::init(false), cl::Hidden,
70  cl::desc("Dump the SCCs in the ThinLTO index's callgraph"));
71 
72 /// Enable global value internalization in LTO.
74  "enable-lto-internalization", cl::init(true), cl::Hidden,
75  cl::desc("Enable global value internalization in LTO"));
76 
77 // Computes a unique hash for the Module considering the current list of
78 // export/import and other global analysis results.
79 // The hash is produced in \p Key.
81  SmallString<40> &Key, const Config &Conf, const ModuleSummaryIndex &Index,
82  StringRef ModuleID, const FunctionImporter::ImportMapTy &ImportList,
83  const FunctionImporter::ExportSetTy &ExportList,
84  const std::map<GlobalValue::GUID, GlobalValue::LinkageTypes> &ResolvedODR,
85  const GVSummaryMapTy &DefinedGlobals,
86  const std::set<GlobalValue::GUID> &CfiFunctionDefs,
87  const std::set<GlobalValue::GUID> &CfiFunctionDecls) {
88  // Compute the unique hash for this entry.
89  // This is based on the current compiler version, the module itself, the
90  // export list, the hash for every single module in the import list, the
91  // list of ResolvedODR for the module, and the list of preserved symbols.
92  SHA1 Hasher;
93 
94  // Start with the compiler revision
95  Hasher.update(LLVM_VERSION_STRING);
96 #ifdef LLVM_REVISION
97  Hasher.update(LLVM_REVISION);
98 #endif
99 
100  // Include the parts of the LTO configuration that affect code generation.
101  auto AddString = [&](StringRef Str) {
102  Hasher.update(Str);
103  Hasher.update(ArrayRef<uint8_t>{0});
104  };
105  auto AddUnsigned = [&](unsigned I) {
106  uint8_t Data[4];
108  Hasher.update(ArrayRef<uint8_t>{Data, 4});
109  };
110  auto AddUint64 = [&](uint64_t I) {
111  uint8_t Data[8];
113  Hasher.update(ArrayRef<uint8_t>{Data, 8});
114  };
115  AddString(Conf.CPU);
116  // FIXME: Hash more of Options. For now all clients initialize Options from
117  // command-line flags (which is unsupported in production), but may set
118  // RelaxELFRelocations. The clang driver can also pass FunctionSections,
119  // DataSections and DebuggerTuning via command line flags.
120  AddUnsigned(Conf.Options.RelaxELFRelocations);
121  AddUnsigned(Conf.Options.FunctionSections);
122  AddUnsigned(Conf.Options.DataSections);
123  AddUnsigned((unsigned)Conf.Options.DebuggerTuning);
124  for (auto &A : Conf.MAttrs)
125  AddString(A);
126  if (Conf.RelocModel)
127  AddUnsigned(*Conf.RelocModel);
128  else
129  AddUnsigned(-1);
130  if (Conf.CodeModel)
131  AddUnsigned(*Conf.CodeModel);
132  else
133  AddUnsigned(-1);
134  for (const auto &S : Conf.MllvmArgs)
135  AddString(S);
136  AddUnsigned(Conf.CGOptLevel);
137  AddUnsigned(Conf.CGFileType);
138  AddUnsigned(Conf.OptLevel);
139  AddUnsigned(Conf.Freestanding);
140  AddString(Conf.OptPipeline);
141  AddString(Conf.AAPipeline);
142  AddString(Conf.OverrideTriple);
143  AddString(Conf.DefaultTriple);
144  AddString(Conf.DwoDir);
145 
146  // Include the hash for the current module
147  auto ModHash = Index.getModuleHash(ModuleID);
148  Hasher.update(ArrayRef<uint8_t>((uint8_t *)&ModHash[0], sizeof(ModHash)));
149 
150  std::vector<uint64_t> ExportsGUID;
151  ExportsGUID.reserve(ExportList.size());
152  for (const auto &VI : ExportList) {
153  auto GUID = VI.getGUID();
154  ExportsGUID.push_back(GUID);
155  }
156 
157  // Sort the export list elements GUIDs.
158  llvm::sort(ExportsGUID);
159  for (uint64_t GUID : ExportsGUID) {
160  // The export list can impact the internalization, be conservative here
161  Hasher.update(ArrayRef<uint8_t>((uint8_t *)&GUID, sizeof(GUID)));
162  }
163 
164  // Include the hash for every module we import functions from. The set of
165  // imported symbols for each module may affect code generation and is
166  // sensitive to link order, so include that as well.
167  using ImportMapIteratorTy = FunctionImporter::ImportMapTy::const_iterator;
168  std::vector<ImportMapIteratorTy> ImportModulesVector;
169  ImportModulesVector.reserve(ImportList.size());
170 
171  for (ImportMapIteratorTy It = ImportList.begin(); It != ImportList.end();
172  ++It) {
173  ImportModulesVector.push_back(It);
174  }
175  llvm::sort(ImportModulesVector,
176  [](const ImportMapIteratorTy &Lhs, const ImportMapIteratorTy &Rhs)
177  -> bool { return Lhs->getKey() < Rhs->getKey(); });
178  for (const ImportMapIteratorTy &EntryIt : ImportModulesVector) {
179  auto ModHash = Index.getModuleHash(EntryIt->first());
180  Hasher.update(ArrayRef<uint8_t>((uint8_t *)&ModHash[0], sizeof(ModHash)));
181 
182  AddUint64(EntryIt->second.size());
183  for (auto &Fn : EntryIt->second)
184  AddUint64(Fn);
185  }
186 
187  // Include the hash for the resolved ODR.
188  for (auto &Entry : ResolvedODR) {
189  Hasher.update(ArrayRef<uint8_t>((const uint8_t *)&Entry.first,
190  sizeof(GlobalValue::GUID)));
191  Hasher.update(ArrayRef<uint8_t>((const uint8_t *)&Entry.second,
192  sizeof(GlobalValue::LinkageTypes)));
193  }
194 
195  // Members of CfiFunctionDefs and CfiFunctionDecls that are referenced or
196  // defined in this module.
197  std::set<GlobalValue::GUID> UsedCfiDefs;
198  std::set<GlobalValue::GUID> UsedCfiDecls;
199 
200  // Typeids used in this module.
201  std::set<GlobalValue::GUID> UsedTypeIds;
202 
203  auto AddUsedCfiGlobal = [&](GlobalValue::GUID ValueGUID) {
204  if (CfiFunctionDefs.count(ValueGUID))
205  UsedCfiDefs.insert(ValueGUID);
206  if (CfiFunctionDecls.count(ValueGUID))
207  UsedCfiDecls.insert(ValueGUID);
208  };
209 
210  auto AddUsedThings = [&](GlobalValueSummary *GS) {
211  if (!GS) return;
212  AddUnsigned(GS->getVisibility());
213  AddUnsigned(GS->isLive());
214  AddUnsigned(GS->canAutoHide());
215  for (const ValueInfo &VI : GS->refs()) {
216  AddUnsigned(VI.isDSOLocal(Index.withDSOLocalPropagation()));
217  AddUsedCfiGlobal(VI.getGUID());
218  }
219  if (auto *GVS = dyn_cast<GlobalVarSummary>(GS)) {
220  AddUnsigned(GVS->maybeReadOnly());
221  AddUnsigned(GVS->maybeWriteOnly());
222  }
223  if (auto *FS = dyn_cast<FunctionSummary>(GS)) {
224  for (auto &TT : FS->type_tests())
225  UsedTypeIds.insert(TT);
226  for (auto &TT : FS->type_test_assume_vcalls())
227  UsedTypeIds.insert(TT.GUID);
228  for (auto &TT : FS->type_checked_load_vcalls())
229  UsedTypeIds.insert(TT.GUID);
230  for (auto &TT : FS->type_test_assume_const_vcalls())
231  UsedTypeIds.insert(TT.VFunc.GUID);
232  for (auto &TT : FS->type_checked_load_const_vcalls())
233  UsedTypeIds.insert(TT.VFunc.GUID);
234  for (auto &ET : FS->calls()) {
235  AddUnsigned(ET.first.isDSOLocal(Index.withDSOLocalPropagation()));
236  AddUsedCfiGlobal(ET.first.getGUID());
237  }
238  }
239  };
240 
241  // Include the hash for the linkage type to reflect internalization and weak
242  // resolution, and collect any used type identifier resolutions.
243  for (auto &GS : DefinedGlobals) {
244  GlobalValue::LinkageTypes Linkage = GS.second->linkage();
245  Hasher.update(
246  ArrayRef<uint8_t>((const uint8_t *)&Linkage, sizeof(Linkage)));
247  AddUsedCfiGlobal(GS.first);
248  AddUsedThings(GS.second);
249  }
250 
251  // Imported functions may introduce new uses of type identifier resolutions,
252  // so we need to collect their used resolutions as well.
253  for (auto &ImpM : ImportList)
254  for (auto &ImpF : ImpM.second) {
255  GlobalValueSummary *S = Index.findSummaryInModule(ImpF, ImpM.first());
256  AddUsedThings(S);
257  // If this is an alias, we also care about any types/etc. that the aliasee
258  // may reference.
259  if (auto *AS = dyn_cast_or_null<AliasSummary>(S))
260  AddUsedThings(AS->getBaseObject());
261  }
262 
263  auto AddTypeIdSummary = [&](StringRef TId, const TypeIdSummary &S) {
264  AddString(TId);
265 
266  AddUnsigned(S.TTRes.TheKind);
267  AddUnsigned(S.TTRes.SizeM1BitWidth);
268 
269  AddUint64(S.TTRes.AlignLog2);
270  AddUint64(S.TTRes.SizeM1);
271  AddUint64(S.TTRes.BitMask);
272  AddUint64(S.TTRes.InlineBits);
273 
274  AddUint64(S.WPDRes.size());
275  for (auto &WPD : S.WPDRes) {
276  AddUnsigned(WPD.first);
277  AddUnsigned(WPD.second.TheKind);
278  AddString(WPD.second.SingleImplName);
279 
280  AddUint64(WPD.second.ResByArg.size());
281  for (auto &ByArg : WPD.second.ResByArg) {
282  AddUint64(ByArg.first.size());
283  for (uint64_t Arg : ByArg.first)
284  AddUint64(Arg);
285  AddUnsigned(ByArg.second.TheKind);
286  AddUint64(ByArg.second.Info);
287  AddUnsigned(ByArg.second.Byte);
288  AddUnsigned(ByArg.second.Bit);
289  }
290  }
291  };
292 
293  // Include the hash for all type identifiers used by this module.
294  for (GlobalValue::GUID TId : UsedTypeIds) {
295  auto TidIter = Index.typeIds().equal_range(TId);
296  for (auto It = TidIter.first; It != TidIter.second; ++It)
297  AddTypeIdSummary(It->second.first, It->second.second);
298  }
299 
300  AddUnsigned(UsedCfiDefs.size());
301  for (auto &V : UsedCfiDefs)
302  AddUint64(V);
303 
304  AddUnsigned(UsedCfiDecls.size());
305  for (auto &V : UsedCfiDecls)
306  AddUint64(V);
307 
308  if (!Conf.SampleProfile.empty()) {
309  auto FileOrErr = MemoryBuffer::getFile(Conf.SampleProfile);
310  if (FileOrErr) {
311  Hasher.update(FileOrErr.get()->getBuffer());
312 
313  if (!Conf.ProfileRemapping.empty()) {
314  FileOrErr = MemoryBuffer::getFile(Conf.ProfileRemapping);
315  if (FileOrErr)
316  Hasher.update(FileOrErr.get()->getBuffer());
317  }
318  }
319  }
320 
321  Key = toHex(Hasher.result());
322 }
323 
325  const Config &C, ValueInfo VI,
326  DenseSet<GlobalValueSummary *> &GlobalInvolvedWithAlias,
328  isPrevailing,
330  recordNewLinkage,
331  const DenseSet<GlobalValue::GUID> &GUIDPreservedSymbols) {
332  GlobalValue::VisibilityTypes Visibility =
333  C.VisibilityScheme == Config::ELF ? VI.getELFVisibility()
335  for (auto &S : VI.getSummaryList()) {
336  GlobalValue::LinkageTypes OriginalLinkage = S->linkage();
337  // Ignore local and appending linkage values since the linker
338  // doesn't resolve them.
339  if (GlobalValue::isLocalLinkage(OriginalLinkage) ||
341  continue;
342  // We need to emit only one of these. The prevailing module will keep it,
343  // but turned into a weak, while the others will drop it when possible.
344  // This is both a compile-time optimization and a correctness
345  // transformation. This is necessary for correctness when we have exported
346  // a reference - we need to convert the linkonce to weak to
347  // ensure a copy is kept to satisfy the exported reference.
348  // FIXME: We may want to split the compile time and correctness
349  // aspects into separate routines.
350  if (isPrevailing(VI.getGUID(), S.get())) {
351  if (GlobalValue::isLinkOnceLinkage(OriginalLinkage)) {
352  S->setLinkage(GlobalValue::getWeakLinkage(
353  GlobalValue::isLinkOnceODRLinkage(OriginalLinkage)));
354  // The kept copy is eligible for auto-hiding (hidden visibility) if all
355  // copies were (i.e. they were all linkonce_odr global unnamed addr).
356  // If any copy is not (e.g. it was originally weak_odr), then the symbol
357  // must remain externally available (e.g. a weak_odr from an explicitly
358  // instantiated template). Additionally, if it is in the
359  // GUIDPreservedSymbols set, that means that it is visibile outside
360  // the summary (e.g. in a native object or a bitcode file without
361  // summary), and in that case we cannot hide it as it isn't possible to
362  // check all copies.
363  S->setCanAutoHide(VI.canAutoHide() &&
364  !GUIDPreservedSymbols.count(VI.getGUID()));
365  }
366  if (C.VisibilityScheme == Config::FromPrevailing)
367  Visibility = S->getVisibility();
368  }
369  // Alias and aliasee can't be turned into available_externally.
370  else if (!isa<AliasSummary>(S.get()) &&
371  !GlobalInvolvedWithAlias.count(S.get()))
373 
374  // For ELF, set visibility to the computed visibility from summaries. We
375  // don't track visibility from declarations so this may be more relaxed than
376  // the most constraining one.
377  if (C.VisibilityScheme == Config::ELF)
378  S->setVisibility(Visibility);
379 
380  if (S->linkage() != OriginalLinkage)
381  recordNewLinkage(S->modulePath(), VI.getGUID(), S->linkage());
382  }
383 
384  if (C.VisibilityScheme == Config::FromPrevailing) {
385  for (auto &S : VI.getSummaryList()) {
386  GlobalValue::LinkageTypes OriginalLinkage = S->linkage();
387  if (GlobalValue::isLocalLinkage(OriginalLinkage) ||
389  continue;
390  S->setVisibility(Visibility);
391  }
392  }
393 }
394 
395 /// Resolve linkage for prevailing symbols in the \p Index.
396 //
397 // We'd like to drop these functions if they are no longer referenced in the
398 // current module. However there is a chance that another module is still
399 // referencing them because of the import. We make sure we always emit at least
400 // one copy.
402  const Config &C, ModuleSummaryIndex &Index,
404  isPrevailing,
406  recordNewLinkage,
407  const DenseSet<GlobalValue::GUID> &GUIDPreservedSymbols) {
408  // We won't optimize the globals that are referenced by an alias for now
409  // Ideally we should turn the alias into a global and duplicate the definition
410  // when needed.
411  DenseSet<GlobalValueSummary *> GlobalInvolvedWithAlias;
412  for (auto &I : Index)
413  for (auto &S : I.second.SummaryList)
414  if (auto AS = dyn_cast<AliasSummary>(S.get()))
415  GlobalInvolvedWithAlias.insert(&AS->getAliasee());
416 
417  for (auto &I : Index)
418  thinLTOResolvePrevailingGUID(C, Index.getValueInfo(I),
419  GlobalInvolvedWithAlias, isPrevailing,
420  recordNewLinkage, GUIDPreservedSymbols);
421 }
422 
424  if (auto *VarSummary = dyn_cast<GlobalVarSummary>(GVS->getBaseObject()))
425  return !VarSummary->maybeReadOnly() && !VarSummary->maybeWriteOnly() &&
426  (VarSummary->linkage() == GlobalValue::WeakODRLinkage ||
427  VarSummary->linkage() == GlobalValue::LinkOnceODRLinkage);
428  return false;
429 }
430 
432  ValueInfo VI, function_ref<bool(StringRef, ValueInfo)> isExported,
434  isPrevailing) {
435  for (auto &S : VI.getSummaryList()) {
436  if (isExported(S->modulePath(), VI)) {
437  if (GlobalValue::isLocalLinkage(S->linkage()))
438  S->setLinkage(GlobalValue::ExternalLinkage);
439  } else if (EnableLTOInternalization &&
440  // Ignore local and appending linkage values since the linker
441  // doesn't resolve them.
442  !GlobalValue::isLocalLinkage(S->linkage()) &&
443  (!GlobalValue::isInterposableLinkage(S->linkage()) ||
444  isPrevailing(VI.getGUID(), S.get())) &&
445  S->linkage() != GlobalValue::AppendingLinkage &&
446  // We can't internalize available_externally globals because this
447  // can break function pointer equality.
449  // Functions and read-only variables with linkonce_odr and
450  // weak_odr linkage can be internalized. We can't internalize
451  // linkonce_odr and weak_odr variables which are both modified
452  // and read somewhere in the program because reads and writes
453  // will become inconsistent.
454  !isWeakObjectWithRWAccess(S.get()))
455  S->setLinkage(GlobalValue::InternalLinkage);
456  }
457 }
458 
459 // Update the linkages in the given \p Index to mark exported values
460 // as external and non-exported values as internal.
463  function_ref<bool(StringRef, ValueInfo)> isExported,
465  isPrevailing) {
466  for (auto &I : Index)
467  thinLTOInternalizeAndPromoteGUID(Index.getValueInfo(I), isExported,
468  isPrevailing);
469 }
470 
471 // Requires a destructor for std::vector<InputModule>.
472 InputFile::~InputFile() = default;
473 
475  std::unique_ptr<InputFile> File(new InputFile);
476 
478  if (!FOrErr)
479  return FOrErr.takeError();
480 
481  File->TargetTriple = FOrErr->TheReader.getTargetTriple();
482  File->SourceFileName = FOrErr->TheReader.getSourceFileName();
483  File->COFFLinkerOpts = FOrErr->TheReader.getCOFFLinkerOpts();
484  File->DependentLibraries = FOrErr->TheReader.getDependentLibraries();
485  File->ComdatTable = FOrErr->TheReader.getComdatTable();
486 
487  for (unsigned I = 0; I != FOrErr->Mods.size(); ++I) {
488  size_t Begin = File->Symbols.size();
489  for (const irsymtab::Reader::SymbolRef &Sym :
490  FOrErr->TheReader.module_symbols(I))
491  // Skip symbols that are irrelevant to LTO. Note that this condition needs
492  // to match the one in Skip() in LTO::addRegularLTO().
493  if (Sym.isGlobal() && !Sym.isFormatSpecific())
494  File->Symbols.push_back(Sym);
495  File->ModuleSymIndices.push_back({Begin, File->Symbols.size()});
496  }
497 
498  File->Mods = FOrErr->Mods;
499  File->Strtab = std::move(FOrErr->Strtab);
500  return std::move(File);
501 }
502 
504  return Mods[0].getModuleIdentifier();
505 }
506 
508  assert(Mods.size() == 1 && "Expect only one bitcode module");
509  return Mods[0];
510 }
511 
512 LTO::RegularLTOState::RegularLTOState(unsigned ParallelCodeGenParallelismLevel,
513  const Config &Conf)
514  : ParallelCodeGenParallelismLevel(ParallelCodeGenParallelismLevel),
515  Ctx(Conf), CombinedModule(std::make_unique<Module>("ld-temp.o", Ctx)),
516  Mover(std::make_unique<IRMover>(*CombinedModule)) {}
517 
518 LTO::ThinLTOState::ThinLTOState(ThinBackend Backend)
519  : Backend(Backend), CombinedIndex(/*HaveGVs*/ false) {
520  if (!Backend)
521  this->Backend =
523 }
524 
526  unsigned ParallelCodeGenParallelismLevel)
527  : Conf(std::move(Conf)),
528  RegularLTO(ParallelCodeGenParallelismLevel, this->Conf),
529  ThinLTO(std::move(Backend)) {}
530 
531 // Requires a destructor for MapVector<BitcodeModule>.
532 LTO::~LTO() = default;
533 
534 // Add the symbols in the given module to the GlobalResolutions map, and resolve
535 // their partitions.
536 void LTO::addModuleToGlobalRes(ArrayRef<InputFile::Symbol> Syms,
538  unsigned Partition, bool InSummary) {
539  auto *ResI = Res.begin();
540  auto *ResE = Res.end();
541  (void)ResE;
542  const Triple TT(RegularLTO.CombinedModule->getTargetTriple());
543  for (const InputFile::Symbol &Sym : Syms) {
544  assert(ResI != ResE);
545  SymbolResolution Res = *ResI++;
546 
547  StringRef Name = Sym.getName();
548  // Strip the __imp_ prefix from COFF dllimport symbols (similar to the
549  // way they are handled by lld), otherwise we can end up with two
550  // global resolutions (one with and one for a copy of the symbol without).
551  if (TT.isOSBinFormatCOFF() && Name.startswith("__imp_"))
552  Name = Name.substr(strlen("__imp_"));
553  auto &GlobalRes = GlobalResolutions[Name];
554  GlobalRes.UnnamedAddr &= Sym.isUnnamedAddr();
555  if (Res.Prevailing) {
556  assert(!GlobalRes.Prevailing &&
557  "Multiple prevailing defs are not allowed");
558  GlobalRes.Prevailing = true;
559  GlobalRes.IRName = std::string(Sym.getIRName());
560  } else if (!GlobalRes.Prevailing && GlobalRes.IRName.empty()) {
561  // Sometimes it can be two copies of symbol in a module and prevailing
562  // symbol can have no IR name. That might happen if symbol is defined in
563  // module level inline asm block. In case we have multiple modules with
564  // the same symbol we want to use IR name of the prevailing symbol.
565  // Otherwise, if we haven't seen a prevailing symbol, set the name so that
566  // we can later use it to check if there is any prevailing copy in IR.
567  GlobalRes.IRName = std::string(Sym.getIRName());
568  }
569 
570  // Set the partition to external if we know it is re-defined by the linker
571  // with -defsym or -wrap options, used elsewhere, e.g. it is visible to a
572  // regular object, is referenced from llvm.compiler.used/llvm.used, or was
573  // already recorded as being referenced from a different partition.
574  if (Res.LinkerRedefined || Res.VisibleToRegularObj || Sym.isUsed() ||
575  (GlobalRes.Partition != GlobalResolution::Unknown &&
576  GlobalRes.Partition != Partition)) {
577  GlobalRes.Partition = GlobalResolution::External;
578  } else
579  // First recorded reference, save the current partition.
580  GlobalRes.Partition = Partition;
581 
582  // Flag as visible outside of summary if visible from a regular object or
583  // from a module that does not have a summary.
584  GlobalRes.VisibleOutsideSummary |=
585  (Res.VisibleToRegularObj || Sym.isUsed() || !InSummary);
586 
587  GlobalRes.ExportDynamic |= Res.ExportDynamic;
588  }
589 }
590 
593  StringRef Path = Input->getName();
594  OS << Path << '\n';
595  auto ResI = Res.begin();
596  for (const InputFile::Symbol &Sym : Input->symbols()) {
597  assert(ResI != Res.end());
598  SymbolResolution Res = *ResI++;
599 
600  OS << "-r=" << Path << ',' << Sym.getName() << ',';
601  if (Res.Prevailing)
602  OS << 'p';
604  OS << 'l';
605  if (Res.VisibleToRegularObj)
606  OS << 'x';
607  if (Res.LinkerRedefined)
608  OS << 'r';
609  OS << '\n';
610  }
611  OS.flush();
612  assert(ResI == Res.end());
613 }
614 
615 Error LTO::add(std::unique_ptr<InputFile> Input,
617  assert(!CalledGetMaxTasks);
618 
619  if (Conf.ResolutionFile)
620  writeToResolutionFile(*Conf.ResolutionFile, Input.get(), Res);
621 
622  if (RegularLTO.CombinedModule->getTargetTriple().empty()) {
623  RegularLTO.CombinedModule->setTargetTriple(Input->getTargetTriple());
624  if (Triple(Input->getTargetTriple()).isOSBinFormatELF())
626  }
627 
628  const SymbolResolution *ResI = Res.begin();
629  for (unsigned I = 0; I != Input->Mods.size(); ++I)
630  if (Error Err = addModule(*Input, I, ResI, Res.end()))
631  return Err;
632 
633  assert(ResI == Res.end());
634  return Error::success();
635 }
636 
637 Error LTO::addModule(InputFile &Input, unsigned ModI,
638  const SymbolResolution *&ResI,
639  const SymbolResolution *ResE) {
640  Expected<BitcodeLTOInfo> LTOInfo = Input.Mods[ModI].getLTOInfo();
641  if (!LTOInfo)
642  return LTOInfo.takeError();
643 
644  if (EnableSplitLTOUnit) {
645  // If only some modules were split, flag this in the index so that
646  // we can skip or error on optimizations that need consistently split
647  // modules (whole program devirt and lower type tests).
648  if (*EnableSplitLTOUnit != LTOInfo->EnableSplitLTOUnit)
649  ThinLTO.CombinedIndex.setPartiallySplitLTOUnits();
650  } else
651  EnableSplitLTOUnit = LTOInfo->EnableSplitLTOUnit;
652 
653  BitcodeModule BM = Input.Mods[ModI];
654  auto ModSyms = Input.module_symbols(ModI);
655  addModuleToGlobalRes(ModSyms, {ResI, ResE},
656  LTOInfo->IsThinLTO ? ThinLTO.ModuleMap.size() + 1 : 0,
657  LTOInfo->HasSummary);
658 
659  if (LTOInfo->IsThinLTO)
660  return addThinLTO(BM, ModSyms, ResI, ResE);
661 
662  RegularLTO.EmptyCombinedModule = false;
664  addRegularLTO(BM, ModSyms, ResI, ResE);
665  if (!ModOrErr)
666  return ModOrErr.takeError();
667 
668  if (!LTOInfo->HasSummary)
669  return linkRegularLTO(std::move(*ModOrErr), /*LivenessFromIndex=*/false);
670 
671  // Regular LTO module summaries are added to a dummy module that represents
672  // the combined regular LTO module.
673  if (Error Err = BM.readSummary(ThinLTO.CombinedIndex, "", -1ull))
674  return Err;
675  RegularLTO.ModsWithSummaries.push_back(std::move(*ModOrErr));
676  return Error::success();
677 }
678 
679 // Checks whether the given global value is in a non-prevailing comdat
680 // (comdat containing values the linker indicated were not prevailing,
681 // which we then dropped to available_externally), and if so, removes
682 // it from the comdat. This is called for all global values to ensure the
683 // comdat is empty rather than leaving an incomplete comdat. It is needed for
684 // regular LTO modules, in case we are in a mixed-LTO mode (both regular
685 // and thin LTO modules) compilation. Since the regular LTO module will be
686 // linked first in the final native link, we want to make sure the linker
687 // doesn't select any of these incomplete comdats that would be left
688 // in the regular LTO module without this cleanup.
689 static void
691  std::set<const Comdat *> &NonPrevailingComdats) {
692  Comdat *C = GV.getComdat();
693  if (!C)
694  return;
695 
696  if (!NonPrevailingComdats.count(C))
697  return;
698 
699  // Additionally need to drop externally visible global values from the comdat
700  // to available_externally, so that there aren't multiply defined linker
701  // errors.
702  if (!GV.hasLocalLinkage())
704 
705  if (auto GO = dyn_cast<GlobalObject>(&GV))
706  GO->setComdat(nullptr);
707 }
708 
709 // Add a regular LTO object to the link.
710 // The resulting module needs to be linked into the combined LTO module with
711 // linkRegularLTO.
713 LTO::addRegularLTO(BitcodeModule BM, ArrayRef<InputFile::Symbol> Syms,
714  const SymbolResolution *&ResI,
715  const SymbolResolution *ResE) {
716  RegularLTOState::AddedModule Mod;
718  BM.getLazyModule(RegularLTO.Ctx, /*ShouldLazyLoadMetadata*/ true,
719  /*IsImporting*/ false);
720  if (!MOrErr)
721  return MOrErr.takeError();
722  Module &M = **MOrErr;
723  Mod.M = std::move(*MOrErr);
724 
725  if (Error Err = M.materializeMetadata())
726  return std::move(Err);
727  UpgradeDebugInfo(M);
728 
729  ModuleSymbolTable SymTab;
730  SymTab.addModule(&M);
731 
732  for (GlobalVariable &GV : M.globals())
733  if (GV.hasAppendingLinkage())
734  Mod.Keep.push_back(&GV);
735 
736  DenseSet<GlobalObject *> AliasedGlobals;
737  for (auto &GA : M.aliases())
738  if (GlobalObject *GO = GA.getAliaseeObject())
739  AliasedGlobals.insert(GO);
740 
741  // In this function we need IR GlobalValues matching the symbols in Syms
742  // (which is not backed by a module), so we need to enumerate them in the same
743  // order. The symbol enumeration order of a ModuleSymbolTable intentionally
744  // matches the order of an irsymtab, but when we read the irsymtab in
745  // InputFile::create we omit some symbols that are irrelevant to LTO. The
746  // Skip() function skips the same symbols from the module as InputFile does
747  // from the symbol table.
748  auto MsymI = SymTab.symbols().begin(), MsymE = SymTab.symbols().end();
749  auto Skip = [&]() {
750  while (MsymI != MsymE) {
751  auto Flags = SymTab.getSymbolFlags(*MsymI);
752  if ((Flags & object::BasicSymbolRef::SF_Global) &&
754  return;
755  ++MsymI;
756  }
757  };
758  Skip();
759 
760  std::set<const Comdat *> NonPrevailingComdats;
761  SmallSet<StringRef, 2> NonPrevailingAsmSymbols;
762  for (const InputFile::Symbol &Sym : Syms) {
763  assert(ResI != ResE);
764  SymbolResolution Res = *ResI++;
765 
766  assert(MsymI != MsymE);
767  ModuleSymbolTable::Symbol Msym = *MsymI++;
768  Skip();
769 
770  if (GlobalValue *GV = Msym.dyn_cast<GlobalValue *>()) {
771  if (Res.Prevailing) {
772  if (Sym.isUndefined())
773  continue;
774  Mod.Keep.push_back(GV);
775  // For symbols re-defined with linker -wrap and -defsym options,
776  // set the linkage to weak to inhibit IPO. The linkage will be
777  // restored by the linker.
778  if (Res.LinkerRedefined)
779  GV->setLinkage(GlobalValue::WeakAnyLinkage);
780 
781  GlobalValue::LinkageTypes OriginalLinkage = GV->getLinkage();
782  if (GlobalValue::isLinkOnceLinkage(OriginalLinkage))
783  GV->setLinkage(GlobalValue::getWeakLinkage(
784  GlobalValue::isLinkOnceODRLinkage(OriginalLinkage)));
785  } else if (isa<GlobalObject>(GV) &&
786  (GV->hasLinkOnceODRLinkage() || GV->hasWeakODRLinkage() ||
787  GV->hasAvailableExternallyLinkage()) &&
788  !AliasedGlobals.count(cast<GlobalObject>(GV))) {
789  // Any of the above three types of linkage indicates that the
790  // chosen prevailing symbol will have the same semantics as this copy of
791  // the symbol, so we may be able to link it with available_externally
792  // linkage. We will decide later whether to do that when we link this
793  // module (in linkRegularLTO), based on whether it is undefined.
794  Mod.Keep.push_back(GV);
796  if (GV->hasComdat())
797  NonPrevailingComdats.insert(GV->getComdat());
798  cast<GlobalObject>(GV)->setComdat(nullptr);
799  }
800 
801  // Set the 'local' flag based on the linker resolution for this symbol.
803  GV->setDSOLocal(true);
804  if (GV->hasDLLImportStorageClass())
805  GV->setDLLStorageClass(GlobalValue::DLLStorageClassTypes::
806  DefaultStorageClass);
807  }
808  } else if (auto *AS = Msym.dyn_cast<ModuleSymbolTable::AsmSymbol *>()) {
809  // Collect non-prevailing symbols.
810  if (!Res.Prevailing)
811  NonPrevailingAsmSymbols.insert(AS->first);
812  } else {
813  llvm_unreachable("unknown symbol type");
814  }
815 
816  // Common resolution: collect the maximum size/alignment over all commons.
817  // We also record if we see an instance of a common as prevailing, so that
818  // if none is prevailing we can ignore it later.
819  if (Sym.isCommon()) {
820  // FIXME: We should figure out what to do about commons defined by asm.
821  // For now they aren't reported correctly by ModuleSymbolTable.
822  auto &CommonRes = RegularLTO.Commons[std::string(Sym.getIRName())];
823  CommonRes.Size = std::max(CommonRes.Size, Sym.getCommonSize());
824  if (uint32_t SymAlignValue = Sym.getCommonAlignment()) {
825  const Align SymAlign(SymAlignValue);
826  CommonRes.Align = std::max(SymAlign, CommonRes.Align.valueOrOne());
827  }
828  CommonRes.Prevailing |= Res.Prevailing;
829  }
830  }
831 
832  if (!M.getComdatSymbolTable().empty())
833  for (GlobalValue &GV : M.global_values())
834  handleNonPrevailingComdat(GV, NonPrevailingComdats);
835 
836  // Prepend ".lto_discard <sym>, <sym>*" directive to each module inline asm
837  // block.
838  if (!M.getModuleInlineAsm().empty()) {
839  std::string NewIA = ".lto_discard";
840  if (!NonPrevailingAsmSymbols.empty()) {
841  // Don't dicard a symbol if there is a live .symver for it.
843  M, [&](StringRef Name, StringRef Alias) {
844  if (!NonPrevailingAsmSymbols.count(Alias))
845  NonPrevailingAsmSymbols.erase(Name);
846  });
847  NewIA += " " + llvm::join(NonPrevailingAsmSymbols, ", ");
848  }
849  NewIA += "\n";
850  M.setModuleInlineAsm(NewIA + M.getModuleInlineAsm());
851  }
852 
853  assert(MsymI == MsymE);
854  return std::move(Mod);
855 }
856 
857 Error LTO::linkRegularLTO(RegularLTOState::AddedModule Mod,
858  bool LivenessFromIndex) {
859  std::vector<GlobalValue *> Keep;
860  for (GlobalValue *GV : Mod.Keep) {
861  if (LivenessFromIndex && !ThinLTO.CombinedIndex.isGUIDLive(GV->getGUID())) {
862  if (Function *F = dyn_cast<Function>(GV)) {
863  if (DiagnosticOutputFile) {
864  if (Error Err = F->materialize())
865  return Err;
866  OptimizationRemarkEmitter ORE(F, nullptr);
867  ORE.emit(OptimizationRemark(DEBUG_TYPE, "deadfunction", F)
868  << ore::NV("Function", F)
869  << " not added to the combined module ");
870  }
871  }
872  continue;
873  }
874 
875  if (!GV->hasAvailableExternallyLinkage()) {
876  Keep.push_back(GV);
877  continue;
878  }
879 
880  // Only link available_externally definitions if we don't already have a
881  // definition.
882  GlobalValue *CombinedGV =
883  RegularLTO.CombinedModule->getNamedValue(GV->getName());
884  if (CombinedGV && !CombinedGV->isDeclaration())
885  continue;
886 
887  Keep.push_back(GV);
888  }
889 
890  return RegularLTO.Mover->move(std::move(Mod.M), Keep, nullptr,
891  /* IsPerformingImport */ false);
892 }
893 
894 // Add a ThinLTO module to the link.
895 Error LTO::addThinLTO(BitcodeModule BM, ArrayRef<InputFile::Symbol> Syms,
896  const SymbolResolution *&ResI,
897  const SymbolResolution *ResE) {
898  if (Error Err =
899  BM.readSummary(ThinLTO.CombinedIndex, BM.getModuleIdentifier(),
900  ThinLTO.ModuleMap.size()))
901  return Err;
902 
903  for (const InputFile::Symbol &Sym : Syms) {
904  assert(ResI != ResE);
905  SymbolResolution Res = *ResI++;
906 
907  if (!Sym.getIRName().empty()) {
909  Sym.getIRName(), GlobalValue::ExternalLinkage, ""));
910  if (Res.Prevailing) {
911  ThinLTO.PrevailingModuleForGUID[GUID] = BM.getModuleIdentifier();
912 
913  // For linker redefined symbols (via --wrap or --defsym) we want to
914  // switch the linkage to `weak` to prevent IPOs from happening.
915  // Find the summary in the module for this very GV and record the new
916  // linkage so that we can switch it when we import the GV.
917  if (Res.LinkerRedefined)
918  if (auto S = ThinLTO.CombinedIndex.findSummaryInModule(
919  GUID, BM.getModuleIdentifier()))
920  S->setLinkage(GlobalValue::WeakAnyLinkage);
921  }
922 
923  // If the linker resolved the symbol to a local definition then mark it
924  // as local in the summary for the module we are adding.
926  if (auto S = ThinLTO.CombinedIndex.findSummaryInModule(
927  GUID, BM.getModuleIdentifier())) {
928  S->setDSOLocal(true);
929  }
930  }
931  }
932  }
933 
934  if (!ThinLTO.ModuleMap.insert({BM.getModuleIdentifier(), BM}).second)
935  return make_error<StringError>(
936  "Expected at most one ThinLTO module per bitcode file",
938 
939  if (!Conf.ThinLTOModulesToCompile.empty()) {
940  if (!ThinLTO.ModulesToCompile)
941  ThinLTO.ModulesToCompile = ModuleMapType();
942  // This is a fuzzy name matching where only modules with name containing the
943  // specified switch values are going to be compiled.
944  for (const std::string &Name : Conf.ThinLTOModulesToCompile) {
945  if (BM.getModuleIdentifier().contains(Name)) {
946  ThinLTO.ModulesToCompile->insert({BM.getModuleIdentifier(), BM});
947  llvm::errs() << "[ThinLTO] Selecting " << BM.getModuleIdentifier()
948  << " to compile\n";
949  }
950  }
951  }
952 
953  return Error::success();
954 }
955 
956 unsigned LTO::getMaxTasks() const {
957  CalledGetMaxTasks = true;
958  auto ModuleCount = ThinLTO.ModulesToCompile ? ThinLTO.ModulesToCompile->size()
959  : ThinLTO.ModuleMap.size();
960  return RegularLTO.ParallelCodeGenParallelismLevel + ModuleCount;
961 }
962 
963 // If only some of the modules were split, we cannot correctly handle
964 // code that contains type tests or type checked loads.
965 Error LTO::checkPartiallySplit() {
966  if (!ThinLTO.CombinedIndex.partiallySplitLTOUnits())
967  return Error::success();
968 
969  Function *TypeTestFunc = RegularLTO.CombinedModule->getFunction(
970  Intrinsic::getName(Intrinsic::type_test));
971  Function *TypeCheckedLoadFunc = RegularLTO.CombinedModule->getFunction(
972  Intrinsic::getName(Intrinsic::type_checked_load));
973 
974  // First check if there are type tests / type checked loads in the
975  // merged regular LTO module IR.
976  if ((TypeTestFunc && !TypeTestFunc->use_empty()) ||
977  (TypeCheckedLoadFunc && !TypeCheckedLoadFunc->use_empty()))
978  return make_error<StringError>(
979  "inconsistent LTO Unit splitting (recompile with -fsplit-lto-unit)",
981 
982  // Otherwise check if there are any recorded in the combined summary from the
983  // ThinLTO modules.
984  for (auto &P : ThinLTO.CombinedIndex) {
985  for (auto &S : P.second.SummaryList) {
986  auto *FS = dyn_cast<FunctionSummary>(S.get());
987  if (!FS)
988  continue;
989  if (!FS->type_test_assume_vcalls().empty() ||
990  !FS->type_checked_load_vcalls().empty() ||
991  !FS->type_test_assume_const_vcalls().empty() ||
992  !FS->type_checked_load_const_vcalls().empty() ||
993  !FS->type_tests().empty())
994  return make_error<StringError>(
995  "inconsistent LTO Unit splitting (recompile with -fsplit-lto-unit)",
997  }
998  }
999  return Error::success();
1000 }
1001 
1003  // Compute "dead" symbols, we don't want to import/export these!
1004  DenseSet<GlobalValue::GUID> GUIDPreservedSymbols;
1005  DenseMap<GlobalValue::GUID, PrevailingType> GUIDPrevailingResolutions;
1006  for (auto &Res : GlobalResolutions) {
1007  // Normally resolution have IR name of symbol. We can do nothing here
1008  // otherwise. See comments in GlobalResolution struct for more details.
1009  if (Res.second.IRName.empty())
1010  continue;
1011 
1013  GlobalValue::dropLLVMManglingEscape(Res.second.IRName));
1014 
1015  if (Res.second.VisibleOutsideSummary && Res.second.Prevailing)
1016  GUIDPreservedSymbols.insert(GUID);
1017 
1018  if (Res.second.ExportDynamic)
1019  DynamicExportSymbols.insert(GUID);
1020 
1021  GUIDPrevailingResolutions[GUID] =
1023  }
1024 
1025  auto isPrevailing = [&](GlobalValue::GUID G) {
1026  auto It = GUIDPrevailingResolutions.find(G);
1027  if (It == GUIDPrevailingResolutions.end())
1028  return PrevailingType::Unknown;
1029  return It->second;
1030  };
1031  computeDeadSymbolsWithConstProp(ThinLTO.CombinedIndex, GUIDPreservedSymbols,
1032  isPrevailing, Conf.OptLevel > 0);
1033 
1034  // Setup output file to emit statistics.
1035  auto StatsFileOrErr = setupStatsFile(Conf.StatsFile);
1036  if (!StatsFileOrErr)
1037  return StatsFileOrErr.takeError();
1038  std::unique_ptr<ToolOutputFile> StatsFile = std::move(StatsFileOrErr.get());
1039 
1040  Error Result = runRegularLTO(AddStream);
1041  if (!Result)
1042  Result = runThinLTO(AddStream, Cache, GUIDPreservedSymbols);
1043 
1044  if (StatsFile)
1045  PrintStatisticsJSON(StatsFile->os());
1046 
1047  return Result;
1048 }
1049 
1050 Error LTO::runRegularLTO(AddStreamFn AddStream) {
1051  // Setup optimization remarks.
1052  auto DiagFileOrErr = lto::setupLLVMOptimizationRemarks(
1053  RegularLTO.CombinedModule->getContext(), Conf.RemarksFilename,
1056  if (!DiagFileOrErr)
1057  return DiagFileOrErr.takeError();
1058  DiagnosticOutputFile = std::move(*DiagFileOrErr);
1059 
1060  // Finalize linking of regular LTO modules containing summaries now that
1061  // we have computed liveness information.
1062  for (auto &M : RegularLTO.ModsWithSummaries)
1063  if (Error Err = linkRegularLTO(std::move(M),
1064  /*LivenessFromIndex=*/true))
1065  return Err;
1066 
1067  // Ensure we don't have inconsistently split LTO units with type tests.
1068  // FIXME: this checks both LTO and ThinLTO. It happens to work as we take
1069  // this path both cases but eventually this should be split into two and
1070  // do the ThinLTO checks in `runThinLTO`.
1071  if (Error Err = checkPartiallySplit())
1072  return Err;
1073 
1074  // Make sure commons have the right size/alignment: we kept the largest from
1075  // all the prevailing when adding the inputs, and we apply it here.
1076  const DataLayout &DL = RegularLTO.CombinedModule->getDataLayout();
1077  for (auto &I : RegularLTO.Commons) {
1078  if (!I.second.Prevailing)
1079  // Don't do anything if no instance of this common was prevailing.
1080  continue;
1081  GlobalVariable *OldGV = RegularLTO.CombinedModule->getNamedGlobal(I.first);
1082  if (OldGV && DL.getTypeAllocSize(OldGV->getValueType()) == I.second.Size) {
1083  // Don't create a new global if the type is already correct, just make
1084  // sure the alignment is correct.
1085  OldGV->setAlignment(I.second.Align);
1086  continue;
1087  }
1088  ArrayType *Ty =
1089  ArrayType::get(Type::getInt8Ty(RegularLTO.Ctx), I.second.Size);
1090  auto *GV = new GlobalVariable(*RegularLTO.CombinedModule, Ty, false,
1092  ConstantAggregateZero::get(Ty), "");
1093  GV->setAlignment(I.second.Align);
1094  if (OldGV) {
1095  OldGV->replaceAllUsesWith(ConstantExpr::getBitCast(GV, OldGV->getType()));
1096  GV->takeName(OldGV);
1097  OldGV->eraseFromParent();
1098  } else {
1099  GV->setName(I.first);
1100  }
1101  }
1102 
1103  // If allowed, upgrade public vcall visibility metadata to linkage unit
1104  // visibility before whole program devirtualization in the optimizer.
1105  updateVCallVisibilityInModule(*RegularLTO.CombinedModule,
1107  DynamicExportSymbols);
1108  updatePublicTypeTestCalls(*RegularLTO.CombinedModule,
1110 
1111  if (Conf.PreOptModuleHook &&
1112  !Conf.PreOptModuleHook(0, *RegularLTO.CombinedModule))
1113  return finalizeOptimizationRemarks(std::move(DiagnosticOutputFile));
1114 
1115  if (!Conf.CodeGenOnly) {
1116  for (const auto &R : GlobalResolutions) {
1117  if (!R.second.isPrevailingIRSymbol())
1118  continue;
1119  if (R.second.Partition != 0 &&
1120  R.second.Partition != GlobalResolution::External)
1121  continue;
1122 
1123  GlobalValue *GV =
1124  RegularLTO.CombinedModule->getNamedValue(R.second.IRName);
1125  // Ignore symbols defined in other partitions.
1126  // Also skip declarations, which are not allowed to have internal linkage.
1127  if (!GV || GV->hasLocalLinkage() || GV->isDeclaration())
1128  continue;
1129  GV->setUnnamedAddr(R.second.UnnamedAddr ? GlobalValue::UnnamedAddr::Global
1131  if (EnableLTOInternalization && R.second.Partition == 0)
1133  }
1134 
1135  RegularLTO.CombinedModule->addModuleFlag(Module::Error, "LTOPostLink", 1);
1136 
1137  if (Conf.PostInternalizeModuleHook &&
1138  !Conf.PostInternalizeModuleHook(0, *RegularLTO.CombinedModule))
1139  return finalizeOptimizationRemarks(std::move(DiagnosticOutputFile));
1140  }
1141 
1142  if (!RegularLTO.EmptyCombinedModule || Conf.AlwaysEmitRegularLTOObj) {
1143  if (Error Err =
1144  backend(Conf, AddStream, RegularLTO.ParallelCodeGenParallelismLevel,
1145  *RegularLTO.CombinedModule, ThinLTO.CombinedIndex))
1146  return Err;
1147  }
1148 
1149  return finalizeOptimizationRemarks(std::move(DiagnosticOutputFile));
1150 }
1151 
1152 static const char *libcallRoutineNames[] = {
1153 #define HANDLE_LIBCALL(code, name) name,
1154 #include "llvm/IR/RuntimeLibcalls.def"
1155 #undef HANDLE_LIBCALL
1156 };
1157 
1160 }
1161 
1162 /// This class defines the interface to the ThinLTO backend.
1164 protected:
1165  const Config &Conf;
1170 
1171 public:
1172  ThinBackendProc(const Config &Conf, ModuleSummaryIndex &CombinedIndex,
1173  const StringMap<GVSummaryMapTy> &ModuleToDefinedGVSummaries,
1174  lto::IndexWriteCallback OnWrite, bool ShouldEmitImportsFiles)
1175  : Conf(Conf), CombinedIndex(CombinedIndex),
1176  ModuleToDefinedGVSummaries(ModuleToDefinedGVSummaries),
1177  OnWrite(OnWrite), ShouldEmitImportsFiles(ShouldEmitImportsFiles) {}
1178 
1179  virtual ~ThinBackendProc() = default;
1180  virtual Error start(
1181  unsigned Task, BitcodeModule BM,
1182  const FunctionImporter::ImportMapTy &ImportList,
1183  const FunctionImporter::ExportSetTy &ExportList,
1184  const std::map<GlobalValue::GUID, GlobalValue::LinkageTypes> &ResolvedODR,
1185  MapVector<StringRef, BitcodeModule> &ModuleMap) = 0;
1186  virtual Error wait() = 0;
1187  virtual unsigned getThreadCount() = 0;
1188 
1189  // Write sharded indices and (optionally) imports to disk
1191  llvm::StringRef ModulePath,
1192  const std::string &NewModulePath) {
1193  std::map<std::string, GVSummaryMapTy> ModuleToSummariesForIndex;
1194  std::error_code EC;
1195  gatherImportedSummariesForModule(ModulePath, ModuleToDefinedGVSummaries,
1196  ImportList, ModuleToSummariesForIndex);
1197 
1198  raw_fd_ostream OS(NewModulePath + ".thinlto.bc", EC,
1200  if (EC)
1201  return errorCodeToError(EC);
1202  writeIndexToFile(CombinedIndex, OS, &ModuleToSummariesForIndex);
1203 
1204  if (ShouldEmitImportsFiles) {
1205  EC = EmitImportsFiles(ModulePath, NewModulePath + ".imports",
1206  ModuleToSummariesForIndex);
1207  if (EC)
1208  return errorCodeToError(EC);
1209  }
1210  return Error::success();
1211  }
1212 };
1213 
1214 namespace {
1215 class InProcessThinBackend : public ThinBackendProc {
1216  ThreadPool BackendThreadPool;
1217  AddStreamFn AddStream;
1218  FileCache Cache;
1219  std::set<GlobalValue::GUID> CfiFunctionDefs;
1220  std::set<GlobalValue::GUID> CfiFunctionDecls;
1221 
1222  Optional<Error> Err;
1223  std::mutex ErrMu;
1224 
1225  bool ShouldEmitIndexFiles;
1226 
1227 public:
1228  InProcessThinBackend(
1229  const Config &Conf, ModuleSummaryIndex &CombinedIndex,
1230  ThreadPoolStrategy ThinLTOParallelism,
1231  const StringMap<GVSummaryMapTy> &ModuleToDefinedGVSummaries,
1232  AddStreamFn AddStream, FileCache Cache, lto::IndexWriteCallback OnWrite,
1233  bool ShouldEmitIndexFiles, bool ShouldEmitImportsFiles)
1234  : ThinBackendProc(Conf, CombinedIndex, ModuleToDefinedGVSummaries,
1235  OnWrite, ShouldEmitImportsFiles),
1236  BackendThreadPool(ThinLTOParallelism), AddStream(std::move(AddStream)),
1237  Cache(std::move(Cache)), ShouldEmitIndexFiles(ShouldEmitIndexFiles) {
1238  for (auto &Name : CombinedIndex.cfiFunctionDefs())
1239  CfiFunctionDefs.insert(
1241  for (auto &Name : CombinedIndex.cfiFunctionDecls())
1242  CfiFunctionDecls.insert(
1244  }
1245 
1246  Error runThinLTOBackendThread(
1247  AddStreamFn AddStream, FileCache Cache, unsigned Task, BitcodeModule BM,
1248  ModuleSummaryIndex &CombinedIndex,
1249  const FunctionImporter::ImportMapTy &ImportList,
1250  const FunctionImporter::ExportSetTy &ExportList,
1251  const std::map<GlobalValue::GUID, GlobalValue::LinkageTypes> &ResolvedODR,
1252  const GVSummaryMapTy &DefinedGlobals,
1254  auto RunThinBackend = [&](AddStreamFn AddStream) {
1255  LTOLLVMContext BackendContext(Conf);
1256  Expected<std::unique_ptr<Module>> MOrErr = BM.parseModule(BackendContext);
1257  if (!MOrErr)
1258  return MOrErr.takeError();
1259 
1260  return thinBackend(Conf, Task, AddStream, **MOrErr, CombinedIndex,
1261  ImportList, DefinedGlobals, &ModuleMap);
1262  };
1263 
1264  auto ModuleID = BM.getModuleIdentifier();
1265 
1266  if (ShouldEmitIndexFiles) {
1267  if (auto E = emitFiles(ImportList, ModuleID, ModuleID.str()))
1268  return E;
1269  }
1270 
1271  if (!Cache || !CombinedIndex.modulePaths().count(ModuleID) ||
1272  all_of(CombinedIndex.getModuleHash(ModuleID),
1273  [](uint32_t V) { return V == 0; }))
1274  // Cache disabled or no entry for this module in the combined index or
1275  // no module hash.
1276  return RunThinBackend(AddStream);
1277 
1279  // The module may be cached, this helps handling it.
1280  computeLTOCacheKey(Key, Conf, CombinedIndex, ModuleID, ImportList,
1281  ExportList, ResolvedODR, DefinedGlobals, CfiFunctionDefs,
1282  CfiFunctionDecls);
1283  Expected<AddStreamFn> CacheAddStreamOrErr = Cache(Task, Key);
1284  if (Error Err = CacheAddStreamOrErr.takeError())
1285  return Err;
1286  AddStreamFn &CacheAddStream = *CacheAddStreamOrErr;
1287  if (CacheAddStream)
1288  return RunThinBackend(CacheAddStream);
1289 
1290  return Error::success();
1291  }
1292 
1293  Error start(
1294  unsigned Task, BitcodeModule BM,
1295  const FunctionImporter::ImportMapTy &ImportList,
1296  const FunctionImporter::ExportSetTy &ExportList,
1297  const std::map<GlobalValue::GUID, GlobalValue::LinkageTypes> &ResolvedODR,
1298  MapVector<StringRef, BitcodeModule> &ModuleMap) override {
1299  StringRef ModulePath = BM.getModuleIdentifier();
1300  assert(ModuleToDefinedGVSummaries.count(ModulePath));
1301  const GVSummaryMapTy &DefinedGlobals =
1302  ModuleToDefinedGVSummaries.find(ModulePath)->second;
1303  BackendThreadPool.async(
1304  [=](BitcodeModule BM, ModuleSummaryIndex &CombinedIndex,
1305  const FunctionImporter::ImportMapTy &ImportList,
1306  const FunctionImporter::ExportSetTy &ExportList,
1307  const std::map<GlobalValue::GUID, GlobalValue::LinkageTypes>
1308  &ResolvedODR,
1309  const GVSummaryMapTy &DefinedGlobals,
1311  if (LLVM_ENABLE_THREADS && Conf.TimeTraceEnabled)
1313  "thin backend");
1314  Error E = runThinLTOBackendThread(
1315  AddStream, Cache, Task, BM, CombinedIndex, ImportList, ExportList,
1316  ResolvedODR, DefinedGlobals, ModuleMap);
1317  if (E) {
1318  std::unique_lock<std::mutex> L(ErrMu);
1319  if (Err)
1320  Err = joinErrors(std::move(*Err), std::move(E));
1321  else
1322  Err = std::move(E);
1323  }
1324  if (LLVM_ENABLE_THREADS && Conf.TimeTraceEnabled)
1326  },
1327  BM, std::ref(CombinedIndex), std::ref(ImportList), std::ref(ExportList),
1328  std::ref(ResolvedODR), std::ref(DefinedGlobals), std::ref(ModuleMap));
1329 
1330  if (OnWrite)
1331  OnWrite(std::string(ModulePath));
1332  return Error::success();
1333  }
1334 
1335  Error wait() override {
1336  BackendThreadPool.wait();
1337  if (Err)
1338  return std::move(*Err);
1339  else
1340  return Error::success();
1341  }
1342 
1343  unsigned getThreadCount() override {
1344  return BackendThreadPool.getThreadCount();
1345  }
1346 };
1347 } // end anonymous namespace
1348 
1350  lto::IndexWriteCallback OnWrite,
1351  bool ShouldEmitIndexFiles,
1352  bool ShouldEmitImportsFiles) {
1353  return [=](const Config &Conf, ModuleSummaryIndex &CombinedIndex,
1354  const StringMap<GVSummaryMapTy> &ModuleToDefinedGVSummaries,
1355  AddStreamFn AddStream, FileCache Cache) {
1356  return std::make_unique<InProcessThinBackend>(
1357  Conf, CombinedIndex, Parallelism, ModuleToDefinedGVSummaries, AddStream,
1358  Cache, OnWrite, ShouldEmitIndexFiles, ShouldEmitImportsFiles);
1359  };
1360 }
1361 
1362 // Given the original \p Path to an output file, replace any path
1363 // prefix matching \p OldPrefix with \p NewPrefix. Also, create the
1364 // resulting directory if it does not yet exist.
1365 std::string lto::getThinLTOOutputFile(const std::string &Path,
1366  const std::string &OldPrefix,
1367  const std::string &NewPrefix) {
1368  if (OldPrefix.empty() && NewPrefix.empty())
1369  return Path;
1370  SmallString<128> NewPath(Path);
1371  llvm::sys::path::replace_path_prefix(NewPath, OldPrefix, NewPrefix);
1372  StringRef ParentPath = llvm::sys::path::parent_path(NewPath.str());
1373  if (!ParentPath.empty()) {
1374  // Make sure the new directory exists, creating it if necessary.
1375  if (std::error_code EC = llvm::sys::fs::create_directories(ParentPath))
1376  llvm::errs() << "warning: could not create directory '" << ParentPath
1377  << "': " << EC.message() << '\n';
1378  }
1379  return std::string(NewPath.str());
1380 }
1381 
1382 namespace {
1383 class WriteIndexesThinBackend : public ThinBackendProc {
1384  std::string OldPrefix, NewPrefix;
1385  raw_fd_ostream *LinkedObjectsFile;
1386 
1387 public:
1388  WriteIndexesThinBackend(
1389  const Config &Conf, ModuleSummaryIndex &CombinedIndex,
1390  const StringMap<GVSummaryMapTy> &ModuleToDefinedGVSummaries,
1391  std::string OldPrefix, std::string NewPrefix, bool ShouldEmitImportsFiles,
1392  raw_fd_ostream *LinkedObjectsFile, lto::IndexWriteCallback OnWrite)
1393  : ThinBackendProc(Conf, CombinedIndex, ModuleToDefinedGVSummaries,
1394  OnWrite, ShouldEmitImportsFiles),
1395  OldPrefix(OldPrefix), NewPrefix(NewPrefix),
1396  LinkedObjectsFile(LinkedObjectsFile) {}
1397 
1398  Error start(
1399  unsigned Task, BitcodeModule BM,
1400  const FunctionImporter::ImportMapTy &ImportList,
1401  const FunctionImporter::ExportSetTy &ExportList,
1402  const std::map<GlobalValue::GUID, GlobalValue::LinkageTypes> &ResolvedODR,
1403  MapVector<StringRef, BitcodeModule> &ModuleMap) override {
1404  StringRef ModulePath = BM.getModuleIdentifier();
1405  std::string NewModulePath =
1406  getThinLTOOutputFile(std::string(ModulePath), OldPrefix, NewPrefix);
1407 
1408  if (LinkedObjectsFile)
1409  *LinkedObjectsFile << NewModulePath << '\n';
1410 
1411  if (auto E = emitFiles(ImportList, ModulePath, NewModulePath))
1412  return E;
1413 
1414  if (OnWrite)
1415  OnWrite(std::string(ModulePath));
1416  return Error::success();
1417  }
1418 
1419  Error wait() override { return Error::success(); }
1420 
1421  // WriteIndexesThinBackend should always return 1 to prevent module
1422  // re-ordering and avoid non-determinism in the final link.
1423  unsigned getThreadCount() override { return 1; }
1424 };
1425 } // end anonymous namespace
1426 
1428  std::string OldPrefix, std::string NewPrefix, bool ShouldEmitImportsFiles,
1429  raw_fd_ostream *LinkedObjectsFile, IndexWriteCallback OnWrite) {
1430  return [=](const Config &Conf, ModuleSummaryIndex &CombinedIndex,
1431  const StringMap<GVSummaryMapTy> &ModuleToDefinedGVSummaries,
1432  AddStreamFn AddStream, FileCache Cache) {
1433  return std::make_unique<WriteIndexesThinBackend>(
1434  Conf, CombinedIndex, ModuleToDefinedGVSummaries, OldPrefix, NewPrefix,
1435  ShouldEmitImportsFiles, LinkedObjectsFile, OnWrite);
1436  };
1437 }
1438 
1439 Error LTO::runThinLTO(AddStreamFn AddStream, FileCache Cache,
1440  const DenseSet<GlobalValue::GUID> &GUIDPreservedSymbols) {
1441  timeTraceProfilerBegin("ThinLink", StringRef(""));
1442  auto TimeTraceScopeExit = llvm::make_scope_exit([]() {
1445  });
1446  if (ThinLTO.ModuleMap.empty())
1447  return Error::success();
1448 
1449  if (ThinLTO.ModulesToCompile && ThinLTO.ModulesToCompile->empty()) {
1450  llvm::errs() << "warning: [ThinLTO] No module compiled\n";
1451  return Error::success();
1452  }
1453 
1454  if (Conf.CombinedIndexHook &&
1455  !Conf.CombinedIndexHook(ThinLTO.CombinedIndex, GUIDPreservedSymbols))
1456  return Error::success();
1457 
1458  // Collect for each module the list of function it defines (GUID ->
1459  // Summary).
1461  ModuleToDefinedGVSummaries(ThinLTO.ModuleMap.size());
1462  ThinLTO.CombinedIndex.collectDefinedGVSummariesPerModule(
1463  ModuleToDefinedGVSummaries);
1464  // Create entries for any modules that didn't have any GV summaries
1465  // (either they didn't have any GVs to start with, or we suppressed
1466  // generation of the summaries because they e.g. had inline assembly
1467  // uses that couldn't be promoted/renamed on export). This is so
1468  // InProcessThinBackend::start can still launch a backend thread, which
1469  // is passed the map of summaries for the module, without any special
1470  // handling for this case.
1471  for (auto &Mod : ThinLTO.ModuleMap)
1472  if (!ModuleToDefinedGVSummaries.count(Mod.first))
1473  ModuleToDefinedGVSummaries.try_emplace(Mod.first);
1474 
1475  // Synthesize entry counts for functions in the CombinedIndex.
1476  computeSyntheticCounts(ThinLTO.CombinedIndex);
1477 
1479  ThinLTO.ModuleMap.size());
1481  ThinLTO.ModuleMap.size());
1483 
1484  if (DumpThinCGSCCs)
1485  ThinLTO.CombinedIndex.dumpSCCs(outs());
1486 
1487  std::set<GlobalValue::GUID> ExportedGUIDs;
1488 
1490  ThinLTO.CombinedIndex.setWithWholeProgramVisibility();
1491  // If allowed, upgrade public vcall visibility to linkage unit visibility in
1492  // the summaries before whole program devirtualization below.
1493  updateVCallVisibilityInIndex(ThinLTO.CombinedIndex,
1495  DynamicExportSymbols);
1496 
1497  // Perform index-based WPD. This will return immediately if there are
1498  // no index entries in the typeIdMetadata map (e.g. if we are instead
1499  // performing IR-based WPD in hybrid regular/thin LTO mode).
1500  std::map<ValueInfo, std::vector<VTableSlotSummary>> LocalWPDTargetsMap;
1501  runWholeProgramDevirtOnIndex(ThinLTO.CombinedIndex, ExportedGUIDs,
1502  LocalWPDTargetsMap);
1503 
1504  if (Conf.OptLevel > 0)
1505  ComputeCrossModuleImport(ThinLTO.CombinedIndex, ModuleToDefinedGVSummaries,
1506  ImportLists, ExportLists);
1507 
1508  // Figure out which symbols need to be internalized. This also needs to happen
1509  // at -O0 because summary-based DCE is implemented using internalization, and
1510  // we must apply DCE consistently with the full LTO module in order to avoid
1511  // undefined references during the final link.
1512  for (auto &Res : GlobalResolutions) {
1513  // If the symbol does not have external references or it is not prevailing,
1514  // then not need to mark it as exported from a ThinLTO partition.
1515  if (Res.second.Partition != GlobalResolution::External ||
1516  !Res.second.isPrevailingIRSymbol())
1517  continue;
1518  auto GUID = GlobalValue::getGUID(
1519  GlobalValue::dropLLVMManglingEscape(Res.second.IRName));
1520  // Mark exported unless index-based analysis determined it to be dead.
1521  if (ThinLTO.CombinedIndex.isGUIDLive(GUID))
1522  ExportedGUIDs.insert(GUID);
1523  }
1524 
1525  // Any functions referenced by the jump table in the regular LTO object must
1526  // be exported.
1527  for (auto &Def : ThinLTO.CombinedIndex.cfiFunctionDefs())
1528  ExportedGUIDs.insert(
1530  for (auto &Decl : ThinLTO.CombinedIndex.cfiFunctionDecls())
1531  ExportedGUIDs.insert(
1533 
1534  auto isExported = [&](StringRef ModuleIdentifier, ValueInfo VI) {
1535  const auto &ExportList = ExportLists.find(ModuleIdentifier);
1536  return (ExportList != ExportLists.end() && ExportList->second.count(VI)) ||
1537  ExportedGUIDs.count(VI.getGUID());
1538  };
1539 
1540  // Update local devirtualized targets that were exported by cross-module
1541  // importing or by other devirtualizations marked in the ExportedGUIDs set.
1542  updateIndexWPDForExports(ThinLTO.CombinedIndex, isExported,
1543  LocalWPDTargetsMap);
1544 
1545  auto isPrevailing = [&](GlobalValue::GUID GUID,
1546  const GlobalValueSummary *S) {
1547  return ThinLTO.PrevailingModuleForGUID[GUID] == S->modulePath();
1548  };
1549  thinLTOInternalizeAndPromoteInIndex(ThinLTO.CombinedIndex, isExported,
1550  isPrevailing);
1551 
1552  auto recordNewLinkage = [&](StringRef ModuleIdentifier,
1553  GlobalValue::GUID GUID,
1554  GlobalValue::LinkageTypes NewLinkage) {
1555  ResolvedODR[ModuleIdentifier][GUID] = NewLinkage;
1556  };
1557  thinLTOResolvePrevailingInIndex(Conf, ThinLTO.CombinedIndex, isPrevailing,
1558  recordNewLinkage, GUIDPreservedSymbols);
1559 
1560  thinLTOPropagateFunctionAttrs(ThinLTO.CombinedIndex, isPrevailing);
1561 
1562  generateParamAccessSummary(ThinLTO.CombinedIndex);
1563 
1566 
1567  TimeTraceScopeExit.release();
1568 
1569  std::unique_ptr<ThinBackendProc> BackendProc =
1570  ThinLTO.Backend(Conf, ThinLTO.CombinedIndex, ModuleToDefinedGVSummaries,
1571  AddStream, Cache);
1572 
1573  auto &ModuleMap =
1574  ThinLTO.ModulesToCompile ? *ThinLTO.ModulesToCompile : ThinLTO.ModuleMap;
1575 
1576  auto ProcessOneModule = [&](int I) -> Error {
1577  auto &Mod = *(ModuleMap.begin() + I);
1578  // Tasks 0 through ParallelCodeGenParallelismLevel-1 are reserved for
1579  // combined module and parallel code generation partitions.
1580  return BackendProc->start(RegularLTO.ParallelCodeGenParallelismLevel + I,
1581  Mod.second, ImportLists[Mod.first],
1582  ExportLists[Mod.first], ResolvedODR[Mod.first],
1583  ThinLTO.ModuleMap);
1584  };
1585 
1586  if (BackendProc->getThreadCount() == 1) {
1587  // Process the modules in the order they were provided on the command-line.
1588  // It is important for this codepath to be used for WriteIndexesThinBackend,
1589  // to ensure the emitted LinkedObjectsFile lists ThinLTO objects in the same
1590  // order as the inputs, which otherwise would affect the final link order.
1591  for (int I = 0, E = ModuleMap.size(); I != E; ++I)
1592  if (Error E = ProcessOneModule(I))
1593  return E;
1594  } else {
1595  // When executing in parallel, process largest bitsize modules first to
1596  // improve parallelism, and avoid starving the thread pool near the end.
1597  // This saves about 15 sec on a 36-core machine while link `clang.exe` (out
1598  // of 100 sec).
1599  std::vector<BitcodeModule *> ModulesVec;
1600  ModulesVec.reserve(ModuleMap.size());
1601  for (auto &Mod : ModuleMap)
1602  ModulesVec.push_back(&Mod.second);
1603  for (int I : generateModulesOrdering(ModulesVec))
1604  if (Error E = ProcessOneModule(I))
1605  return E;
1606  }
1607  return BackendProc->wait();
1608 }
1609 
1614  std::string Filename = std::string(RemarksFilename);
1615  // For ThinLTO, file.opt.<format> becomes
1616  // file.opt.<format>.thin.<num>.<format>.
1617  if (!Filename.empty() && Count != -1)
1618  Filename =
1619  (Twine(Filename) + ".thin." + llvm::utostr(Count) + "." + RemarksFormat)
1620  .str();
1621 
1622  auto ResultOrErr = llvm::setupLLVMOptimizationRemarks(
1625  if (Error E = ResultOrErr.takeError())
1626  return std::move(E);
1627 
1628  if (*ResultOrErr)
1629  (*ResultOrErr)->keep();
1630 
1631  return ResultOrErr;
1632 }
1633 
1636  // Setup output file to emit statistics.
1637  if (StatsFilename.empty())
1638  return nullptr;
1639 
1640  llvm::EnableStatistics(false);
1641  std::error_code EC;
1642  auto StatsFile =
1643  std::make_unique<ToolOutputFile>(StatsFilename, EC, sys::fs::OF_None);
1644  if (EC)
1645  return errorCodeToError(EC);
1646 
1647  StatsFile->keep();
1648  return std::move(StatsFile);
1649 }
1650 
1651 // Compute the ordering we will process the inputs: the rough heuristic here
1652 // is to sort them per size so that the largest module get schedule as soon as
1653 // possible. This is purely a compile-time optimization.
1655  auto Seq = llvm::seq<int>(0, R.size());
1656  std::vector<int> ModulesOrdering(Seq.begin(), Seq.end());
1657  llvm::sort(ModulesOrdering, [&](int LeftIndex, int RightIndex) {
1658  auto LSize = R[LeftIndex]->getBuffer().size();
1659  auto RSize = R[RightIndex]->getBuffer().size();
1660  return LSize > RSize;
1661  });
1662  return ModulesOrdering;
1663 }
llvm::RemarksPasses
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"))
Definition: ThinLTOCodeGenerator.cpp:79
MemoryBuffer.h
StackSafetyAnalysis.h
llvm::GlobalVariable::eraseFromParent
void eraseFromParent()
eraseFromParent - This method unlinks 'this' from the containing module and deletes it.
Definition: Globals.cpp:464
llvm::BitcodeModule::parseModule
Expected< std::unique_ptr< Module > > parseModule(LLVMContext &Context, DataLayoutCallbackTy DataLayoutCallback=[](StringRef) { return None;})
Read the entire bitcode module and return it.
Definition: BitcodeReader.cpp:7913
llvm::FileCache
std::function< Expected< AddStreamFn >(unsigned Task, StringRef Key)> FileCache
This is the type of a file cache.
Definition: Caching.h:56
FunctionImportUtils.h
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
llvm::tgtok::Def
@ Def
Definition: TGLexer.h:50
M
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
Definition: README.txt:252
llvm::ModuleSymbolTable::AsmSymbol
std::pair< std::string, uint32_t > AsmSymbol
Definition: ModuleSymbolTable.h:35
llvm::sys::path::replace_path_prefix
bool replace_path_prefix(SmallVectorImpl< char > &Path, StringRef OldPrefix, StringRef NewPrefix, Style style=Style::native)
Replace matching path prefix with another path.
Definition: Path.cpp:518
llvm::BitcodeModule::readSummary
Error readSummary(ModuleSummaryIndex &CombinedIndex, StringRef ModulePath, uint64_t ModuleId)
Parse the specified bitcode buffer and merge its module summary index into CombinedIndex.
Definition: BitcodeReader.cpp:7756
llvm::DataLayout
A parsed version of the target data layout string in and methods for querying it.
Definition: DataLayout.h:113
FileSystem.h
llvm::sys::fs::OF_None
@ OF_None
Definition: FileSystem.h:757
llvm::GlobalValue::getGlobalIdentifier
std::string getGlobalIdentifier() const
Return the modified name for this global value suitable to be used as the key for a global lookup (e....
Definition: Globals.cpp:166
Metadata.h
llvm::object::readIRSymtab
Expected< IRSymtabFile > readIRSymtab(MemoryBufferRef MBRef)
Reads a bitcode file, creating its irsymtab if necessary.
Definition: IRObjectFile.cpp:136
llvm::UpgradeDebugInfo
bool UpgradeDebugInfo(Module &M)
Check the debug info version number, if it is out-dated, drop the debug info.
Definition: AutoUpgrade.cpp:4320
llvm::lto::InputFile::Symbol
The purpose of this class is to only expose the symbol information that an LTO client should need in ...
Definition: LTO.h:133
llvm::ModuleSummaryIndex::getModuleHash
const ModuleHash & getModuleHash(const StringRef ModPath) const
Get the module SHA1 hash recorded for the given module path.
Definition: ModuleSummaryIndex.h:1459
llvm::lto::finalizeOptimizationRemarks
Error finalizeOptimizationRemarks(std::unique_ptr< ToolOutputFile > DiagOutputFile)
Definition: LTOBackend.cpp:482
llvm::GlobalValue::dropLLVMManglingEscape
static StringRef dropLLVMManglingEscape(StringRef Name)
If the given string begins with the GlobalValue name mangling escape character '\1',...
Definition: GlobalValue.h:560
llvm::ThreadPool
A ThreadPool for asynchronous parallel execution on a defined number of threads.
Definition: ThreadPool.h:52
llvm::computeLTOCacheKey
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 ...
Definition: LTO.cpp:80
llvm::lto::Config::CGOptLevel
CodeGenOpt::Level CGOptLevel
Definition: Config.h:56
llvm::Function
Definition: Function.h:60
llvm::lto::Config::TimeTraceGranularity
unsigned TimeTraceGranularity
Time trace granularity.
Definition: Config.h:173
P
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
Definition: README-SSE.txt:411
llvm::lto::Config::RemarksFormat
std::string RemarksFormat
The format used for serializing remarks (default: YAML).
Definition: Config.h:158
llvm::lto::ThinBackendProc::ThinBackendProc
ThinBackendProc(const Config &Conf, ModuleSummaryIndex &CombinedIndex, const StringMap< GVSummaryMapTy > &ModuleToDefinedGVSummaries, lto::IndexWriteCallback OnWrite, bool ShouldEmitImportsFiles)
Definition: LTO.cpp:1172
llvm::lto::Config::CodeModel
Optional< CodeModel::Model > CodeModel
Definition: Config.h:55
Statistic.h
llvm::ZeroCallUsedRegs::ZeroCallUsedRegsKind::Skip
@ Skip
llvm::lto::Config::RemarksWithHotness
bool RemarksWithHotness
Whether to emit optimization remarks with hotness informations.
Definition: Config.h:140
handleNonPrevailingComdat
static void handleNonPrevailingComdat(GlobalValue &GV, std::set< const Comdat * > &NonPrevailingComdats)
Definition: LTO.cpp:690
Path.h
llvm::support::endian::write32le
void write32le(void *P, uint32_t V)
Definition: Endian.h:416
DEBUG_TYPE
#define DEBUG_TYPE
Definition: LTO.cpp:66
llvm::GlobalValue::isLocalLinkage
static bool isLocalLinkage(LinkageTypes Linkage)
Definition: GlobalValue.h:402
llvm::detail::DenseSetImpl::find
iterator find(const_arg_type_t< ValueT > V)
Definition: DenseSet.h:179
llvm::ThreadPoolStrategy
This tells how a thread pool will be used.
Definition: Threading.h:116
llvm::AddStreamFn
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.
Definition: Caching.h:42
llvm::GlobalValue::UnnamedAddr::None
@ None
llvm::runWholeProgramDevirtOnIndex
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.
Definition: WholeProgramDevirt.cpp:855
llvm::RemarksFilename
cl::opt< std::string > RemarksFilename("lto-pass-remarks-output", cl::desc("Output filename for pass remarks"), cl::value_desc("filename"))
Definition: ThinLTOCodeGenerator.cpp:78
ManagedStatic.h
llvm::Intrinsic::getName
StringRef getName(ID id)
Return the LLVM name for an intrinsic, such as "llvm.ppc.altivec.lvx".
Definition: Function.cpp:882
llvm::lto::InputFile::getSingleBitcodeModule
BitcodeModule & getSingleBitcodeModule()
Definition: LTO.cpp:507
llvm::Error::success
static ErrorSuccess success()
Create a success value.
Definition: Error.h:329
llvm::GlobalVariable
Definition: GlobalVariable.h:39
llvm::ConstantExpr::getBitCast
static Constant * getBitCast(Constant *C, Type *Ty, bool OnlyIfReduced=false)
Definition: Constants.cpp:2202
Error.h
OptimizationRemarkEmitter.h
llvm::lto::ThinBackendProc::Conf
const Config & Conf
Definition: LTO.cpp:1165
llvm::Triple
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:44
llvm::lto::InputFile::~InputFile
~InputFile()
llvm::lto::Config::ThinLTOModulesToCompile
std::vector< std::string > ThinLTOModulesToCompile
Specific thinLTO modules to compile.
Definition: Config.h:167
llvm::cl::Hidden
@ Hidden
Definition: CommandLine.h:140
llvm::heavyweight_hardware_concurrency
ThreadPoolStrategy heavyweight_hardware_concurrency(unsigned ThreadCount=0)
Returns a thread strategy for tasks requiring significant memory or other resources.
Definition: Threading.h:162
llvm::lto::ThinBackend
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.
Definition: LTO.h:196
llvm::lto::SymbolResolution::Prevailing
unsigned Prevailing
The linker has chosen this definition of the symbol.
Definition: LTO.h:436
llvm::StringMap::end
iterator end()
Definition: StringMap.h:204
llvm::X86AS::FS
@ FS
Definition: X86.h:200
llvm::RemarksHotnessThreshold
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)
Definition: ThinLTOCodeGenerator.cpp:82
llvm::SmallSet
SmallSet - This maintains a set of unique values, optimizing for the case when the set is small (less...
Definition: SmallSet.h:136
llvm::GlobalValue::UnnamedAddr::Global
@ Global
llvm::lto::Config
LTO configuration.
Definition: Config.h:40
llvm::Optional
Definition: APInt.h:33
llvm::lto::Config::Freestanding
bool Freestanding
Flag to indicate that the optimizer should not assume builtins are present on the target.
Definition: Config.h:66
llvm::GlobalValue::DefaultVisibility
@ DefaultVisibility
The GV is visible.
Definition: GlobalValue.h:63
llvm::MapVector< StringRef, BitcodeModule >
llvm::RemarksWithHotness
cl::opt< bool > RemarksWithHotness("lto-pass-remarks-with-hotness", cl::desc("With PGO, include profile count in optimization remarks"), cl::Hidden)
Definition: ThinLTOCodeGenerator.cpp:80
llvm::max
Expected< ExpressionValue > max(const ExpressionValue &Lhs, const ExpressionValue &Rhs)
Definition: FileCheck.cpp:337
llvm::errs
raw_fd_ostream & errs()
This returns a reference to a raw_ostream for standard error.
Definition: raw_ostream.cpp:891
llvm::lto::setupLLVMOptimizationRemarks
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.
Definition: LTO.cpp:1610
llvm::Expected
Tagged union holding either a T or a Error.
Definition: APFloat.h:41
llvm::thinLTOResolvePrevailingInIndex
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.
Definition: LTO.cpp:401
llvm::GlobalValue::setUnnamedAddr
void setUnnamedAddr(UnnamedAddr Val)
Definition: GlobalValue.h:225
llvm::GlobalValue::LinkageTypes
LinkageTypes
An enumeration for the kinds of linkage for global values.
Definition: GlobalValue.h:47
llvm::ArrayType
Class to represent array types.
Definition: DerivedTypes.h:357
llvm::StringMap::find
iterator find(StringRef Key)
Definition: StringMap.h:217
llvm::gatherImportedSummariesForModule
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.
Definition: FunctionImport.cpp:976
llvm::GlobalValue::isLinkOnceODRLinkage
static bool isLinkOnceODRLinkage(LinkageTypes Linkage)
Definition: GlobalValue.h:378
llvm::generateParamAccessSummary
void generateParamAccessSummary(ModuleSummaryIndex &Index)
Definition: StackSafetyAnalysis.cpp:1103
llvm::lto::Config::CodeGenOnly
bool CodeGenOnly
Disable entirely the optimizer, including importing for ThinLTO.
Definition: Config.h:69
llvm::detail::DenseSetImpl< ValueT, DenseMap< ValueT, detail::DenseSetEmpty, DenseMapInfo< ValueT >, detail::DenseSetPair< ValueT > >, DenseMapInfo< ValueT > >::insert
std::pair< iterator, bool > insert(const ValueT &V)
Definition: DenseSet.h:206
LegacyPassManager.h
llvm::detail::DenseSetImpl< ValueT, DenseMap< ValueT, detail::DenseSetEmpty, DenseMapInfo< ValueT >, detail::DenseSetPair< ValueT > >, DenseMapInfo< ValueT > >::count
size_type count(const_arg_type_t< ValueT > V) const
Return 1 if the specified key is in the set, 0 otherwise.
Definition: DenseSet.h:97
PassManagerBuilder.h
llvm::Type::getInt8Ty
static IntegerType * getInt8Ty(LLVMContext &C)
Definition: Type.cpp:237
llvm::Data
@ Data
Definition: SIMachineScheduler.h:55
llvm::timeTraceProfilerFinishThread
void timeTraceProfilerFinishThread()
Finish a time trace profiler running on a worker thread.
Definition: TimeProfiler.cpp:311
llvm::MemoryBufferRef
Definition: MemoryBufferRef.h:22
llvm::EmitImportsFiles
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.
Definition: FunctionImport.cpp:1000
llvm::lto::Config::CombinedIndexHook
CombinedIndexHookFn CombinedIndexHook
Definition: Config.h:254
llvm::lto::setupStatsFile
Expected< std::unique_ptr< ToolOutputFile > > setupStatsFile(StringRef StatsFilename)
Setups the output file for saving statistics.
Definition: LTO.cpp:1635
llvm::lto::getThinLTOOutputFile
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.
Definition: LTO.cpp:1365
F
#define F(x, y, z)
Definition: MD5.cpp:55
llvm::RISCVFenceField::R
@ R
Definition: RISCVBaseInfo.h:265
llvm::timeTraceProfilerInitialize
void timeTraceProfilerInitialize(unsigned TimeTraceGranularity, StringRef ProcName)
Initialize the time trace profiler.
Definition: TimeProfiler.cpp:288
llvm::BitcodeModule::getModuleIdentifier
StringRef getModuleIdentifier() const
Definition: BitcodeReader.h:96
Context
LLVMContext & Context
Definition: NVVMIntrRange.cpp:66
llvm::lto::Config::FromPrevailing
@ FromPrevailing
Definition: Config.h:42
Arg
amdgpu Simplify well known AMD library false FunctionCallee Value * Arg
Definition: AMDGPULibCalls.cpp:187
CommandLine.h
llvm::GlobalValueSummary
Function and variable summary information to aid decisions and implementation of importing.
Definition: ModuleSummaryIndex.h:289
llvm::all_of
bool all_of(R &&range, UnaryPredicate P)
Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly.
Definition: STLExtras.h:1590
llvm::MemoryBuffer::getFile
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,...
Definition: MemoryBuffer.cpp:239
llvm::MapVector::begin
iterator begin()
Definition: MapVector.h:70
llvm::Triple::isOSBinFormatELF
bool isOSBinFormatELF() const
Tests whether the OS uses the ELF binary format.
Definition: Triple.h:663
TargetMachine.h
llvm::GlobalValue::isDeclaration
bool isDeclaration() const
Return true if the primary definition of this global value is outside of the current translation unit...
Definition: Globals.cpp:271
llvm::GlobalValue::VisibilityTypes
VisibilityTypes
An enumeration for the kinds of visibility of global values.
Definition: GlobalValue.h:62
llvm::outs
raw_fd_ostream & outs()
This returns a reference to a raw_fd_ostream for standard output.
Definition: raw_ostream.cpp:883
llvm::GlobalValue::isAppendingLinkage
static bool isAppendingLinkage(LinkageTypes Linkage)
Definition: GlobalValue.h:393
llvm::setupLLVMOptimizationRemarks
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.
Definition: LLVMRemarkStreamer.cpp:94
llvm::lto::Config::SampleProfile
std::string SampleProfile
Sample PGO profile path.
Definition: Config.h:114
llvm::SHA1
A class that wrap the SHA1 algorithm.
Definition: SHA1.h:26
E
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
BitcodeWriter.h
Intrinsics.h
llvm::timeTraceProfilerBegin
void timeTraceProfilerBegin(StringRef Name, StringRef Detail)
Manually begin a time section, with the given Name and Detail.
Definition: TimeProfiler.cpp:344
C
(vector float) vec_cmpeq(*A, *B) C
Definition: README_ALTIVEC.txt:86
llvm::GlobalObject
Definition: GlobalObject.h:27
llvm::errorCodeToError
Error errorCodeToError(std::error_code EC)
Helper for converting an std::error_code to a Error.
Definition: Error.cpp:92
llvm::lto::Config::Options
TargetOptions Options
Definition: Config.h:48
llvm::SHA1::result
std::array< uint8_t, 20 > result()
Return the current raw 160-bits SHA1 for the digested data since the last call to init().
Definition: SHA1.cpp:296
llvm::lto::Config::VisibilityScheme
VisScheme VisibilityScheme
Allows non-imported definitions to get the potentially more constraining visibility from the prevaili...
Definition: Config.h:90
llvm::AMDGPU::PALMD::Key
Key
PAL metadata keys.
Definition: AMDGPUMetadata.h:486
TargetLibraryInfo.h
llvm::lto::Config::ELF
@ ELF
Definition: Config.h:43
false
Definition: StackSlotColoring.cpp:141
SplitModule.h
llvm::dwarf::Index
Index
Definition: Dwarf.h:472
llvm::computeSyntheticCounts
void computeSyntheticCounts(ModuleSummaryIndex &Index)
Compute synthetic function entry counts.
Definition: SummaryBasedOptimizations.cpp:47
llvm::thinLTOInternalizeAndPromoteInIndex
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...
Definition: LTO.cpp:461
llvm::detail::DenseSetImpl::size
size_type size() const
Definition: DenseSet.h:81
llvm::sys::fs::create_directories
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.
Definition: Path.cpp:967
EnableLTOInternalization
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::lto::Config::ResolutionFile
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...
Definition: Config.h:189
llvm::lto::InputFile::symbols
ArrayRef< Symbol > symbols() const
A range over the symbols in this InputFile.
Definition: LTO.h:158
llvm::lto::InputFile::create
static Expected< std::unique_ptr< InputFile > > create(MemoryBufferRef Object)
Create an InputFile.
Definition: LTO.cpp:474
llvm::raw_ostream
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:52
thinLTOResolvePrevailingGUID
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)
Definition: LTO.cpp:324
llvm::Value::setName
void setName(const Twine &Name)
Change the name of the value.
Definition: Value.cpp:375
llvm::raw_ostream::flush
void flush()
Definition: raw_ostream.h:185
llvm::TargetOptions::RelaxELFRelocations
unsigned RelaxELFRelocations
Definition: TargetOptions.h:260
llvm::GlobalValue::InternalLinkage
@ InternalLinkage
Rename collisions when linking (static functions).
Definition: GlobalValue.h:55
llvm::Align
This struct is a compact representation of a valid (non-zero power of two) alignment.
Definition: Alignment.h:39
llvm::ModuleSymbolTable::symbols
ArrayRef< Symbol > symbols() const
Definition: ModuleSymbolTable.h:46
llvm::Comdat
Definition: Comdat.h:33
llvm::Value::use_empty
bool use_empty() const
Definition: Value.h:344
llvm::GlobalValue::getGUID
static GUID getGUID(StringRef GlobalName)
Return a 64-bit global unique ID constructed from global value name (i.e.
Definition: GlobalValue.h:585
llvm::ModuleSymbolTable::addModule
void addModule(Module *M)
Definition: ModuleSymbolTable.cpp:54
llvm::lto::LTO::getMaxTasks
unsigned getMaxTasks() const
Returns an upper bound on the number of tasks that the client may expect.
Definition: LTO.cpp:956
SourceMgr.h
llvm::lto::Config::StatsFile
std::string StatsFile
Statistics output file path.
Definition: Config.h:164
llvm::lto::Config::PostInternalizeModuleHook
ModuleHookFn PostInternalizeModuleHook
This hook is called after internalizing the module.
Definition: Config.h:229
llvm::lto::Config::OverrideTriple
std::string OverrideTriple
Setting this field will replace target triples in input files with this triple.
Definition: Config.h:104
llvm::ThreadPool::getThreadCount
unsigned getThreadCount() const
Definition: ThreadPool.h:110
llvm::StringMap
StringMap - This is an unconventional map that is specialized for handling keys that are "strings",...
Definition: StringMap.h:110
llvm::ValueInfo
Struct that holds a reference to a particular GUID in a global value summary.
Definition: ModuleSummaryIndex.h:167
llvm::SmallString
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
Definition: SmallString.h:26
llvm::RemarksFormat
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"))
Definition: ThinLTOCodeGenerator.cpp:83
LTOBackend.h
llvm::lto::Config::OptLevel
unsigned OptLevel
Definition: Config.h:58
llvm::OutputFileType::Object
@ Object
llvm::updateVCallVisibilityInIndex
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...
Definition: WholeProgramDevirt.cpp:835
llvm::sort
void sort(IteratorTy Start, IteratorTy End)
Definition: STLExtras.h:1538
llvm::function_ref
An efficient, type-erasing, non-owning reference to a callable.
Definition: STLFunctionalExtras.h:36
llvm::StringRef::empty
constexpr bool empty() const
empty - Check if the string is empty.
Definition: StringRef.h:134
G
const DataFlowGraph & G
Definition: RDFGraph.cpp:200
llvm::lto::ThinBackendProc::emitFiles
Error emitFiles(const FunctionImporter::ImportMapTy &ImportList, llvm::StringRef ModulePath, const std::string &NewModulePath)
Definition: LTO.cpp:1190
llvm::DenseSet
Implements a dense probed hash-table based set.
Definition: DenseSet.h:268
ThreadPool.h
llvm::lto::Config::RemarksFilename
std::string RemarksFilename
Optimization remarks file path.
Definition: Config.h:134
llvm::cl::opt< bool >
llvm::GlobalValue::hasAvailableExternallyLinkage
bool hasAvailableExternallyLinkage() const
Definition: GlobalValue.h:505
IRObjectFile.h
llvm::lto::Config::DefaultTriple
std::string DefaultTriple
Setting this field will replace unspecified target triples in input files with this triple.
Definition: Config.h:108
llvm::PrintStatisticsJSON
void PrintStatisticsJSON(raw_ostream &OS)
Print statistics in JSON format.
Definition: Statistic.cpp:203
llvm::IRMover
Definition: IRMover.h:26
llvm::lto::backend
Error backend(const Config &C, AddStreamFn AddStream, unsigned ParallelCodeGenParallelismLevel, Module &M, ModuleSummaryIndex &CombinedIndex)
Runs a regular LTO backend.
Definition: LTOBackend.cpp:493
llvm::DiagnosticInfoOptimizationBase::Argument
Used in the streaming interface as the general argument type.
Definition: DiagnosticInfo.h:427
llvm::GlobalValue
Definition: GlobalValue.h:44
llvm::X86AS::GS
@ GS
Definition: X86.h:199
object
bar al al movzbl eax ret Missed when stored in a memory object
Definition: README.txt:1411
VI
@ VI
Definition: SIInstrInfo.cpp:7894
llvm::object::BasicSymbolRef::SF_FormatSpecific
@ SF_FormatSpecific
Definition: SymbolicFile.h:117
Threading.h
llvm::SmallSet::count
size_type count(const T &V) const
count - Return 1 if the element is in the set, 0 otherwise.
Definition: SmallSet.h:165
uint64_t
llvm::pdb::Unknown
@ Unknown
Definition: PDBTypes.h:396
llvm::computeDeadSymbolsWithConstProp
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.
Definition: FunctionImport.cpp:963
IPO.h
llvm::lto::Config::DwoDir
std::string DwoDir
The directory to store .dwo files.
Definition: Config.h:120
llvm::GlobalValue::WeakAnyLinkage
@ WeakAnyLinkage
Keep one copy of named function when linking (weak)
Definition: GlobalValue.h:52
llvm::PointerUnion::dyn_cast
T dyn_cast() const
Returns the current pointer if it is of the specified pointer type, otherwise returns null.
Definition: PointerUnion.h:162
llvm::symbolize::toHex
static std::string toHex(uint64_t V)
Definition: DIPrinter.cpp:278
move
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
Definition: README.txt:546
llvm::LLVMContext
This is an important class for using LLVM in a threaded context.
Definition: LLVMContext.h:67
llvm::DenseMap
Definition: DenseMap.h:714
llvm::lto::LTOLLVMContext
A derived class of LLVMContext that initializes itself according to a given Config object.
Definition: Config.h:293
I
#define I(x, y, z)
Definition: MD5.cpp:58
llvm::lto::LTO::getRuntimeLibcallSymbols
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...
Definition: LTO.cpp:1158
Analysis.h
StringExtras.h
llvm::cl::init
initializer< Ty > init(const Ty &Val)
Definition: CommandLine.h:440
llvm::joinErrors
Error joinErrors(Error E1, Error E2)
Concatenate errors.
Definition: Error.h:426
llvm::GlobalValue::setLinkage
void setLinkage(LinkageTypes LT)
Definition: GlobalValue.h:530
ToolOutputFile.h
llvm::TypeIdSummary
Definition: ModuleSummaryIndex.h:1033
llvm::EnableStatistics
void EnableStatistics(bool DoPrintOnExit=true)
Enable the collection and printing of statistics.
Definition: Statistic.cpp:134
llvm::DenseMapBase< DenseMap< KeyT, ValueT, DenseMapInfo< KeyT >, llvm::detail::DenseMapPair< KeyT, ValueT > >, KeyT, ValueT, DenseMapInfo< KeyT >, llvm::detail::DenseMapPair< KeyT, ValueT > >::find
iterator find(const_arg_type_t< KeyT > Val)
Definition: DenseMap.h:150
llvm::ModuleSummaryIndex::modulePaths
const StringMap< std::pair< uint64_t, ModuleHash > > & modulePaths() const
Table of modules, containing module hash and id.
Definition: ModuleSummaryIndex.h:1444
llvm::StringMap::begin
iterator begin()
Definition: StringMap.h:203
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
llvm::sys::path::parent_path
StringRef parent_path(StringRef path, Style style=Style::native)
Get parent path.
Definition: Path.cpp:467
thinLTOInternalizeAndPromoteGUID
static void thinLTOInternalizeAndPromoteGUID(ValueInfo VI, function_ref< bool(StringRef, ValueInfo)> isExported, function_ref< bool(GlobalValue::GUID, const GlobalValueSummary *)> isPrevailing)
Definition: LTO.cpp:431
llvm::move
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
Definition: STLExtras.h:1666
llvm::GlobalValue::hasLocalLinkage
bool hasLocalLinkage() const
Definition: GlobalValue.h:521
llvm::updateIndexWPDForExports
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...
Definition: WholeProgramDevirt.cpp:861
llvm::lto::Config::MAttrs
std::vector< std::string > MAttrs
Definition: Config.h:49
llvm::ArrayType::get
static ArrayType * get(Type *ElementType, uint64_t NumElements)
This static method is the primary way to construct an ArrayType.
Definition: Type.cpp:638
llvm::Module
A Module instance is used to store all the information related to an LLVM module.
Definition: Module.h:65
llvm::ModuleSummaryIndex::cfiFunctionDefs
std::set< std::string > & cfiFunctionDefs()
Definition: ModuleSummaryIndex.h:1363
IRMover.h
llvm::StringMapImpl::size
unsigned size() const
Definition: StringMap.h:95
llvm::PrevailingType::Unknown
@ Unknown
llvm::lto::Config::ProfileRemapping
std::string ProfileRemapping
Name remapping file for profile data.
Definition: Config.h:117
llvm::SmallSet::erase
bool erase(const T &V)
Definition: SmallSet.h:206
llvm::GlobalValue::AppendingLinkage
@ AppendingLinkage
Special purpose, only applies to global arrays.
Definition: GlobalValue.h:54
Mangler.h
llvm::size
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.
Definition: STLExtras.h:1571
llvm::SHA1::update
void update(ArrayRef< uint8_t > Data)
Digest more data.
Definition: SHA1.cpp:213
TargetOptions.h
llvm::GlobalValue::getWeakLinkage
static LinkageTypes getWeakLinkage(bool ODR)
Definition: GlobalValue.h:365
llvm::lto::Config::RelocModel
Optional< Reloc::Model > RelocModel
Definition: Config.h:54
llvm::lto::InputFile::getName
StringRef getName() const
Returns the path to the InputFile.
Definition: LTO.cpp:503
llvm::ArrayRef< uint8_t >
llvm::updateVCallVisibilityInModule
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...
Definition: WholeProgramDevirt.cpp:787
llvm::lto::Config::RemarksHotnessThreshold
llvm::Optional< uint64_t > RemarksHotnessThreshold
The minimum hotness value a diagnostic needs in order to be included in optimization diagnostics.
Definition: Config.h:155
llvm::OptimizationRemarkEmitter
The optimization diagnostic interface.
Definition: OptimizationRemarkEmitter.h:33
llvm::lto::Config::HasWholeProgramVisibility
bool HasWholeProgramVisibility
Asserts whether we can assume whole program visibility during the LTO link.
Definition: Config.h:79
llvm::lto::thinBackend
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.
Definition: LTOBackend.cpp:539
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:50
this
Analysis the ScalarEvolution expression for r is this
Definition: README.txt:8
llvm::lto::LTO::~LTO
~LTO()
llvm_unreachable
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Definition: ErrorHandling.h:143
llvm::ThreadPool::async
auto async(Function &&F, Args &&...ArgList)
Asynchronous submission of a task to the pool.
Definition: ThreadPool.h:66
llvm::lto::Config::TimeTraceEnabled
bool TimeTraceEnabled
Time trace enabled.
Definition: Config.h:170
llvm::GlobalValue::WeakODRLinkage
@ WeakODRLinkage
Same, but only replaced by something equivalent.
Definition: GlobalValue.h:53
llvm::Value::replaceAllUsesWith
void replaceAllUsesWith(Value *V)
Change all uses of this to point to a new Value.
Definition: Value.cpp:532
llvm::lto::createWriteIndexesThinBackend
ThinBackend createWriteIndexesThinBackend(std::string OldPrefix, std::string NewPrefix, bool ShouldEmitImportsFiles, raw_fd_ostream *LinkedObjectsFile, IndexWriteCallback OnWrite)
This ThinBackend writes individual module indexes to files, instead of running the individual backend...
Definition: LTO.cpp:1427
uint32_t
llvm::lto::LTO::run
Error run(AddStreamFn AddStream, FileCache Cache=nullptr)
Runs the LTO pipeline.
Definition: LTO.cpp:1002
DL
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
Definition: AArch64SLSHardening.cpp:76
S
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
Definition: README.txt:210
llvm::lto::Config::AlwaysEmitRegularLTOObj
bool AlwaysEmitRegularLTOObj
Always emit a Regular LTO object even when it is empty because no Regular LTO modules were linked.
Definition: Config.h:84
llvm::lto::Config::OptPipeline
std::string OptPipeline
If this field is set, the set of passes run in the middle-end optimizer will be the one specified by ...
Definition: Config.h:95
llvm::ModuleSummaryIndex::cfiFunctionDecls
std::set< std::string > & cfiFunctionDecls()
Definition: ModuleSummaryIndex.h:1366
llvm::GlobalValue::AvailableExternallyLinkage
@ AvailableExternallyLinkage
Available for inspection, not emission.
Definition: GlobalValue.h:49
llvm::GlobalValue::getAliaseeObject
const GlobalObject * getAliaseeObject() const
Definition: Globals.cpp:365
llvm::Module::Error
@ Error
Emits an error if two values disagree, otherwise the resulting value is that of the operands.
Definition: Module.h:118
llvm::Value::getName
StringRef getName() const
Return a constant reference to the value's name.
Definition: Value.cpp:308
llvm::raw_fd_ostream
A raw_ostream that writes to a file descriptor.
Definition: raw_ostream.h:440
llvm::GlobalValue::CommonLinkage
@ CommonLinkage
Tentative definitions.
Definition: GlobalValue.h:58
llvm::PointerUnion
A discriminated union of two or more pointer types, with the discriminator in the low bit of the poin...
Definition: PointerUnion.h:112
llvm::make_scope_exit
detail::scope_exit< std::decay_t< Callable > > make_scope_exit(Callable &&F)
Definition: ScopeExit.h:59
llvm::lto::Config::MllvmArgs
std::vector< std::string > MllvmArgs
Definition: Config.h:50
llvm::ModuleSymbolTable::getSymbolFlags
uint32_t getSymbolFlags(Symbol S) const
Definition: ModuleSymbolTable.cpp:189
llvm::GlobalValue::isLinkOnceLinkage
static bool isLinkOnceLinkage(LinkageTypes Linkage)
Definition: GlobalValue.h:381
llvm::Twine
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:81
llvm::lto::LTO::LTO
LTO(Config Conf, ThinBackend Backend=nullptr, unsigned ParallelCodeGenParallelismLevel=1)
Create an LTO object.
Definition: LTO.cpp:525
llvm::BitcodeModule::getLazyModule
Expected< std::unique_ptr< Module > > getLazyModule(LLVMContext &Context, bool ShouldLazyLoadMetadata, bool IsImporting)
Read the bitcode module and prepare for lazy deserialization of function bodies.
Definition: BitcodeReader.cpp:7746
llvm::TargetOptions::DebuggerTuning
DebuggerKind DebuggerTuning
Which debugger to tune for.
Definition: TargetOptions.h:409
llvm::writeIndexToFile
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 ...
Definition: BitcodeWriter.cpp:4736
llvm::GraphProgram::Name
Name
Definition: GraphWriter.h:50
std
Definition: BitVector.h:851
llvm::inconvertibleErrorCode
std::error_code inconvertibleErrorCode()
The value returned by this function can be returned from convertToErrorCode for Error values where no...
Definition: Error.cpp:79
LLVMRemarkStreamer.h
llvm::GlobalValue::isInterposableLinkage
static bool isInterposableLinkage(LinkageTypes Linkage)
Whether the definition of this global may be replaced by something non-equivalent at link time.
Definition: GlobalValue.h:418
llvm::ModuleSymbolTable::CollectAsmSymvers
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.
Definition: ModuleSymbolTable.cpp:167
llvm::DenseMapBase< DenseMap< KeyT, ValueT, DenseMapInfo< KeyT >, llvm::detail::DenseMapPair< KeyT, ValueT > >, KeyT, ValueT, DenseMapInfo< KeyT >, llvm::detail::DenseMapPair< KeyT, ValueT > >::end
iterator end()
Definition: DenseMap.h:84
llvm::ArrayRef::begin
iterator begin() const
Definition: ArrayRef.h:152
isWeakObjectWithRWAccess
static bool isWeakObjectWithRWAccess(GlobalValueSummary *GVS)
Definition: LTO.cpp:423
llvm::irsymtab::Reader::SymbolRef
Ephemeral symbols produced by Reader::symbols() and Reader::module_symbols().
Definition: IRSymtab.h:313
llvm::Error
Lightweight error class with error context and mandatory checking.
Definition: Error.h:155
llvm::thinLTOPropagateFunctionAttrs
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.
Definition: FunctionAttrs.cpp:427
llvm::timeTraceProfilerEnabled
bool timeTraceProfilerEnabled()
Is the time trace profiler enabled, i.e. initialized?
Definition: TimeProfiler.h:102
llvm::GlobalValue::getComdat
const Comdat * getComdat() const
Definition: Globals.cpp:181
llvm::GlobalValue::getGUID
GUID getGUID() const
Return a 64-bit global unique ID constructed from global value name (i.e.
Definition: GlobalValue.h:589
llvm::lto::SymbolResolution::FinalDefinitionInLinkageUnit
unsigned FinalDefinitionInLinkageUnit
The definition of this symbol is unpreemptable at runtime and is known to be in this linkage unit.
Definition: LTO.h:440
llvm::lto::Config::AAPipeline
std::string AAPipeline
Definition: Config.h:100
llvm::MapVector::size
size_type size() const
Definition: MapVector.h:61
llvm::TargetOptions::DataSections
unsigned DataSections
Emit data into separate sections.
Definition: TargetOptions.h:266
llvm::lto::IndexWriteCallback
std::function< void(const std::string &)> IndexWriteCallback
This ThinBackend runs the individual backend jobs in-process.
Definition: LTO.h:206
llvm::lto::Config::PreOptModuleHook
ModuleHookFn PreOptModuleHook
This module hook is called after linking (regular LTO) or loading (ThinLTO) the module,...
Definition: Config.h:222
llvm::lto::SymbolResolution
The resolution for a symbol.
Definition: LTO.h:430
llvm::lto::ThinBackendProc::ModuleToDefinedGVSummaries
const StringMap< GVSummaryMapTy > & ModuleToDefinedGVSummaries
Definition: LTO.cpp:1167
llvm::PrevailingType::Yes
@ Yes
llvm::StringMap::count
size_type count(StringRef Key) const
count - Return 1 if the element is in the map, 0 otherwise.
Definition: StringMap.h:245
llvm::lto::ThinBackendProc::CombinedIndex
ModuleSummaryIndex & CombinedIndex
Definition: LTO.cpp:1166
llvm::SmallSet::insert
std::pair< const_iterator, bool > insert(const T &V)
insert - Insert an element into the set if it isn't already there.
Definition: SmallSet.h:178
llvm::SmallString::str
StringRef str() const
Explicit conversion to StringRef.
Definition: SmallString.h:260
llvm::PrevailingType::No
@ No
WholeProgramDevirt.h
llvm::FunctionReturnThunksKind::Keep
@ Keep
No function return thunk.
libcallRoutineNames
static const char * libcallRoutineNames[]
Definition: LTO.cpp:1152
llvm::lto::SymbolResolution::VisibleToRegularObj
unsigned VisibleToRegularObj
The definition of this symbol is visible outside of the LTO unit.
Definition: LTO.h:443
SHA1.h
llvm::StringRef::contains
bool contains(StringRef Other) const
Return true if the given string is a substring of *this, and false otherwise.
Definition: StringRef.h:415
llvm::makeArrayRef
ArrayRef< T > makeArrayRef(const T &OneElt)
Construct an ArrayRef from a single element.
Definition: ArrayRef.h:475
llvm::GlobalValue::ExternalLinkage
@ ExternalLinkage
Externally visible function.
Definition: GlobalValue.h:48
llvm::GlobalValue::DLLStorageClassTypes
DLLStorageClassTypes
Storage classes of global values for PE targets.
Definition: GlobalValue.h:69
llvm::Expected::takeError
Error takeError()
Take ownership of the stored error.
Definition: Error.h:597
llvm::ThreadPool::wait
void wait()
Blocking wait for all the threads to complete and the queue to be empty.
Definition: ThreadPool.cpp:143
llvm::OptimizationRemark
Diagnostic information for applied optimization remarks.
Definition: DiagnosticInfo.h:690
llvm::lto::generateModulesOrdering
std::vector< int > generateModulesOrdering(ArrayRef< BitcodeModule * > R)
Produces a container ordering for optimal multi-threaded processing.
Definition: LTO.cpp:1654
llvm::ModuleSymbolTable
Definition: ModuleSymbolTable.h:33
llvm::lto::Config::CGFileType
CodeGenFileType CGFileType
Definition: Config.h:57
llvm::support::endian::write64le
void write64le(void *P, uint64_t V)
Definition: Endian.h:417
llvm::updatePublicTypeTestCalls
void updatePublicTypeTestCalls(Module &M, bool WholeProgramVisibilityEnabledInLTO)
Definition: WholeProgramDevirt.cpp:805
llvm::GlobalValueSummary::getBaseObject
GlobalValueSummary * getBaseObject()
If this is an alias summary, returns the summary of the aliased object (a global variable or function...
Definition: ModuleSummaryIndex.h:498
LTO.h
llvm::ModuleSummaryIndex
Class to hold module path string table and global value map, and encapsulate methods for operating on...
Definition: ModuleSummaryIndex.h:1087
llvm::object::BasicSymbolRef::SF_Global
@ SF_Global
Definition: SymbolicFile.h:111
TargetTransformInfo.h
AutoUpgrade.h
ScopeExit.h
llvm::ComputeCrossModuleImport
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.
Definition: FunctionImport.cpp:653
llvm::GlobalValue::getType
PointerType * getType() const
Global values are always pointers.
Definition: GlobalValue.h:288
llvm::timeTraceProfilerEnd
void timeTraceProfilerEnd()
Manually end the last time section.
Definition: TimeProfiler.cpp:356
llvm::GlobalValue::getValueType
Type * getValueType() const
Definition: GlobalValue.h:290
llvm::StringMap::try_emplace
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.
Definition: StringMap.h:329
llvm::lto::Config::CPU
std::string CPU
Definition: Config.h:47
llvm::lto::ThinBackendProc
This class defines the interface to the ThinLTO backend.
Definition: LTO.cpp:1163
llvm::BitcodeModule
Represents a module in a bitcode file.
Definition: BitcodeReader.h:61
llvm::TargetOptions::FunctionSections
unsigned FunctionSections
Emit functions into separate sections.
Definition: TargetOptions.h:263
llvm::Value::takeName
void takeName(Value *V)
Transfer the name from V to this value.
Definition: Value.cpp:381
llvm::hasWholeProgramVisibility
bool hasWholeProgramVisibility(bool WholeProgramVisibilityEnabledInLTO)
Definition: WholeProgramDevirt.cpp:779
DumpThinCGSCCs
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"))
llvm::cl::desc
Definition: CommandLine.h:413
llvm::lto::LTO::add
Error add(std::unique_ptr< InputFile > Obj, ArrayRef< SymbolResolution > Res)
Add an input file to the LTO link, using the provided symbol resolutions.
Definition: LTO.cpp:615
Mod
Module * Mod
Definition: PassBuilderBindings.cpp:54
BitcodeReader.h
llvm::GlobalObject::setAlignment
void setAlignment(MaybeAlign Align)
Definition: Globals.cpp:126
llvm::lto::SymbolResolution::ExportDynamic
unsigned ExportDynamic
The symbol was exported dynamically, and therefore could be referenced by a shared library not visibl...
Definition: LTO.h:447
llvm::StringMap::const_iterator
StringMapConstIterator< ValueTy > const_iterator
Definition: StringMap.h:200
raw_ostream.h
SummaryBasedOptimizations.h
llvm::lto::createInProcessThinBackend
ThinBackend createInProcessThinBackend(ThreadPoolStrategy Parallelism, IndexWriteCallback OnWrite=nullptr, bool ShouldEmitIndexFiles=false, bool ShouldEmitImportsFiles=false)
Definition: LTO.cpp:1349
llvm::ConstantAggregateZero::get
static ConstantAggregateZero * get(Type *Ty)
Definition: Constants.cpp:1587
DiagnosticPrinter.h
llvm::GlobalValue::LinkOnceODRLinkage
@ LinkOnceODRLinkage
Same, but only replaced by something equivalent.
Definition: GlobalValue.h:51
TargetRegistry.h
llvm::SmallSet::empty
bool empty() const
Definition: SmallSet.h:158
TimeProfiler.h
llvm::lto::SymbolResolution::LinkerRedefined
unsigned LinkerRedefined
Linker redefined version of the symbol which appeared in -wrap or -defsym linker option.
Definition: LTO.h:451
llvm::ArrayRef::end
iterator end() const
Definition: ArrayRef.h:153
llvm::lto::ThinBackendProc::ShouldEmitImportsFiles
bool ShouldEmitImportsFiles
Definition: LTO.cpp:1169
llvm::lto::ThinBackendProc::OnWrite
lto::IndexWriteCallback OnWrite
Definition: LTO.cpp:1168
llvm::lto::Config::RemarksPasses
std::string RemarksPasses
Optimization remarks pass filter.
Definition: Config.h:137
writeToResolutionFile
static void writeToResolutionFile(raw_ostream &OS, InputFile *Input, ArrayRef< SymbolResolution > Res)
Definition: LTO.cpp:591
llvm::lto::InputFile
An input file.
Definition: LTO.h:105
SmallSet.h