LLVM 17.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"
25#include "llvm/Support/Error.h"
26#include "llvm/Support/thread.h"
29
30namespace llvm {
31
32class Error;
33class IRMover;
34class LLVMContext;
35class MemoryBufferRef;
36class Module;
37class raw_pwrite_stream;
38class 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
76namespace 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.
81std::string getThinLTOOutputFile(const std::string &Path,
82 const std::string &OldPrefix,
83 const std::string &NewPrefix);
84
85/// Setup optimization remarks.
86Expected<std::unique_ptr<ToolOutputFile>> setupLLVMOptimizationRemarks(
87 LLVMContext &Context, StringRef RemarksFilename, StringRef RemarksPasses,
88 StringRef RemarksFormat, bool RemarksWithHotness,
89 std::optional<uint64_t> RemarksHotnessThreshold = 0, int Count = -1);
90
91/// Setups the output file for saving statistics.
92Expected<std::unique_ptr<ToolOutputFile>>
93setupStatsFile(StringRef StatsFilename);
94
95/// Produces a container ordering for optimal multi-threaded processing. Returns
96/// ordered indices to elements in the input array.
97std::vector<int> generateModulesOrdering(ArrayRef<BitcodeModule *> R);
98
99class LTO;
100struct SymbolResolution;
101class 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.
106public:
107 class Symbol;
108
109private:
110 // FIXME: Remove LTO class friendship once we have bitcode symbol tables.
111 friend LTO;
112 InputFile() = default;
113
114 std::vector<BitcodeModule> Mods;
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
125public:
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
183private:
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.
193using 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).
200/// OnWrite is callback which receives module identifier and notifies LTO user
201/// that index file for the module (and optionally imports file) was created.
202/// ShouldEmitIndexFiles being true will write sharded ThinLTO index files
203/// to the same path as the input module, with suffix ".thinlto.bc"
204/// ShouldEmitImportsFiles is true it also writes a list of imported files to a
205/// similar path with ".imports" appended instead.
206using IndexWriteCallback = std::function<void(const std::string &)>;
208 IndexWriteCallback OnWrite = nullptr,
209 bool ShouldEmitIndexFiles = false,
210 bool ShouldEmitImportsFiles = false);
211
212/// This ThinBackend writes individual module indexes to files, instead of
213/// running the individual backend jobs. This backend is for distributed builds
214/// where separate processes will invoke the real backends.
215///
216/// To find the path to write the index to, the backend checks if the path has a
217/// prefix of OldPrefix; if so, it replaces that prefix with NewPrefix. It then
218/// appends ".thinlto.bc" and writes the index to that path. If
219/// ShouldEmitImportsFiles is true it also writes a list of imported files to a
220/// similar path with ".imports" appended instead.
221/// LinkedObjectsFile is an output stream to write the list of object files for
222/// the final ThinLTO linking. Can be nullptr.
223/// OnWrite is callback which receives module identifier and notifies LTO user
224/// that index file for the module (and optionally imports file) was created.
225ThinBackend createWriteIndexesThinBackend(std::string OldPrefix,
226 std::string NewPrefix,
227 bool ShouldEmitImportsFiles,
228 raw_fd_ostream *LinkedObjectsFile,
229 IndexWriteCallback OnWrite);
230
231/// This class implements a resolution-based interface to LLVM's LTO
232/// functionality. It supports regular LTO, parallel LTO code generation and
233/// ThinLTO. You can use it from a linker in the following way:
234/// - Set hooks and code generation options (see lto::Config struct defined in
235/// Config.h), and use the lto::Config object to create an lto::LTO object.
236/// - Create lto::InputFile objects using lto::InputFile::create(), then use
237/// the symbols() function to enumerate its symbols and compute a resolution
238/// for each symbol (see SymbolResolution below).
239/// - After the linker has visited each input file (and each regular object
240/// file) and computed a resolution for each symbol, take each lto::InputFile
241/// and pass it and an array of symbol resolutions to the add() function.
242/// - Call the getMaxTasks() function to get an upper bound on the number of
243/// native object files that LTO may add to the link.
244/// - Call the run() function. This function will use the supplied AddStream
245/// and Cache functions to add up to getMaxTasks() native object files to
246/// the link.
247class LTO {
248 friend InputFile;
249
250public:
251 /// Create an LTO object. A default constructed LTO object has a reasonable
252 /// production configuration, but you can customize it by passing arguments to
253 /// this constructor.
254 /// FIXME: We do currently require the DiagHandler field to be set in Conf.
255 /// Until that is fixed, a Config argument is required.
256 LTO(Config Conf, ThinBackend Backend = nullptr,
257 unsigned ParallelCodeGenParallelismLevel = 1);
259
260 /// Add an input file to the LTO link, using the provided symbol resolutions.
261 /// The symbol resolutions must appear in the enumeration order given by
262 /// InputFile::symbols().
263 Error add(std::unique_ptr<InputFile> Obj, ArrayRef<SymbolResolution> Res);
264
265 /// Returns an upper bound on the number of tasks that the client may expect.
266 /// This may only be called after all IR object files have been added. For a
267 /// full description of tasks see LTOBackend.h.
268 unsigned getMaxTasks() const;
269
270 /// Runs the LTO pipeline. This function calls the supplied AddStream
271 /// function to add native object files to the link.
272 ///
273 /// The Cache parameter is optional. If supplied, it will be used to cache
274 /// native object files and add them to the link.
275 ///
276 /// The client will receive at most one callback (via either AddStream or
277 /// Cache) for each task identifier.
278 Error run(AddStreamFn AddStream, FileCache Cache = nullptr);
279
280 /// Static method that returns a list of libcall symbols that can be generated
281 /// by LTO but might not be visible from bitcode symbol table.
283
284private:
285 Config Conf;
286
287 struct RegularLTOState {
288 RegularLTOState(unsigned ParallelCodeGenParallelismLevel,
289 const Config &Conf);
293 /// Record if at least one instance of the common was marked as prevailing
294 bool Prevailing = false;
295 };
296 std::map<std::string, CommonResolution> Commons;
297
298 unsigned ParallelCodeGenParallelismLevel;
299 LTOLLVMContext Ctx;
300 std::unique_ptr<Module> CombinedModule;
301 std::unique_ptr<IRMover> Mover;
302
303 // This stores the information about a regular LTO module that we have added
304 // to the link. It will either be linked immediately (for modules without
305 // summaries) or after summary-based dead stripping (for modules with
306 // summaries).
307 struct AddedModule {
308 std::unique_ptr<Module> M;
309 std::vector<GlobalValue *> Keep;
310 };
311 std::vector<AddedModule> ModsWithSummaries;
312 bool EmptyCombinedModule = true;
313 } RegularLTO;
314
316
317 struct ThinLTOState {
318 ThinLTOState(ThinBackend Backend);
319
320 ThinBackend Backend;
321 ModuleSummaryIndex CombinedIndex;
322 // The full set of bitcode modules in input order.
323 ModuleMapType ModuleMap;
324 // The bitcode modules to compile, if specified by the LTO Config.
325 std::optional<ModuleMapType> ModulesToCompile;
326 DenseMap<GlobalValue::GUID, StringRef> PrevailingModuleForGUID;
327 } ThinLTO;
328
329 // The global resolution for a particular (mangled) symbol name. This is in
330 // particular necessary to track whether each symbol can be internalized.
331 // Because any input file may introduce a new cross-partition reference, we
332 // cannot make any final internalization decisions until all input files have
333 // been added and the client has called run(). During run() we apply
334 // internalization decisions either directly to the module (for regular LTO)
335 // or to the combined index (for ThinLTO).
336 struct GlobalResolution {
337 /// The unmangled name of the global.
338 std::string IRName;
339
340 /// Keep track if the symbol is visible outside of a module with a summary
341 /// (i.e. in either a regular object or a regular LTO module without a
342 /// summary).
343 bool VisibleOutsideSummary = false;
344
345 /// The symbol was exported dynamically, and therefore could be referenced
346 /// by a shared library not visible to the linker.
347 bool ExportDynamic = false;
348
349 bool UnnamedAddr = true;
350
351 /// True if module contains the prevailing definition.
352 bool Prevailing = false;
353
354 /// Returns true if module contains the prevailing definition and symbol is
355 /// an IR symbol. For example when module-level inline asm block is used,
356 /// symbol can be prevailing in module but have no IR name.
357 bool isPrevailingIRSymbol() const { return Prevailing && !IRName.empty(); }
358
359 /// This field keeps track of the partition number of this global. The
360 /// regular LTO object is partition 0, while each ThinLTO object has its own
361 /// partition number from 1 onwards.
362 ///
363 /// Any global that is defined or used by more than one partition, or that
364 /// is referenced externally, may not be internalized.
365 ///
366 /// Partitions generally have a one-to-one correspondence with tasks, except
367 /// that we use partition 0 for all parallel LTO code generation partitions.
368 /// Any partitioning of the combined LTO object is done internally by the
369 /// LTO backend.
370 unsigned Partition = Unknown;
371
372 /// Special partition numbers.
373 enum : unsigned {
374 /// A partition number has not yet been assigned to this global.
375 Unknown = -1u,
376
377 /// This global is either used by more than one partition or has an
378 /// external reference, and therefore cannot be internalized.
379 External = -2u,
380
381 /// The RegularLTO partition
382 RegularLTO = 0,
383 };
384 };
385
386 // Global mapping from mangled symbol names to resolutions.
387 StringMap<GlobalResolution> GlobalResolutions;
388
389 void addModuleToGlobalRes(ArrayRef<InputFile::Symbol> Syms,
390 ArrayRef<SymbolResolution> Res, unsigned Partition,
391 bool InSummary);
392
393 // These functions take a range of symbol resolutions [ResI, ResE) and consume
394 // the resolutions used by a single input module by incrementing ResI. After
395 // these functions return, [ResI, ResE) will refer to the resolution range for
396 // the remaining modules in the InputFile.
397 Error addModule(InputFile &Input, unsigned ModI,
398 const SymbolResolution *&ResI, const SymbolResolution *ResE);
399
400 Expected<RegularLTOState::AddedModule>
401 addRegularLTO(BitcodeModule BM, ArrayRef<InputFile::Symbol> Syms,
402 const SymbolResolution *&ResI, const SymbolResolution *ResE);
403 Error linkRegularLTO(RegularLTOState::AddedModule Mod,
404 bool LivenessFromIndex);
405
406 Error addThinLTO(BitcodeModule BM, ArrayRef<InputFile::Symbol> Syms,
407 const SymbolResolution *&ResI, const SymbolResolution *ResE);
408
409 Error runRegularLTO(AddStreamFn AddStream);
410 Error runThinLTO(AddStreamFn AddStream, FileCache Cache,
411 const DenseSet<GlobalValue::GUID> &GUIDPreservedSymbols);
412
413 Error checkPartiallySplit();
414
415 mutable bool CalledGetMaxTasks = false;
416
417 // Use Optional to distinguish false from not yet initialized.
418 std::optional<bool> EnableSplitLTOUnit;
419
420 // Identify symbols exported dynamically, and that therefore could be
421 // referenced by a shared library not visible to the linker.
422 DenseSet<GlobalValue::GUID> DynamicExportSymbols;
423
424 // Diagnostic optimization remarks file
425 std::unique_ptr<ToolOutputFile> DiagnosticOutputFile;
426};
427
428/// The resolution for a symbol. The linker must provide a SymbolResolution for
429/// each global symbol based on its internal resolution of that symbol.
434
435 /// The linker has chosen this definition of the symbol.
436 unsigned Prevailing : 1;
437
438 /// The definition of this symbol is unpreemptable at runtime and is known to
439 /// be in this linkage unit.
441
442 /// The definition of this symbol is visible outside of the LTO unit.
444
445 /// The symbol was exported dynamically, and therefore could be referenced
446 /// by a shared library not visible to the linker.
447 unsigned ExportDynamic : 1;
448
449 /// Linker redefined version of the symbol which appeared in -wrap or -defsym
450 /// linker option.
451 unsigned LinkerRedefined : 1;
452};
453
454} // namespace lto
455} // namespace llvm
456
457#endif
This file defines the StringMap class.
Provides passes for computing function attributes based on interprocedural analyses.
#define I(x, y, z)
Definition: MD5.cpp:58
Machine Check Debug Module
This file implements a map that provides insertion order iteration.
ModuleSummaryIndex.h This file contains the declarations the classes that hold the module index and s...
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: ArrayRef.h:41
Represents a module in a bitcode file.
Lightweight error class with error context and mandatory checking.
Definition: Error.h:156
Tagged union holding either a T or a Error.
Definition: Error.h:470
StringMap< FunctionsToImportTy > ImportMapTy
The map contains an entry for every module to import from, the key being the module identifier to pas...
DenseSet< ValueInfo > ExportSetTy
The set contains an entry for every global value the module exports.
uint64_t GUID
Declare a type to represent a global unique identifier for a global value.
Definition: GlobalValue.h:583
LinkageTypes
An enumeration for the kinds of linkage for global values.
Definition: GlobalValue.h:47
Class to hold module path string table and global value map, and encapsulate methods for operating on...
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1200
StringMap - This is an unconventional map that is specialized for handling keys that are "strings",...
Definition: StringMap.h:111
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:50
This tells how a thread pool will be used.
Definition: Threading.h:116
The purpose of this class is to only expose the symbol information that an LTO client should need in ...
Definition: LTO.h:133
Symbol(const irsymtab::Symbol &S)
Definition: LTO.h:137
An input file.
Definition: LTO.h:105
static Expected< std::unique_ptr< InputFile > > create(MemoryBufferRef Object)
Create an InputFile.
Definition: LTO.cpp:475
ArrayRef< Symbol > symbols() const
A range over the symbols in this InputFile.
Definition: LTO.h:158
StringRef getCOFFLinkerOpts() const
Returns linker options specified in the input file.
Definition: LTO.h:161
ArrayRef< StringRef > getDependentLibraries() const
Returns dependent library specifiers from the input file.
Definition: LTO.h:164
ArrayRef< std::pair< StringRef, Comdat::SelectionKind > > getComdatTable() const
Definition: LTO.h:176
StringRef getTargetTriple() const
Returns the input file's target triple.
Definition: LTO.h:170
StringRef getName() const
Returns the path to the InputFile.
Definition: LTO.cpp:504
BitcodeModule & getSingleBitcodeModule()
Definition: LTO.cpp:508
StringRef getSourceFileName() const
Returns the source file path specified at compile time.
Definition: LTO.h:173
This class implements a resolution-based interface to LLVM's LTO functionality.
Definition: LTO.h:247
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:632
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:1192
Error run(AddStreamFn AddStream, FileCache Cache=nullptr)
Runs the LTO pipeline.
Definition: LTO.cpp:1036
unsigned getMaxTasks() const
Returns an upper bound on the number of tasks that the client may expect.
Definition: LTO.cpp:990
A raw_ostream that writes to a file descriptor.
Definition: raw_ostream.h:454
@ C
The default llvm calling convention, compatible with C.
Definition: CallingConv.h:34
ThinBackend createInProcessThinBackend(ThreadPoolStrategy Parallelism, IndexWriteCallback OnWrite=nullptr, bool ShouldEmitIndexFiles=false, bool ShouldEmitImportsFiles=false)
Definition: LTO.cpp:1383
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:1461
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
std::function< void(const std::string &)> IndexWriteCallback
This ThinBackend runs the individual backend jobs in-process.
Definition: LTO.h:206
Expected< std::unique_ptr< ToolOutputFile > > setupStatsFile(StringRef StatsFilename)
Setups the output file for saving statistics.
Definition: LTO.cpp:1670
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:1399
std::vector< int > generateModulesOrdering(ArrayRef< BitcodeModule * > R)
Produces a container ordering for optimal multi-threaded processing.
Definition: LTO.cpp:1689
Expected< std::unique_ptr< ToolOutputFile > > setupLLVMOptimizationRemarks(LLVMContext &Context, StringRef RemarksFilename, StringRef RemarksPasses, StringRef RemarksFormat, bool RemarksWithHotness, std::optional< uint64_t > RemarksHotnessThreshold=0, int Count=-1)
Setup optimization remarks.
Definition: LTO.cpp:1645
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
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 > 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::function< Expected< std::unique_ptr< CachedFileStream > >(unsigned Task, const Twine &ModuleName)> AddStreamFn
This type defines the callback to add a file that is generated on the fly.
Definition: Caching.h:42
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:462
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:81
cl::opt< bool > RemarksWithHotness("lto-pass-remarks-with-hotness", cl::desc("With PGO, include profile count in optimization remarks"), cl::Hidden)
cl::opt< std::string > RemarksFilename("lto-pass-remarks-output", cl::desc("Output filename for pass remarks"), cl::value_desc("filename"))
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:402
@ Mod
The access may modify the value stored in memory.
cl::opt< std::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)
std::function< Expected< AddStreamFn >(unsigned Task, StringRef Key, const Twine &ModuleName)> FileCache
This is the type of a file cache.
Definition: Caching.h:58
DenseMap< GlobalValue::GUID, GlobalValueSummary * > GVSummaryMapTy
Map of global value GUID to its summary, used to identify values defined in a particular module,...
This struct is a compact representation of a valid (non-zero power of two) alignment.
Definition: Alignment.h:39
This represents a symbol that has been read from a storage::Symbol and possibly a storage::Uncommon.
Definition: IRSymtab.h:170
StringRef getName() const
Returns the mangled symbol name.
Definition: IRSymtab.h:182
bool canBeOmittedFromSymbolTable() const
Definition: IRSymtab.h:205
bool isUsed() const
Definition: IRSymtab.h:202
StringRef getSectionName() const
Definition: IRSymtab.h:231
bool isTLS() const
Definition: IRSymtab.h:203
bool isWeak() const
Definition: IRSymtab.h:199
bool isIndirect() const
Definition: IRSymtab.h:201
bool isCommon() const
Definition: IRSymtab.h:200
uint32_t getCommonAlignment() const
Definition: IRSymtab.h:219
bool isExecutable() const
Definition: IRSymtab.h:212
uint64_t getCommonSize() const
Definition: IRSymtab.h:214
int getComdatIndex() const
Returns the index into the comdat table (see Reader::getComdatTable()), or -1 if not a comdat member.
Definition: IRSymtab.h:190
GlobalValue::VisibilityTypes getVisibility() const
Definition: IRSymtab.h:194
bool isUndefined() const
Definition: IRSymtab.h:198
StringRef getIRName() const
Returns the unmangled symbol name, or the empty string if this is not an IR symbol.
Definition: IRSymtab.h:186
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
Contains the information needed by linkers for symbol resolution, as well as by the LTO implementatio...
Definition: IRSymtab.h:91
LTO configuration.
Definition: Config.h:41
A derived class of LLVMContext that initializes itself according to a given Config object.
Definition: Config.h:290
std::vector< GlobalValue * > Keep
Definition: LTO.h:309
std::unique_ptr< Module > M
Definition: LTO.h:308
bool Prevailing
Record if at least one instance of the common was marked as prevailing.
Definition: LTO.h:294
The resolution for a symbol.
Definition: LTO.h:430
unsigned FinalDefinitionInLinkageUnit
The definition of this symbol is unpreemptable at runtime and is known to be in this linkage unit.
Definition: LTO.h:440
unsigned ExportDynamic
The symbol was exported dynamically, and therefore could be referenced by a shared library not visibl...
Definition: LTO.h:447
unsigned Prevailing
The linker has chosen this definition of the symbol.
Definition: LTO.h:436
unsigned LinkerRedefined
Linker redefined version of the symbol which appeared in -wrap or -defsym linker option.
Definition: LTO.h:451
unsigned VisibleToRegularObj
The definition of this symbol is visible outside of the LTO unit.
Definition: LTO.h:443