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