LLVM 20.0.0git
|
#include "llvm/LTO/Config.h"
Public Types | |
enum | VisScheme { FromPrevailing , ELF } |
using | ModuleHookFn = std::function< bool(unsigned Task, const Module &)> |
The following callbacks deal with tasks, which normally represent the entire optimization and code generation pipeline for what will become a single native object file. | |
using | CombinedIndexHookFn = std::function< bool(const ModuleSummaryIndex &Index, const DenseSet< GlobalValue::GUID > &GUIDPreservedSymbols)> |
A combined index hook is called after all per-module indexes have been combined (ThinLTO-specific). | |
Public Member Functions | |
Error | addSaveTemps (std::string OutputFileName, bool UseInputModulePath=false, const DenseSet< StringRef > &SaveTempsArgs={}) |
This is a convenience function that configures this Config object to write temporary files named after the given OutputFileName for each of the LTO phases to disk. | |
Public Attributes | |
std::string | CPU |
TargetOptions | Options |
std::vector< std::string > | MAttrs |
std::vector< std::string > | MllvmArgs |
std::vector< std::string > | PassPlugins |
std::function< void(legacy::PassManager &)> | PreCodeGenPassesHook |
For adding passes that run right before codegen. | |
std::optional< Reloc::Model > | RelocModel = Reloc::PIC_ |
std::optional< CodeModel::Model > | CodeModel |
CodeGenOptLevel | CGOptLevel = CodeGenOptLevel::Default |
CodeGenFileType | CGFileType = CodeGenFileType::ObjectFile |
unsigned | OptLevel = 2 |
bool | VerifyEach = false |
bool | DisableVerify = false |
bool | Freestanding = false |
Flag to indicate that the optimizer should not assume builtins are present on the target. | |
bool | CodeGenOnly = false |
Disable entirely the optimizer, including importing for ThinLTO. | |
bool | RunCSIRInstr = false |
Run PGO context sensitive IR instrumentation. | |
bool | PGOWarnMismatch = true |
Turn on/off the warning about a hash mismatch in the PGO profile data. | |
bool | HasWholeProgramVisibility = false |
Asserts whether we can assume whole program visibility during the LTO link. | |
bool | ValidateAllVtablesHaveTypeInfos = false |
We're validating that all native vtables have corresponding type infos. | |
bool | AllVtablesHaveTypeInfos = false |
If all native vtables have corresponding type infos, allow usage of RTTI to block devirtualization on types used in native files. | |
bool | AlwaysEmitRegularLTOObj = false |
Always emit a Regular LTO object even when it is empty because no Regular LTO modules were linked. | |
VisScheme | VisibilityScheme = FromPrevailing |
Allows non-imported definitions to get the potentially more constraining visibility from the prevailing definition. | |
std::string | OptPipeline |
If this field is set, the set of passes run in the middle-end optimizer will be the one specified by the string. | |
std::string | AAPipeline |
std::string | OverrideTriple |
Setting this field will replace target triples in input files with this triple. | |
std::string | DefaultTriple |
Setting this field will replace unspecified target triples in input files with this triple. | |
std::string | CSIRProfile |
Context Sensitive PGO profile path. | |
std::string | SampleProfile |
Sample PGO profile path. | |
std::string | ProfileRemapping |
Name remapping file for profile data. | |
std::string | DwoDir |
The directory to store .dwo files. | |
std::string | SplitDwarfFile |
The name for the split debug info file used for the DW_AT_[GNU_]dwo_name attribute in the skeleton CU. | |
std::string | SplitDwarfOutput |
The path to write a .dwo file to. | |
std::string | RemarksFilename |
Optimization remarks file path. | |
std::string | RemarksPasses |
Optimization remarks pass filter. | |
bool | RemarksWithHotness = false |
Whether to emit optimization remarks with hotness informations. | |
std::optional< uint64_t > | RemarksHotnessThreshold = 0 |
The minimum hotness value a diagnostic needs in order to be included in optimization diagnostics. | |
std::string | RemarksFormat |
The format used for serializing remarks (default: YAML). | |
bool | DebugPassManager = false |
Whether to emit the pass manager debuggging informations. | |
std::string | StatsFile |
Statistics output file path. | |
std::vector< std::string > | ThinLTOModulesToCompile |
Specific thinLTO modules to compile. | |
bool | TimeTraceEnabled = false |
Time trace enabled. | |
unsigned | TimeTraceGranularity = 500 |
Time trace granularity. | |
bool | ShouldDiscardValueNames = true |
DiagnosticHandlerFunction | DiagHandler |
bool | AddFSDiscriminator = false |
Add FSAFDO discriminators. | |
std::unique_ptr< raw_ostream > | ResolutionFile |
If this field is set, LTO will write input file paths and symbol resolutions here in llvm-lto2 command line flag format. | |
PipelineTuningOptions | PTO |
Tunable parameters for passes in the default pipelines. | |
ModuleHookFn | PreOptModuleHook |
This module hook is called after linking (regular LTO) or loading (ThinLTO) the module, before modifying it. | |
ModuleHookFn | PostPromoteModuleHook |
This hook is called after promoting any internal functions (ThinLTO-specific). | |
ModuleHookFn | PostInternalizeModuleHook |
This hook is called after internalizing the module. | |
ModuleHookFn | PostImportModuleHook |
This hook is called after importing from other modules (ThinLTO-specific). | |
ModuleHookFn | PostOptModuleHook |
This module hook is called after optimization is complete. | |
ModuleHookFn | PreCodeGenModuleHook |
This module hook is called before code generation. | |
CombinedIndexHookFn | CombinedIndexHook |
LTO configuration.
A linker can configure LTO by setting fields in this data structure and passing it to the lto::LTO constructor.
using llvm::lto::Config::CombinedIndexHookFn = std::function<bool( const ModuleSummaryIndex &Index, const DenseSet<GlobalValue::GUID> &GUIDPreservedSymbols)> |
A combined index hook is called after all per-module indexes have been combined (ThinLTO-specific).
It can be used to implement -save-temps for the combined index.
If this function returns false, any further processing for ThinLTO tasks is aborted.
It is called regardless of whether the backend is in-process, although it is not called from individual backend processes.
using llvm::lto::Config::ModuleHookFn = std::function<bool(unsigned Task, const Module &)> |
The following callbacks deal with tasks, which normally represent the entire optimization and code generation pipeline for what will become a single native object file.
Each task has a unique identifier between 0 and getMaxTasks()-1, which is supplied to the callback via the Task parameter. A task represents the entire pipeline for ThinLTO and regular (non-parallel) LTO, but a parallel code generation task will be split into N tasks before code generation, where N is the parallelism level.
LTO may decide to stop processing a task at any time, for example if the module is empty or if a module hook (see below) returns false. For this reason, the client should not expect to receive exactly getMaxTasks() native object files. A module hook may be used by a linker to perform actions during the LTO pipeline. For example, a linker may use this function to implement -save-temps. If this function returns false, any further processing for that task is aborted.
Module hooks must be thread safe with respect to the linker's internal data structures. A module hook will never be called concurrently from multiple threads with the same task ID, or the same module.
Note that in out-of-process backend scenarios, none of the hooks will be called for ThinLTO tasks.
Error Config::addSaveTemps | ( | std::string | OutputFileName, |
bool | UseInputModulePath = false , |
||
const DenseSet< StringRef > & | SaveTempsArgs = {} |
||
) |
This is a convenience function that configures this Config object to write temporary files named after the given OutputFileName for each of the LTO phases to disk.
A client can use this function to implement -save-temps.
FIXME: Temporary files derived from ThinLTO backends are currently named after the input file name, rather than the output file name, when UseInputModulePath is set to true.
Specifically, it (1) sets each of the above module hooks and the combined index hook to a function that calls the hook function (if any) that was present in the appropriate field when the addSaveTemps function was called, and writes the module to a bitcode file with a name prefixed by the given output file name, and (2) creates a resolution file whose name is prefixed by the given output file name and sets ResolutionFile to its file handle.
SaveTempsArgs can be specified to select which temps to save. If SaveTempsArgs is not provided, all temps are saved.
Definition at line 87 of file LTOBackend.cpp.
References CombinedIndexHook, llvm::detail::DenseSetImpl< ValueT, MapTy, ValueInfoT >::contains(), llvm::detail::DenseSetImpl< ValueT, MapTy, ValueInfoT >::empty(), llvm::errorCodeToError(), llvm::sys::fs::OF_None, llvm::sys::fs::OF_Text, llvm::sys::fs::OF_TextWithCRLF, OS, PostImportModuleHook, PostInternalizeModuleHook, PostOptModuleHook, PostPromoteModuleHook, PreCodeGenModuleHook, PreOptModuleHook, reportOpenError(), ResolutionFile, ShouldDiscardValueNames, llvm::Error::success(), llvm::WriteBitcodeToFile(), and llvm::writeIndexToFile().
std::string llvm::lto::Config::AAPipeline |
Definition at line 105 of file Config.h.
Referenced by llvm::computeLTOCacheKey(), and runNewPMPasses().
bool llvm::lto::Config::AddFSDiscriminator = false |
bool llvm::lto::Config::AllVtablesHaveTypeInfos = false |
bool llvm::lto::Config::AlwaysEmitRegularLTOObj = false |
CodeGenFileType llvm::lto::Config::CGFileType = CodeGenFileType::ObjectFile |
Definition at line 58 of file Config.h.
Referenced by codegen(), llvm::computeLTOCacheKey(), and llvm::LTOCodeGenerator::setFileType().
CodeGenOptLevel llvm::lto::Config::CGOptLevel = CodeGenOptLevel::Default |
Definition at line 57 of file Config.h.
Referenced by llvm::computeLTOCacheKey(), createTargetMachine(), and llvm::LTOCodeGenerator::setOptLevel().
bool llvm::lto::Config::CodeGenOnly = false |
Disable entirely the optimizer, including importing for ThinLTO.
Definition at line 68 of file Config.h.
Referenced by llvm::LTOCodeGenerator::compileOptimized(), and llvm::lto::thinBackend().
std::optional<CodeModel::Model> llvm::lto::Config::CodeModel |
Definition at line 56 of file Config.h.
Referenced by llvm::computeLTOCacheKey(), createTargetMachine(), and llvm::LTOCodeGenerator::LTOCodeGenerator().
CombinedIndexHookFn llvm::lto::Config::CombinedIndexHook |
Definition at line 255 of file Config.h.
Referenced by addSaveTemps().
std::string llvm::lto::Config::CPU |
Definition at line 48 of file Config.h.
Referenced by llvm::computeLTOCacheKey(), createTargetMachine(), and llvm::LTOCodeGenerator::setCpu().
std::string llvm::lto::Config::CSIRProfile |
Context Sensitive PGO profile path.
Definition at line 116 of file Config.h.
Referenced by llvm::LTOCodeGenerator::LTOCodeGenerator(), and runNewPMPasses().
bool llvm::lto::Config::DebugPassManager = false |
Whether to emit the pass manager debuggging informations.
Definition at line 166 of file Config.h.
Referenced by runNewPMPasses(), and llvm::LTOCodeGenerator::setDebugPassManager().
std::string llvm::lto::Config::DefaultTriple |
Setting this field will replace unspecified target triples in input files with this triple.
Definition at line 113 of file Config.h.
Referenced by llvm::computeLTOCacheKey().
DiagnosticHandlerFunction llvm::lto::Config::DiagHandler |
bool llvm::lto::Config::DisableVerify = false |
Definition at line 61 of file Config.h.
Referenced by runNewPMPasses(), and llvm::LTOCodeGenerator::setDisableVerify().
std::string llvm::lto::Config::DwoDir |
The directory to store .dwo files.
Definition at line 125 of file Config.h.
Referenced by codegen(), and llvm::computeLTOCacheKey().
bool llvm::lto::Config::Freestanding = false |
Flag to indicate that the optimizer should not assume builtins are present on the target.
Definition at line 65 of file Config.h.
Referenced by llvm::computeLTOCacheKey(), runNewPMPasses(), and llvm::LTOCodeGenerator::setFreestanding().
bool llvm::lto::Config::HasWholeProgramVisibility = false |
std::vector<std::string> llvm::lto::Config::MAttrs |
Definition at line 50 of file Config.h.
Referenced by llvm::computeLTOCacheKey(), createTargetMachine(), and llvm::LTOCodeGenerator::setAttrs().
std::vector<std::string> llvm::lto::Config::MllvmArgs |
Definition at line 51 of file Config.h.
Referenced by llvm::computeLTOCacheKey().
TargetOptions llvm::lto::Config::Options |
Definition at line 49 of file Config.h.
Referenced by llvm::computeLTOCacheKey(), createTargetMachine(), and llvm::LTOCodeGenerator::setTargetOptions().
unsigned llvm::lto::Config::OptLevel = 2 |
Definition at line 59 of file Config.h.
Referenced by llvm::computeLTOCacheKey(), llvm::lto::opt(), llvm::lto::LTO::run(), and llvm::LTOCodeGenerator::setOptLevel().
std::string llvm::lto::Config::OptPipeline |
If this field is set, the set of passes run in the middle-end optimizer will be the one specified by the string.
Only works with the new pass manager as the old one doesn't have this ability.
Definition at line 100 of file Config.h.
Referenced by llvm::computeLTOCacheKey(), and runNewPMPasses().
std::string llvm::lto::Config::OverrideTriple |
Setting this field will replace target triples in input files with this triple.
Definition at line 109 of file Config.h.
Referenced by llvm::computeLTOCacheKey().
std::vector<std::string> llvm::lto::Config::PassPlugins |
Definition at line 52 of file Config.h.
Referenced by runNewPMPasses().
Turn on/off the warning about a hash mismatch in the PGO profile data.
Definition at line 74 of file Config.h.
Referenced by runNewPMPasses().
ModuleHookFn llvm::lto::Config::PostImportModuleHook |
This hook is called after importing from other modules (ThinLTO-specific).
Definition at line 233 of file Config.h.
Referenced by addSaveTemps(), and llvm::lto::thinBackend().
ModuleHookFn llvm::lto::Config::PostInternalizeModuleHook |
This hook is called after internalizing the module.
Definition at line 230 of file Config.h.
Referenced by addSaveTemps(), and llvm::lto::thinBackend().
ModuleHookFn llvm::lto::Config::PostOptModuleHook |
This module hook is called after optimization is complete.
Definition at line 236 of file Config.h.
Referenced by addSaveTemps(), and llvm::lto::opt().
ModuleHookFn llvm::lto::Config::PostPromoteModuleHook |
This hook is called after promoting any internal functions (ThinLTO-specific).
Definition at line 227 of file Config.h.
Referenced by addSaveTemps(), and llvm::lto::thinBackend().
ModuleHookFn llvm::lto::Config::PreCodeGenModuleHook |
This module hook is called before code generation.
It is similar to the PostOptModuleHook, but for parallel code generation it is called after splitting the module.
Definition at line 241 of file Config.h.
Referenced by addSaveTemps(), and codegen().
std::function<void(legacy::PassManager &)> llvm::lto::Config::PreCodeGenPassesHook |
ModuleHookFn llvm::lto::Config::PreOptModuleHook |
This module hook is called after linking (regular LTO) or loading (ThinLTO) the module, before modifying it.
Definition at line 223 of file Config.h.
Referenced by addSaveTemps(), and llvm::lto::thinBackend().
std::string llvm::lto::Config::ProfileRemapping |
Name remapping file for profile data.
Definition at line 122 of file Config.h.
Referenced by llvm::computeLTOCacheKey(), and runNewPMPasses().
PipelineTuningOptions llvm::lto::Config::PTO |
Tunable parameters for passes in the default pipelines.
Definition at line 193 of file Config.h.
Referenced by runNewPMPasses(), and llvm::LTOCodeGenerator::setOptLevel().
std::optional<Reloc::Model> llvm::lto::Config::RelocModel = Reloc::PIC_ |
Definition at line 55 of file Config.h.
Referenced by llvm::computeLTOCacheKey(), createTargetMachine(), and llvm::LTOCodeGenerator::setCodePICModel().
std::string llvm::lto::Config::RemarksFilename |
Optimization remarks file path.
Definition at line 139 of file Config.h.
Referenced by llvm::lto::thinBackend().
std::string llvm::lto::Config::RemarksFormat |
The format used for serializing remarks (default: YAML).
Definition at line 163 of file Config.h.
Referenced by llvm::lto::thinBackend().
std::optional<uint64_t> llvm::lto::Config::RemarksHotnessThreshold = 0 |
The minimum hotness value a diagnostic needs in order to be included in optimization diagnostics.
The threshold is an Optional value, which maps to one of the 3 states:
If threshold option is not specified, it is disabled by default.
Definition at line 160 of file Config.h.
Referenced by llvm::lto::thinBackend().
std::string llvm::lto::Config::RemarksPasses |
Optimization remarks pass filter.
Definition at line 142 of file Config.h.
Referenced by llvm::lto::thinBackend().
bool llvm::lto::Config::RemarksWithHotness = false |
Whether to emit optimization remarks with hotness informations.
Definition at line 145 of file Config.h.
Referenced by llvm::lto::thinBackend().
std::unique_ptr<raw_ostream> llvm::lto::Config::ResolutionFile |
If this field is set, LTO will write input file paths and symbol resolutions here in llvm-lto2 command line flag format.
This can be used for testing and for running the LTO pipeline outside of the linker with llvm-lto2.
Definition at line 190 of file Config.h.
Referenced by llvm::lto::LTO::add(), and addSaveTemps().
bool llvm::lto::Config::RunCSIRInstr = false |
Run PGO context sensitive IR instrumentation.
Definition at line 71 of file Config.h.
Referenced by llvm::LTOCodeGenerator::LTOCodeGenerator(), and runNewPMPasses().
std::string llvm::lto::Config::SampleProfile |
Sample PGO profile path.
Definition at line 119 of file Config.h.
Referenced by llvm::computeLTOCacheKey(), and runNewPMPasses().
Definition at line 180 of file Config.h.
Referenced by addSaveTemps().
std::string llvm::lto::Config::SplitDwarfFile |
The name for the split debug info file used for the DW_AT_[GNU_]dwo_name attribute in the skeleton CU.
This should generally only be used when running an individual backend directly via thinBackend(), as otherwise all objects would use the same .dwo file. Not used as output path.
Definition at line 131 of file Config.h.
Referenced by codegen().
std::string llvm::lto::Config::SplitDwarfOutput |
The path to write a .dwo file to.
This should generally only be used when running an individual backend directly via thinBackend(), as otherwise all .dwo files will be written to the same path. Not used in skeleton CU.
Definition at line 136 of file Config.h.
Referenced by codegen().
std::string llvm::lto::Config::StatsFile |
Statistics output file path.
Definition at line 169 of file Config.h.
Referenced by llvm::LTOCodeGenerator::LTOCodeGenerator(), and llvm::lto::LTO::run().
std::vector<std::string> llvm::lto::Config::ThinLTOModulesToCompile |
bool llvm::lto::Config::TimeTraceEnabled = false |
unsigned llvm::lto::Config::TimeTraceGranularity = 500 |
bool llvm::lto::Config::ValidateAllVtablesHaveTypeInfos = false |
bool llvm::lto::Config::VerifyEach = false |
Definition at line 60 of file Config.h.
Referenced by runNewPMPasses().
VisScheme llvm::lto::Config::VisibilityScheme = FromPrevailing |
Allows non-imported definitions to get the potentially more constraining visibility from the prevailing definition.
FromPrevailing is the default because it works for many binary formats. ELF can use the more optimized 'ELF' scheme.
Definition at line 95 of file Config.h.
Referenced by llvm::lto::LTO::add().