LLVM  15.0.0git
LTO.h
Go to the documentation of this file.
1 //===-LTO.h - 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 declares functions and classes used to support LTO. It is intended
10 // to be used both by LTO classes as well as by clients (gold-plugin) that
11 // don't utilize the LTO code generator interfaces.
12 //
13 //===----------------------------------------------------------------------===//
14 
15 #ifndef LLVM_LTO_LTO_H
16 #define LLVM_LTO_LTO_H
17 
18 #include "llvm/ADT/MapVector.h"
19 #include "llvm/ADT/StringMap.h"
22 #include "llvm/LTO/Config.h"
23 #include "llvm/Object/IRSymtab.h"
24 #include "llvm/Support/Caching.h"
25 #include "llvm/Support/Error.h"
26 #include "llvm/Support/thread.h"
29 
30 namespace llvm {
31 
32 class Error;
33 class IRMover;
34 class LLVMContext;
35 class MemoryBufferRef;
36 class Module;
37 class raw_pwrite_stream;
38 class ToolOutputFile;
39 
40 /// Resolve linkage for prevailing symbols in the \p Index. Linkage changes
41 /// recorded in the index and the ThinLTO backends must apply the changes to
42 /// the module via thinLTOFinalizeInModule.
43 ///
44 /// This is done for correctness (if value exported, ensure we always
45 /// emit a copy), and compile-time optimization (allow drop of duplicates).
47  const lto::Config &C, ModuleSummaryIndex &Index,
48  function_ref<bool(GlobalValue::GUID, const GlobalValueSummary *)>
49  isPrevailing,
50  function_ref<void(StringRef, GlobalValue::GUID, GlobalValue::LinkageTypes)>
51  recordNewLinkage,
52  const DenseSet<GlobalValue::GUID> &GUIDPreservedSymbols);
53 
54 /// Update the linkages in the given \p Index to mark exported values
55 /// as external and non-exported values as internal. The ThinLTO backends
56 /// must apply the changes to the Module via thinLTOInternalizeModule.
58  ModuleSummaryIndex &Index,
59  function_ref<bool(StringRef, ValueInfo)> isExported,
60  function_ref<bool(GlobalValue::GUID, const GlobalValueSummary *)>
61  isPrevailing);
62 
63 /// Computes a unique hash for the Module considering the current list of
64 /// export/import and other global analysis results.
65 /// The hash is produced in \p Key.
67  SmallString<40> &Key, const lto::Config &Conf,
68  const ModuleSummaryIndex &Index, StringRef ModuleID,
69  const FunctionImporter::ImportMapTy &ImportList,
70  const FunctionImporter::ExportSetTy &ExportList,
71  const std::map<GlobalValue::GUID, GlobalValue::LinkageTypes> &ResolvedODR,
72  const GVSummaryMapTy &DefinedGlobals,
73  const std::set<GlobalValue::GUID> &CfiFunctionDefs = {},
74  const std::set<GlobalValue::GUID> &CfiFunctionDecls = {});
75 
76 namespace lto {
77 
78 /// Given the original \p Path to an output file, replace any path
79 /// prefix matching \p OldPrefix with \p NewPrefix. Also, create the
80 /// resulting directory if it does not yet exist.
81 std::string getThinLTOOutputFile(const std::string &Path,
82  const std::string &OldPrefix,
83  const std::string &NewPrefix);
84 
85 /// Setup optimization remarks.
86 Expected<std::unique_ptr<ToolOutputFile>> setupLLVMOptimizationRemarks(
87  LLVMContext &Context, StringRef RemarksFilename, StringRef RemarksPasses,
88  StringRef RemarksFormat, bool RemarksWithHotness,
89  Optional<uint64_t> RemarksHotnessThreshold = 0, int Count = -1);
90 
91 /// Setups the output file for saving statistics.
92 Expected<std::unique_ptr<ToolOutputFile>>
93 setupStatsFile(StringRef StatsFilename);
94 
95 /// Produces a container ordering for optimal multi-threaded processing. Returns
96 /// ordered indices to elements in the input array.
97 std::vector<int> generateModulesOrdering(ArrayRef<BitcodeModule *> R);
98 
99 class LTO;
100 struct SymbolResolution;
101 class ThinBackendProc;
102 
103 /// An input file. This is a symbol table wrapper that only exposes the
104 /// information that an LTO client should need in order to do symbol resolution.
105 class InputFile {
106 public:
107  class Symbol;
108 
109 private:
110  // FIXME: Remove LTO class friendship once we have bitcode symbol tables.
111  friend LTO;
112  InputFile() = default;
113 
114  std::vector<BitcodeModule> Mods;
115  SmallVector<char, 0> Strtab;
116  std::vector<Symbol> Symbols;
117 
118  // [begin, end) for each module
119  std::vector<std::pair<size_t, size_t>> ModuleSymIndices;
120 
121  StringRef TargetTriple, SourceFileName, COFFLinkerOpts;
122  std::vector<StringRef> DependentLibraries;
123  std::vector<std::pair<StringRef, Comdat::SelectionKind>> ComdatTable;
124 
125 public:
126  ~InputFile();
127 
128  /// Create an InputFile.
130 
131  /// The purpose of this class is to only expose the symbol information that an
132  /// LTO client should need in order to do symbol resolution.
134  friend LTO;
135 
136  public:
137  Symbol(const irsymtab::Symbol &S) : irsymtab::Symbol(S) {}
138 
155  };
156 
157  /// A range over the symbols in this InputFile.
158  ArrayRef<Symbol> symbols() const { return Symbols; }
159 
160  /// Returns linker options specified in the input file.
161  StringRef getCOFFLinkerOpts() const { return COFFLinkerOpts; }
162 
163  /// Returns dependent library specifiers from the input file.
164  ArrayRef<StringRef> getDependentLibraries() const { return DependentLibraries; }
165 
166  /// Returns the path to the InputFile.
167  StringRef getName() const;
168 
169  /// Returns the input file's target triple.
170  StringRef getTargetTriple() const { return TargetTriple; }
171 
172  /// Returns the source file path specified at compile time.
173  StringRef getSourceFileName() const { return SourceFileName; }
174 
175  // Returns a table with all the comdats used by this file.
177  return ComdatTable;
178  }
179 
180  // Returns the only BitcodeModule from InputFile.
182 
183 private:
184  ArrayRef<Symbol> module_symbols(unsigned I) const {
185  const auto &Indices = ModuleSymIndices[I];
186  return {Symbols.data() + Indices.first, Symbols.data() + Indices.second};
187  }
188 };
189 
190 /// A ThinBackend defines what happens after the thin-link phase during ThinLTO.
191 /// The details of this type definition aren't important; clients can only
192 /// create a ThinBackend using one of the create*ThinBackend() functions below.
193 using ThinBackend = std::function<std::unique_ptr<ThinBackendProc>(
194  const Config &C, ModuleSummaryIndex &CombinedIndex,
195  StringMap<GVSummaryMapTy> &ModuleToDefinedGVSummaries,
196  AddStreamFn AddStream, FileCache Cache)>;
197 
198 /// This ThinBackend runs the individual backend jobs in-process.
199 /// The default value means to use one job per hardware core (not hyper-thread).
201 
202 /// This ThinBackend writes individual module indexes to files, instead of
203 /// running the individual backend jobs. This backend is for distributed builds
204 /// where separate processes will invoke the real backends.
205 ///
206 /// To find the path to write the index to, the backend checks if the path has a
207 /// prefix of OldPrefix; if so, it replaces that prefix with NewPrefix. It then
208 /// appends ".thinlto.bc" and writes the index to that path. If
209 /// ShouldEmitImportsFiles is true it also writes a list of imported files to a
210 /// similar path with ".imports" appended instead.
211 /// LinkedObjectsFile is an output stream to write the list of object files for
212 /// the final ThinLTO linking. Can be nullptr.
213 /// OnWrite is callback which receives module identifier and notifies LTO user
214 /// that index file for the module (and optionally imports file) was created.
215 using IndexWriteCallback = std::function<void(const std::string &)>;
216 ThinBackend createWriteIndexesThinBackend(std::string OldPrefix,
217  std::string NewPrefix,
218  bool ShouldEmitImportsFiles,
219  raw_fd_ostream *LinkedObjectsFile,
220  IndexWriteCallback OnWrite);
221 
222 /// This class implements a resolution-based interface to LLVM's LTO
223 /// functionality. It supports regular LTO, parallel LTO code generation and
224 /// ThinLTO. You can use it from a linker in the following way:
225 /// - Set hooks and code generation options (see lto::Config struct defined in
226 /// Config.h), and use the lto::Config object to create an lto::LTO object.
227 /// - Create lto::InputFile objects using lto::InputFile::create(), then use
228 /// the symbols() function to enumerate its symbols and compute a resolution
229 /// for each symbol (see SymbolResolution below).
230 /// - After the linker has visited each input file (and each regular object
231 /// file) and computed a resolution for each symbol, take each lto::InputFile
232 /// and pass it and an array of symbol resolutions to the add() function.
233 /// - Call the getMaxTasks() function to get an upper bound on the number of
234 /// native object files that LTO may add to the link.
235 /// - Call the run() function. This function will use the supplied AddStream
236 /// and Cache functions to add up to getMaxTasks() native object files to
237 /// the link.
238 class LTO {
239  friend InputFile;
240 
241 public:
242  /// Create an LTO object. A default constructed LTO object has a reasonable
243  /// production configuration, but you can customize it by passing arguments to
244  /// this constructor.
245  /// FIXME: We do currently require the DiagHandler field to be set in Conf.
246  /// Until that is fixed, a Config argument is required.
247  LTO(Config Conf, ThinBackend Backend = nullptr,
248  unsigned ParallelCodeGenParallelismLevel = 1);
249  ~LTO();
250 
251  /// Add an input file to the LTO link, using the provided symbol resolutions.
252  /// The symbol resolutions must appear in the enumeration order given by
253  /// InputFile::symbols().
254  Error add(std::unique_ptr<InputFile> Obj, ArrayRef<SymbolResolution> Res);
255 
256  /// Returns an upper bound on the number of tasks that the client may expect.
257  /// This may only be called after all IR object files have been added. For a
258  /// full description of tasks see LTOBackend.h.
259  unsigned getMaxTasks() const;
260 
261  /// Runs the LTO pipeline. This function calls the supplied AddStream
262  /// function to add native object files to the link.
263  ///
264  /// The Cache parameter is optional. If supplied, it will be used to cache
265  /// native object files and add them to the link.
266  ///
267  /// The client will receive at most one callback (via either AddStream or
268  /// Cache) for each task identifier.
269  Error run(AddStreamFn AddStream, FileCache Cache = nullptr);
270 
271  /// Static method that returns a list of libcall symbols that can be generated
272  /// by LTO but might not be visible from bitcode symbol table.
274 
275 private:
276  Config Conf;
277 
278  struct RegularLTOState {
279  RegularLTOState(unsigned ParallelCodeGenParallelismLevel,
280  const Config &Conf);
284  /// Record if at least one instance of the common was marked as prevailing
285  bool Prevailing = false;
286  };
287  std::map<std::string, CommonResolution> Commons;
288 
289  unsigned ParallelCodeGenParallelismLevel;
290  LTOLLVMContext Ctx;
291  std::unique_ptr<Module> CombinedModule;
292  std::unique_ptr<IRMover> Mover;
293 
294  // This stores the information about a regular LTO module that we have added
295  // to the link. It will either be linked immediately (for modules without
296  // summaries) or after summary-based dead stripping (for modules with
297  // summaries).
298  struct AddedModule {
299  std::unique_ptr<Module> M;
300  std::vector<GlobalValue *> Keep;
301  };
302  std::vector<AddedModule> ModsWithSummaries;
303  bool EmptyCombinedModule = true;
304  } RegularLTO;
305 
307 
308  struct ThinLTOState {
309  ThinLTOState(ThinBackend Backend);
310 
311  ThinBackend Backend;
312  ModuleSummaryIndex CombinedIndex;
313  // The full set of bitcode modules in input order.
314  ModuleMapType ModuleMap;
315  // The bitcode modules to compile, if specified by the LTO Config.
316  Optional<ModuleMapType> ModulesToCompile;
317  DenseMap<GlobalValue::GUID, StringRef> PrevailingModuleForGUID;
318  } ThinLTO;
319 
320  // The global resolution for a particular (mangled) symbol name. This is in
321  // particular necessary to track whether each symbol can be internalized.
322  // Because any input file may introduce a new cross-partition reference, we
323  // cannot make any final internalization decisions until all input files have
324  // been added and the client has called run(). During run() we apply
325  // internalization decisions either directly to the module (for regular LTO)
326  // or to the combined index (for ThinLTO).
327  struct GlobalResolution {
328  /// The unmangled name of the global.
329  std::string IRName;
330 
331  /// Keep track if the symbol is visible outside of a module with a summary
332  /// (i.e. in either a regular object or a regular LTO module without a
333  /// summary).
334  bool VisibleOutsideSummary = false;
335 
336  /// The symbol was exported dynamically, and therefore could be referenced
337  /// by a shared library not visible to the linker.
338  bool ExportDynamic = false;
339 
340  bool UnnamedAddr = true;
341 
342  /// True if module contains the prevailing definition.
343  bool Prevailing = false;
344 
345  /// Returns true if module contains the prevailing definition and symbol is
346  /// an IR symbol. For example when module-level inline asm block is used,
347  /// symbol can be prevailing in module but have no IR name.
348  bool isPrevailingIRSymbol() const { return Prevailing && !IRName.empty(); }
349 
350  /// This field keeps track of the partition number of this global. The
351  /// regular LTO object is partition 0, while each ThinLTO object has its own
352  /// partition number from 1 onwards.
353  ///
354  /// Any global that is defined or used by more than one partition, or that
355  /// is referenced externally, may not be internalized.
356  ///
357  /// Partitions generally have a one-to-one correspondence with tasks, except
358  /// that we use partition 0 for all parallel LTO code generation partitions.
359  /// Any partitioning of the combined LTO object is done internally by the
360  /// LTO backend.
361  unsigned Partition = Unknown;
362 
363  /// Special partition numbers.
364  enum : unsigned {
365  /// A partition number has not yet been assigned to this global.
366  Unknown = -1u,
367 
368  /// This global is either used by more than one partition or has an
369  /// external reference, and therefore cannot be internalized.
370  External = -2u,
371 
372  /// The RegularLTO partition
373  RegularLTO = 0,
374  };
375  };
376 
377  // Global mapping from mangled symbol names to resolutions.
378  StringMap<GlobalResolution> GlobalResolutions;
379 
380  void addModuleToGlobalRes(ArrayRef<InputFile::Symbol> Syms,
381  ArrayRef<SymbolResolution> Res, unsigned Partition,
382  bool InSummary);
383 
384  // These functions take a range of symbol resolutions [ResI, ResE) and consume
385  // the resolutions used by a single input module by incrementing ResI. After
386  // these functions return, [ResI, ResE) will refer to the resolution range for
387  // the remaining modules in the InputFile.
388  Error addModule(InputFile &Input, unsigned ModI,
389  const SymbolResolution *&ResI, const SymbolResolution *ResE);
390 
391  Expected<RegularLTOState::AddedModule>
392  addRegularLTO(BitcodeModule BM, ArrayRef<InputFile::Symbol> Syms,
393  const SymbolResolution *&ResI, const SymbolResolution *ResE);
394  Error linkRegularLTO(RegularLTOState::AddedModule Mod,
395  bool LivenessFromIndex);
396 
397  Error addThinLTO(BitcodeModule BM, ArrayRef<InputFile::Symbol> Syms,
398  const SymbolResolution *&ResI, const SymbolResolution *ResE);
399 
400  Error runRegularLTO(AddStreamFn AddStream);
401  Error runThinLTO(AddStreamFn AddStream, FileCache Cache,
402  const DenseSet<GlobalValue::GUID> &GUIDPreservedSymbols);
403 
404  Error checkPartiallySplit();
405 
406  mutable bool CalledGetMaxTasks = false;
407 
408  // Use Optional to distinguish false from not yet initialized.
409  Optional<bool> EnableSplitLTOUnit;
410 
411  // Identify symbols exported dynamically, and that therefore could be
412  // referenced by a shared library not visible to the linker.
413  DenseSet<GlobalValue::GUID> DynamicExportSymbols;
414 
415  // Diagnostic optimization remarks file
416  std::unique_ptr<ToolOutputFile> DiagnosticOutputFile;
417 };
418 
419 /// The resolution for a symbol. The linker must provide a SymbolResolution for
420 /// each global symbol based on its internal resolution of that symbol.
425 
426  /// The linker has chosen this definition of the symbol.
427  unsigned Prevailing : 1;
428 
429  /// The definition of this symbol is unpreemptable at runtime and is known to
430  /// be in this linkage unit.
432 
433  /// The definition of this symbol is visible outside of the LTO unit.
434  unsigned VisibleToRegularObj : 1;
435 
436  /// The symbol was exported dynamically, and therefore could be referenced
437  /// by a shared library not visible to the linker.
438  unsigned ExportDynamic : 1;
439 
440  /// Linker redefined version of the symbol which appeared in -wrap or -defsym
441  /// linker option.
442  unsigned LinkerRedefined : 1;
443 };
444 
445 } // namespace lto
446 } // namespace llvm
447 
448 #endif
llvm::GlobalValue::GUID
uint64_t GUID
Declare a type to represent a global unique identifier for a global value.
Definition: GlobalValue.h:508
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
llvm::lto::LTO::RegularLTOState::CommonResolution::Size
uint64_t Size
Definition: LTO.h:282
llvm::irsymtab::Symbol::getIRName
StringRef getIRName() const
Returns the unmangled symbol name, or the empty string if this is not an IR symbol.
Definition: IRSymtab.h:186
llvm::FileCache
std::function< Expected< AddStreamFn >(unsigned Task, StringRef Key)> FileCache
This is the type of a file cache.
Definition: Caching.h:56
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:17
llvm::lltok::Error
@ Error
Definition: LLToken.h:21
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::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::InputFile::getTargetTriple
StringRef getTargetTriple() const
Returns the input file's target triple.
Definition: LTO.h:170
llvm::irsymtab::Symbol::getCOFFWeakExternalFallback
StringRef getCOFFWeakExternalFallback() const
COFF-specific: for weak externals, returns the name of the symbol that is used as a fallback if the w...
Definition: IRSymtab.h:226
llvm::SmallVector< char, 0 >
FunctionImport.h
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::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
llvm::lto::InputFile::getSingleBitcodeModule
BitcodeModule & getSingleBitcodeModule()
Definition: LTO.cpp:505
MapVector.h
llvm::irsymtab::Symbol::canBeOmittedFromSymbolTable
bool canBeOmittedFromSymbolTable() const
Definition: IRSymtab.h:205
Error.h
llvm::lto::InputFile::~InputFile
~InputFile()
llvm::irsymtab::Symbol::isExecutable
bool isExecutable() const
Definition: IRSymtab.h:212
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:427
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::irsymtab::Symbol::getSectionName
StringRef getSectionName() const
Definition: IRSymtab.h:231
llvm::lto::Config
LTO configuration.
Definition: Config.h:40
llvm::Optional
Definition: APInt.h:33
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::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:1577
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:399
llvm::GlobalValue::LinkageTypes
LinkageTypes
An enumeration for the kinds of linkage for global values.
Definition: GlobalValue.h:47
llvm::MemoryBufferRef
Definition: MemoryBufferRef.h:22
llvm::lto::setupStatsFile
Expected< std::unique_ptr< ToolOutputFile > > setupStatsFile(StringRef StatsFilename)
Setups the output file for saving statistics.
Definition: LTO.cpp:1602
ModuleSummaryIndex.h
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:1317
Context
LLVMContext & Context
Definition: NVVMIntrRange.cpp:66
Caching.h
llvm::irsymtab::Symbol::getName
StringRef getName() const
Returns the mangled symbol name.
Definition: IRSymtab.h:182
C
(vector float) vec_cmpeq(*A, *B) C
Definition: README_ALTIVEC.txt:86
llvm::irsymtab::Symbol::getVisibility
GlobalValue::VisibilityTypes getVisibility() const
Definition: IRSymtab.h:194
llvm::AMDGPU::PALMD::Key
Key
PAL metadata keys.
Definition: AMDGPUMetadata.h:486
llvm::MaybeAlign
This struct is a compact representation of a valid (power of two) or undefined (0) alignment.
Definition: Alignment.h:109
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:459
llvm::lto::SymbolResolution::SymbolResolution
SymbolResolution()
Definition: LTO.h:422
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:472
llvm::irsymtab::Symbol::getComdatIndex
int getComdatIndex() const
Returns the index into the comdat table (see Reader::getComdatTable()), or -1 if not a comdat member.
Definition: IRSymtab.h:190
StringMap.h
llvm::lto::InputFile::Symbol::Symbol
Symbol(const irsymtab::Symbol &S)
Definition: LTO.h:137
llvm::irsymtab::Symbol::isUsed
bool isUsed() const
Definition: IRSymtab.h:202
llvm::lto::LTO::getMaxTasks
unsigned getMaxTasks() const
Returns an upper bound on the number of tasks that the client may expect.
Definition: LTO.cpp:953
llvm::lto::LTO::RegularLTOState::AddedModule::M
std::unique_ptr< Module > M
Definition: LTO.h:299
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
llvm::OutputFileType::Object
@ Object
llvm::irsymtab::Symbol::isUndefined
bool isUndefined() const
Definition: IRSymtab.h:198
IRSymtab.h
Index
uint32_t Index
Definition: ELFObjHandler.cpp:82
uint64_t
llvm::irsymtab::Symbol::getCommonSize
uint64_t getCommonSize() const
Definition: IRSymtab.h:214
llvm::lto::LTO
This class implements a resolution-based interface to LLVM's LTO functionality.
Definition: LTO.h:238
llvm::DenseMap
Definition: DenseMap.h:716
llvm::lto::LTOLLVMContext
A derived class of LLVMContext that initializes itself according to a given Config object.
Definition: Config.h:284
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:1153
llvm::irsymtab::Symbol::isIndirect
bool isIndirect() const
Definition: IRSymtab.h:201
llvm::irsymtab::Symbol::isWeak
bool isWeak() const
Definition: IRSymtab.h:199
llvm::lto::LTO::RegularLTOState::CommonResolution
Definition: LTO.h:281
function
print Print MemDeps of function
Definition: MemDepPrinter.cpp:82
llvm::lto::InputFile::getSourceFileName
StringRef getSourceFileName() const
Returns the source file path specified at compile time.
Definition: LTO.h:173
llvm::lto::InputFile::getName
StringRef getName() const
Returns the path to the InputFile.
Definition: LTO.cpp:501
llvm::ArrayRef
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: APInt.h:32
llvm::irsymtab::Symbol::getCommonAlignment
uint32_t getCommonAlignment() const
Definition: IRSymtab.h:219
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:58
llvm::lto::LTO::~LTO
~LTO()
Config.h
llvm::FunctionImporter::ExportSetTy
DenseSet< ValueInfo > ExportSetTy
The set contains an entry for every global value the module exports.
Definition: FunctionImport.h:101
llvm::lto::createWriteIndexesThinBackend
ThinBackend createWriteIndexesThinBackend(std::string OldPrefix, std::string NewPrefix, bool ShouldEmitImportsFiles, raw_fd_ostream *LinkedObjectsFile, IndexWriteCallback OnWrite)
Definition: LTO.cpp:1396
llvm::GVSummaryMapTy
DenseMap< GlobalValue::GUID, GlobalValueSummary * > GVSummaryMapTy
Map of global value GUID to its summary, used to identify values defined in a particular module,...
Definition: ModuleSummaryIndex.h:1055
llvm::lto::LTO::run
Error run(AddStreamFn AddStream, FileCache Cache=nullptr)
Runs the LTO pipeline.
Definition: LTO.cpp:999
llvm::FunctionImporter::ImportMapTy
StringMap< FunctionsToImportTy > ImportMapTy
The map contains an entry for every module to import from, the key being the module identifier to pas...
Definition: FunctionImport.h:98
llvm::lto::LTO::RegularLTOState::CommonResolution::Align
MaybeAlign Align
Definition: LTO.h:283
Module
Machine Check Debug Module
Definition: MachineCheckDebugify.cpp:122
llvm::raw_fd_ostream
A raw_ostream that writes to a file descriptor.
Definition: raw_ostream.h:444
llvm::irsymtab::Symbol
This represents a symbol that has been read from a storage::Symbol and possibly a storage::Uncommon.
Definition: IRSymtab.h:170
llvm::DenseMapBase::empty
LLVM_NODISCARD bool empty() const
Definition: DenseMap.h:98
llvm::lto::LTO::RegularLTOState::AddedModule
Definition: LTO.h:298
llvm::lto::LTO::RegularLTOState::AddedModule::Keep
std::vector< GlobalValue * > Keep
Definition: LTO.h:300
llvm::lto::LTO::LTO
LTO(Config Conf, ThinBackend Backend=nullptr, unsigned ParallelCodeGenParallelismLevel=1)
Create an LTO object.
Definition: LTO.cpp:523
llvm::lto::InputFile::getDependentLibraries
ArrayRef< StringRef > getDependentLibraries() const
Returns dependent library specifiers from the input file.
Definition: LTO.h:164
llvm::Error
Lightweight error class with error context and mandatory checking.
Definition: Error.h:155
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:431
llvm::lto::IndexWriteCallback
std::function< void(const std::string &)> IndexWriteCallback
This ThinBackend writes individual module indexes to files, instead of running the individual backend...
Definition: LTO.h:215
llvm::lto::InputFile::getCOFFLinkerOpts
StringRef getCOFFLinkerOpts() const
Returns linker options specified in the input file.
Definition: LTO.h:161
llvm::lto::SymbolResolution
The resolution for a symbol.
Definition: LTO.h:421
llvm::lto::SymbolResolution::VisibleToRegularObj
unsigned VisibleToRegularObj
The definition of this symbol is visible outside of the LTO unit.
Definition: LTO.h:434
llvm::lto::generateModulesOrdering
std::vector< int > generateModulesOrdering(ArrayRef< BitcodeModule * > R)
Produces a container ordering for optimal multi-threaded processing.
Definition: LTO.cpp:1621
llvm::ModuleSummaryIndex
Class to hold module path string table and global value map, and encapsulate methods for operating on...
Definition: ModuleSummaryIndex.h:1087
llvm::irsymtab::Symbol::isTLS
bool isTLS() const
Definition: IRSymtab.h:203
llvm::lto::createInProcessThinBackend
ThinBackend createInProcessThinBackend(ThreadPoolStrategy Parallelism)
This ThinBackend runs the individual backend jobs in-process.
Definition: LTO.cpp:1304
llvm::lto::LTO::RegularLTOState::CommonResolution::Prevailing
bool Prevailing
Record if at least one instance of the common was marked as prevailing.
Definition: LTO.h:285
thread.h
llvm::BitcodeModule
Represents a module in a bitcode file.
Definition: BitcodeReader.h:61
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:613
BitcodeReader.h
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:438
llvm::irsymtab::storage::Symbol
Contains the information needed by linkers for symbol resolution, as well as by the LTO implementatio...
Definition: IRSymtab.h:91
FunctionAttrs.h
llvm::lto::SymbolResolution::LinkerRedefined
unsigned LinkerRedefined
Linker redefined version of the symbol which appeared in -wrap or -defsym linker option.
Definition: LTO.h:442
llvm::irsymtab::Symbol::isCommon
bool isCommon() const
Definition: IRSymtab.h:200
llvm::lto::InputFile
An input file.
Definition: LTO.h:105
llvm::lto::InputFile::getComdatTable
ArrayRef< std::pair< StringRef, Comdat::SelectionKind > > getComdatTable() const
Definition: LTO.h:176