LLVM  9.0.0svn
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"
20 #include "llvm/ADT/StringSet.h"
21 #include "llvm/IR/DiagnosticInfo.h"
23 #include "llvm/LTO/Config.h"
24 #include "llvm/Linker/IRMover.h"
25 #include "llvm/Object/IRSymtab.h"
26 #include "llvm/Support/Error.h"
28 #include "llvm/Support/thread.h"
31 
32 namespace llvm {
33 
34 class BitcodeModule;
35 class Error;
36 class LLVMContext;
37 class MemoryBufferRef;
38 class Module;
39 class Target;
40 class raw_pwrite_stream;
41 
42 /// Resolve linkage for prevailing symbols in the \p Index. Linkage changes
43 /// recorded in the index and the ThinLTO backends must apply the changes to
44 /// the module via thinLTOResolvePrevailingInModule.
45 ///
46 /// This is done for correctness (if value exported, ensure we always
47 /// emit a copy), and compile-time optimization (allow drop of duplicates).
49  ModuleSummaryIndex &Index,
50  function_ref<bool(GlobalValue::GUID, const GlobalValueSummary *)>
51  isPrevailing,
52  function_ref<void(StringRef, GlobalValue::GUID, GlobalValue::LinkageTypes)>
53  recordNewLinkage,
54  const DenseSet<GlobalValue::GUID> &GUIDPreservedSymbols);
55 
56 /// Update the linkages in the given \p Index to mark exported values
57 /// as external and non-exported values as internal. The ThinLTO backends
58 /// must apply the changes to the Module via thinLTOInternalizeModule.
60  ModuleSummaryIndex &Index,
61  function_ref<bool(StringRef, GlobalValue::GUID)> isExported);
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>>
87 setupOptimizationRemarks(LLVMContext &Context, StringRef RemarksFilename,
88  StringRef RemarksPasses, bool RemarksWithHotness,
89  int Count = -1);
90 
91 /// Setups the output file for saving statistics.
92 Expected<std::unique_ptr<ToolOutputFile>>
93 setupStatsFile(StringRef StatsFilename);
94 
95 class LTO;
96 struct SymbolResolution;
97 class ThinBackendProc;
98 
99 /// An input file. This is a symbol table wrapper that only exposes the
100 /// information that an LTO client should need in order to do symbol resolution.
101 class InputFile {
102 public:
103  class Symbol;
104 
105 private:
106  // FIXME: Remove LTO class friendship once we have bitcode symbol tables.
107  friend LTO;
108  InputFile() = default;
109 
110  std::vector<BitcodeModule> Mods;
111  SmallVector<char, 0> Strtab;
112  std::vector<Symbol> Symbols;
113 
114  // [begin, end) for each module
115  std::vector<std::pair<size_t, size_t>> ModuleSymIndices;
116 
117  StringRef TargetTriple, SourceFileName, COFFLinkerOpts;
118  std::vector<StringRef> DependentLibraries;
119  std::vector<StringRef> ComdatTable;
120 
121 public:
122  ~InputFile();
123 
124  /// Create an InputFile.
126 
127  /// The purpose of this class is to only expose the symbol information that an
128  /// LTO client should need in order to do symbol resolution.
130  friend LTO;
131 
132  public:
133  Symbol(const irsymtab::Symbol &S) : irsymtab::Symbol(S) {}
134 
151  };
152 
153  /// A range over the symbols in this InputFile.
154  ArrayRef<Symbol> symbols() const { return Symbols; }
155 
156  /// Returns linker options specified in the input file.
157  StringRef getCOFFLinkerOpts() const { return COFFLinkerOpts; }
158 
159  /// Returns dependent library specifiers from the input file.
160  ArrayRef<StringRef> getDependentLibraries() const { return DependentLibraries; }
161 
162  /// Returns the path to the InputFile.
163  StringRef getName() const;
164 
165  /// Returns the input file's target triple.
166  StringRef getTargetTriple() const { return TargetTriple; }
167 
168  /// Returns the source file path specified at compile time.
169  StringRef getSourceFileName() const { return SourceFileName; }
170 
171  // Returns a table with all the comdats used by this file.
172  ArrayRef<StringRef> getComdatTable() const { return ComdatTable; }
173 
174  // Returns the only BitcodeModule from InputFile.
176 
177 private:
178  ArrayRef<Symbol> module_symbols(unsigned I) const {
179  const auto &Indices = ModuleSymIndices[I];
180  return {Symbols.data() + Indices.first, Symbols.data() + Indices.second};
181  }
182 };
183 
184 /// This class wraps an output stream for a native object. Most clients should
185 /// just be able to return an instance of this base class from the stream
186 /// callback, but if a client needs to perform some action after the stream is
187 /// written to, that can be done by deriving from this class and overriding the
188 /// destructor.
190 public:
191  NativeObjectStream(std::unique_ptr<raw_pwrite_stream> OS) : OS(std::move(OS)) {}
192  std::unique_ptr<raw_pwrite_stream> OS;
193  virtual ~NativeObjectStream() = default;
194 };
195 
196 /// This type defines the callback to add a native object that is generated on
197 /// the fly.
198 ///
199 /// Stream callbacks must be thread safe.
200 using AddStreamFn =
201  std::function<std::unique_ptr<NativeObjectStream>(unsigned Task)>;
202 
203 /// This is the type of a native object cache. To request an item from the
204 /// cache, pass a unique string as the Key. For hits, the cached file will be
205 /// added to the link and this function will return AddStreamFn(). For misses,
206 /// the cache will return a stream callback which must be called at most once to
207 /// produce content for the stream. The native object stream produced by the
208 /// stream callback will add the file to the link after the stream is written
209 /// to.
210 ///
211 /// Clients generally look like this:
212 ///
213 /// if (AddStreamFn AddStream = Cache(Task, Key))
214 /// ProduceContent(AddStream);
215 using NativeObjectCache =
216  std::function<AddStreamFn(unsigned Task, StringRef Key)>;
217 
218 /// A ThinBackend defines what happens after the thin-link phase during ThinLTO.
219 /// The details of this type definition aren't important; clients can only
220 /// create a ThinBackend using one of the create*ThinBackend() functions below.
221 using ThinBackend = std::function<std::unique_ptr<ThinBackendProc>(
222  Config &C, ModuleSummaryIndex &CombinedIndex,
223  StringMap<GVSummaryMapTy> &ModuleToDefinedGVSummaries,
224  AddStreamFn AddStream, NativeObjectCache Cache)>;
225 
226 /// This ThinBackend runs the individual backend jobs in-process.
227 ThinBackend createInProcessThinBackend(unsigned ParallelismLevel);
228 
229 /// This ThinBackend writes individual module indexes to files, instead of
230 /// running the individual backend jobs. This backend is for distributed builds
231 /// where separate processes will invoke the real backends.
232 ///
233 /// To find the path to write the index to, the backend checks if the path has a
234 /// prefix of OldPrefix; if so, it replaces that prefix with NewPrefix. It then
235 /// appends ".thinlto.bc" and writes the index to that path. If
236 /// ShouldEmitImportsFiles is true it also writes a list of imported files to a
237 /// similar path with ".imports" appended instead.
238 /// LinkedObjectsFile is an output stream to write the list of object files for
239 /// the final ThinLTO linking. Can be nullptr.
240 /// OnWrite is callback which receives module identifier and notifies LTO user
241 /// that index file for the module (and optionally imports file) was created.
242 using IndexWriteCallback = std::function<void(const std::string &)>;
243 ThinBackend createWriteIndexesThinBackend(std::string OldPrefix,
244  std::string NewPrefix,
245  bool ShouldEmitImportsFiles,
246  raw_fd_ostream *LinkedObjectsFile,
247  IndexWriteCallback OnWrite);
248 
249 /// This class implements a resolution-based interface to LLVM's LTO
250 /// functionality. It supports regular LTO, parallel LTO code generation and
251 /// ThinLTO. You can use it from a linker in the following way:
252 /// - Set hooks and code generation options (see lto::Config struct defined in
253 /// Config.h), and use the lto::Config object to create an lto::LTO object.
254 /// - Create lto::InputFile objects using lto::InputFile::create(), then use
255 /// the symbols() function to enumerate its symbols and compute a resolution
256 /// for each symbol (see SymbolResolution below).
257 /// - After the linker has visited each input file (and each regular object
258 /// file) and computed a resolution for each symbol, take each lto::InputFile
259 /// and pass it and an array of symbol resolutions to the add() function.
260 /// - Call the getMaxTasks() function to get an upper bound on the number of
261 /// native object files that LTO may add to the link.
262 /// - Call the run() function. This function will use the supplied AddStream
263 /// and Cache functions to add up to getMaxTasks() native object files to
264 /// the link.
265 class LTO {
266  friend InputFile;
267 
268 public:
269  /// Create an LTO object. A default constructed LTO object has a reasonable
270  /// production configuration, but you can customize it by passing arguments to
271  /// this constructor.
272  /// FIXME: We do currently require the DiagHandler field to be set in Conf.
273  /// Until that is fixed, a Config argument is required.
274  LTO(Config Conf, ThinBackend Backend = nullptr,
275  unsigned ParallelCodeGenParallelismLevel = 1);
276  ~LTO();
277 
278  /// Add an input file to the LTO link, using the provided symbol resolutions.
279  /// The symbol resolutions must appear in the enumeration order given by
280  /// InputFile::symbols().
281  Error add(std::unique_ptr<InputFile> Obj, ArrayRef<SymbolResolution> Res);
282 
283  /// Returns an upper bound on the number of tasks that the client may expect.
284  /// This may only be called after all IR object files have been added. For a
285  /// full description of tasks see LTOBackend.h.
286  unsigned getMaxTasks() const;
287 
288  /// Runs the LTO pipeline. This function calls the supplied AddStream
289  /// function to add native object files to the link.
290  ///
291  /// The Cache parameter is optional. If supplied, it will be used to cache
292  /// native object files and add them to the link.
293  ///
294  /// The client will receive at most one callback (via either AddStream or
295  /// Cache) for each task identifier.
296  Error run(AddStreamFn AddStream, NativeObjectCache Cache = nullptr);
297 
298 private:
299  Config Conf;
300 
301  struct RegularLTOState {
302  RegularLTOState(unsigned ParallelCodeGenParallelismLevel, Config &Conf);
304  uint64_t Size = 0;
305  unsigned Align = 0;
306  /// Record if at least one instance of the common was marked as prevailing
307  bool Prevailing = false;
308  };
309  std::map<std::string, CommonResolution> Commons;
310 
311  unsigned ParallelCodeGenParallelismLevel;
312  LTOLLVMContext Ctx;
313  std::unique_ptr<Module> CombinedModule;
314  std::unique_ptr<IRMover> Mover;
315 
316  // This stores the information about a regular LTO module that we have added
317  // to the link. It will either be linked immediately (for modules without
318  // summaries) or after summary-based dead stripping (for modules with
319  // summaries).
320  struct AddedModule {
321  std::unique_ptr<Module> M;
322  std::vector<GlobalValue *> Keep;
323  };
324  std::vector<AddedModule> ModsWithSummaries;
325  } RegularLTO;
326 
327  struct ThinLTOState {
328  ThinLTOState(ThinBackend Backend);
329 
330  ThinBackend Backend;
331  ModuleSummaryIndex CombinedIndex;
333  DenseMap<GlobalValue::GUID, StringRef> PrevailingModuleForGUID;
334  } ThinLTO;
335 
336  // The global resolution for a particular (mangled) symbol name. This is in
337  // particular necessary to track whether each symbol can be internalized.
338  // Because any input file may introduce a new cross-partition reference, we
339  // cannot make any final internalization decisions until all input files have
340  // been added and the client has called run(). During run() we apply
341  // internalization decisions either directly to the module (for regular LTO)
342  // or to the combined index (for ThinLTO).
343  struct GlobalResolution {
344  /// The unmangled name of the global.
345  std::string IRName;
346 
347  /// Keep track if the symbol is visible outside of a module with a summary
348  /// (i.e. in either a regular object or a regular LTO module without a
349  /// summary).
350  bool VisibleOutsideSummary = false;
351 
352  bool UnnamedAddr = true;
353 
354  /// True if module contains the prevailing definition.
355  bool Prevailing = false;
356 
357  /// Returns true if module contains the prevailing definition and symbol is
358  /// an IR symbol. For example when module-level inline asm block is used,
359  /// symbol can be prevailing in module but have no IR name.
360  bool isPrevailingIRSymbol() const { return Prevailing && !IRName.empty(); }
361 
362  /// This field keeps track of the partition number of this global. The
363  /// regular LTO object is partition 0, while each ThinLTO object has its own
364  /// partition number from 1 onwards.
365  ///
366  /// Any global that is defined or used by more than one partition, or that
367  /// is referenced externally, may not be internalized.
368  ///
369  /// Partitions generally have a one-to-one correspondence with tasks, except
370  /// that we use partition 0 for all parallel LTO code generation partitions.
371  /// Any partitioning of the combined LTO object is done internally by the
372  /// LTO backend.
373  unsigned Partition = Unknown;
374 
375  /// Special partition numbers.
376  enum : unsigned {
377  /// A partition number has not yet been assigned to this global.
378  Unknown = -1u,
379 
380  /// This global is either used by more than one partition or has an
381  /// external reference, and therefore cannot be internalized.
382  External = -2u,
383 
384  /// The RegularLTO partition
385  RegularLTO = 0,
386  };
387  };
388 
389  // Global mapping from mangled symbol names to resolutions.
390  StringMap<GlobalResolution> GlobalResolutions;
391 
392  void addModuleToGlobalRes(ArrayRef<InputFile::Symbol> Syms,
393  ArrayRef<SymbolResolution> Res, unsigned Partition,
394  bool InSummary);
395 
396  // These functions take a range of symbol resolutions [ResI, ResE) and consume
397  // the resolutions used by a single input module by incrementing ResI. After
398  // these functions return, [ResI, ResE) will refer to the resolution range for
399  // the remaining modules in the InputFile.
400  Error addModule(InputFile &Input, unsigned ModI,
401  const SymbolResolution *&ResI, const SymbolResolution *ResE);
402 
404  addRegularLTO(BitcodeModule BM, ArrayRef<InputFile::Symbol> Syms,
405  const SymbolResolution *&ResI, const SymbolResolution *ResE);
406  Error linkRegularLTO(RegularLTOState::AddedModule Mod,
407  bool LivenessFromIndex);
408 
409  Error addThinLTO(BitcodeModule BM, ArrayRef<InputFile::Symbol> Syms,
410  const SymbolResolution *&ResI, const SymbolResolution *ResE);
411 
412  Error runRegularLTO(AddStreamFn AddStream);
413  Error runThinLTO(AddStreamFn AddStream, NativeObjectCache Cache,
414  const DenseSet<GlobalValue::GUID> &GUIDPreservedSymbols);
415 
416  Error checkPartiallySplit();
417 
418  mutable bool CalledGetMaxTasks = false;
419 
420  // Use Optional to distinguish false from not yet initialized.
421  Optional<bool> EnableSplitLTOUnit;
422 };
423 
424 /// The resolution for a symbol. The linker must provide a SymbolResolution for
425 /// each global symbol based on its internal resolution of that symbol.
428  : Prevailing(0), FinalDefinitionInLinkageUnit(0), VisibleToRegularObj(0),
429  LinkerRedefined(0) {}
430 
431  /// The linker has chosen this definition of the symbol.
432  unsigned Prevailing : 1;
433 
434  /// The definition of this symbol is unpreemptable at runtime and is known to
435  /// be in this linkage unit.
437 
438  /// The definition of this symbol is visible outside of the LTO unit.
439  unsigned VisibleToRegularObj : 1;
440 
441  /// Linker redefined version of the symbol which appeared in -wrap or -defsym
442  /// linker option.
443  unsigned LinkerRedefined : 1;
444 };
445 
446 } // namespace lto
447 } // namespace llvm
448 
449 #endif
NativeObjectStream(std::unique_ptr< raw_pwrite_stream > OS)
Definition: LTO.h:191
uint64_t CallInst * C
StringRef getIRName() const
Returns the unmangled symbol name, or the empty string if this is not an IR symbol.
Definition: IRSymtab.h:181
GlobalValue::VisibilityTypes getVisibility() const
Definition: IRSymtab.h:189
ArrayRef< Symbol > symbols() const
A range over the symbols in this InputFile.
Definition: LTO.h:154
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
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:221
ArrayRef< StringRef > getComdatTable() const
Definition: LTO.h:172
LLVMContext & Context
unsigned Prevailing
The linker has chosen this definition of the symbol.
Definition: LTO.h:432
BitcodeModule & getSingleBitcodeModule()
Definition: LTO.cpp:451
bool isTLS() const
Definition: IRSymtab.h:198
uint64_t GUID
Declare a type to represent a global unique identifier for a global value.
Definition: GlobalValue.h:502
This class represents lattice values for constants.
Definition: AllocatorList.h:23
Symbol(const irsymtab::Symbol &S)
Definition: LTO.h:133
cl::opt< bool > RemarksWithHotness("lto-pass-remarks-with-hotness", cl::desc("With PGO, include profile count in optimization remarks"), cl::Hidden)
Contains the information needed by linkers for symbol resolution, as well as by the LTO implementatio...
Definition: IRSymtab.h:86
The purpose of this class is to only expose the symbol information that an LTO client should need in ...
Definition: LTO.h:129
Implements a dense probed hash-table based set.
Definition: DenseSet.h:249
unsigned LinkerRedefined
Linker redefined version of the symbol which appeared in -wrap or -defsym linker option.
Definition: LTO.h:443
bool isExecutable() const
Definition: IRSymtab.h:207
The resolution for a symbol.
Definition: LTO.h:426
This class implements a map that also provides access to all stored values in a deterministic order...
Definition: MapVector.h:37
static Expected< std::unique_ptr< InputFile > > create(MemoryBufferRef Object)
Create an InputFile.
Definition: LTO.cpp:418
std::function< void(const std::string &)> IndexWriteCallback
This ThinBackend writes individual module indexes to files, instead of running the individual backend...
Definition: LTO.h:242
bool canBeOmittedFromSymbolTable() const
Definition: IRSymtab.h:200
ThinBackend createWriteIndexesThinBackend(std::string OldPrefix, std::string NewPrefix, bool ShouldEmitImportsFiles, raw_fd_ostream *LinkedObjectsFile, IndexWriteCallback OnWrite)
Definition: LTO.cpp:1225
StringMap< FunctionsToImportTy > ImportMapTy
The map contains an entry for every module to import from, the key being the module identifier to pas...
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"))
std::unique_ptr< raw_pwrite_stream > OS
Definition: LTO.h:192
Definition: BitVector.h:937
Represents a module in a bitcode file.
Definition: BitcodeReader.h:57
StringRef getSourceFileName() const
Returns the source file path specified at compile time.
Definition: LTO.h:169
std::unordered_set< GlobalValue::GUID > ExportSetTy
The set contains an entry for every global value the module exports.
Tagged union holding either a T or a Error.
Definition: CachePruning.h:22
bool isCommon() const
Definition: IRSymtab.h:195
Key
PAL metadata keys.
StringRef getTargetTriple() const
Returns the input file&#39;s target triple.
Definition: LTO.h:166
DenseMap< GlobalValue::GUID, GlobalValueSummary * > GVSummaryMapTy
Map of global value GUID to its summary, used to identify values defined in a particular module...
bool isUndefined() const
Definition: IRSymtab.h:193
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
Definition: APInt.h:32
An input file.
Definition: LTO.h:101
This class implements a resolution-based interface to LLVM&#39;s LTO functionality.
Definition: LTO.h:265
Class to hold module path string table and global value map, and encapsulate methods for operating on...
StringRef getName() const
Returns the mangled symbol name.
Definition: IRSymtab.h:177
Expected< std::unique_ptr< ToolOutputFile > > setupStatsFile(StringRef StatsFilename)
Setups the output file for saving statistics.
Definition: LTO.cpp:1360
std::unique_ptr< Module > M
Definition: LTO.h:321
std::function< std::unique_ptr< ThinBackendProc >(Config &C, ModuleSummaryIndex &CombinedIndex, StringMap< GVSummaryMapTy > &ModuleToDefinedGVSummaries, AddStreamFn AddStream, NativeObjectCache Cache)> ThinBackend
A ThinBackend defines what happens after the thin-link phase during ThinLTO.
Definition: LTO.h:224
uint32_t getCommonAlignment() const
Definition: IRSymtab.h:214
This class wraps an output stream for a native object.
Definition: LTO.h:189
bool isIndirect() const
Definition: IRSymtab.h:196
std::function< AddStreamFn(unsigned Task, StringRef Key)> NativeObjectCache
This is the type of a native object cache.
Definition: LTO.h:216
bool isUsed() const
Definition: IRSymtab.h:197
LTO configuration.
Definition: Config.h:35
void thinLTOResolvePrevailingInIndex(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:352
This represents a symbol that has been read from a storage::Symbol and possibly a storage::Uncommon...
Definition: IRSymtab.h:165
const T * data() const
Definition: ArrayRef.h:145
std::function< std::unique_ptr< NativeObjectStream >(unsigned Task)> AddStreamFn
This type defines the callback to add a native object that is generated on the fly.
Definition: LTO.h:201
StringRef getSectionName() const
Definition: IRSymtab.h:226
int getComdatIndex() const
Returns the index into the comdat table (see Reader::getComdatTable()), or -1 if not a comdat member...
Definition: IRSymtab.h:185
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:70
static uint64_t add(uint64_t LeftOp, uint64_t RightOp)
Definition: FileCheck.cpp:196
The access may modify the value stored in memory.
StringMap - This is an unconventional map that is specialized for handling keys that are "strings"...
Definition: StringMap.h:219
LinkageTypes
An enumeration for the kinds of linkage for global values.
Definition: GlobalValue.h:47
ThinBackend createInProcessThinBackend(unsigned ParallelismLevel)
This ThinBackend runs the individual backend jobs in-process.
Definition: LTO.cpp:1137
bool isWeak() const
Definition: IRSymtab.h:194
std::vector< GlobalValue * > Keep
Definition: LTO.h:322
A raw_ostream that writes to a file descriptor.
Definition: raw_ostream.h:365
#define I(x, y, z)
Definition: MD5.cpp:58
uint32_t Size
Definition: Profile.cpp:46
unsigned VisibleToRegularObj
The definition of this symbol is visible outside of the LTO unit.
Definition: LTO.h:439
ModuleSummaryIndex.h This file contains the declarations the classes that hold the module index and s...
StringRef getCOFFLinkerOpts() const
Returns linker options specified in the input file.
Definition: LTO.h:157
cl::opt< std::string > RemarksFilename("lto-pass-remarks-output", cl::desc("Output filename for pass remarks"), cl::value_desc("filename"))
Lightweight error class with error context and mandatory checking.
Definition: Error.h:157
uint64_t getCommonSize() const
Definition: IRSymtab.h:209
A derived class of LLVMContext that initializes itself according to a given Config object...
Definition: Config.h:214
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:48
ArrayRef< StringRef > getDependentLibraries() const
Returns dependent library specifiers from the input file.
Definition: LTO.h:160
unsigned FinalDefinitionInLinkageUnit
The definition of this symbol is unpreemptable at runtime and is known to be in this linkage unit...
Definition: LTO.h:436
Expected< std::unique_ptr< ToolOutputFile > > setupOptimizationRemarks(LLVMContext &Context, StringRef RemarksFilename, StringRef RemarksPasses, bool RemarksWithHotness, int Count=-1)
Setup optimization remarks.
Definition: LTO.cpp:1341
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:1150
void thinLTOInternalizeAndPromoteInIndex(ModuleSummaryIndex &Index, function_ref< bool(StringRef, GlobalValue::GUID)> isExported)
Update the linkages in the given Index to mark exported values as external and non-exported values as...
Definition: LTO.cpp:408