LLVM
8.0.1
|
#include "llvm/LTO/Config.h"
Public Types | |
typedef std::function< bool(unsigned Task, const Module &)> | ModuleHookFn |
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. More... | |
typedef std::function< bool(const ModuleSummaryIndex &Index)> | CombinedIndexHookFn |
A combined index hook is called after all per-module indexes have been combined (ThinLTO-specific). More... | |
Public Member Functions | |
Error | addSaveTemps (std::string OutputFileName, bool UseInputModulePath=false) |
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. More... | |
Public Attributes | |
std::string | CPU |
TargetOptions | Options |
std::vector< std::string > | MAttrs |
Optional< Reloc::Model > | RelocModel = Reloc::PIC_ |
Optional< CodeModel::Model > | CodeModel = None |
CodeGenOpt::Level | CGOptLevel = CodeGenOpt::Default |
TargetMachine::CodeGenFileType | CGFileType = TargetMachine::CGFT_ObjectFile |
unsigned | OptLevel = 2 |
bool | DisableVerify = false |
bool | UseNewPM = false |
Use the new pass manager. More... | |
bool | Freestanding = false |
Flag to indicate that the optimizer should not assume builtins are present on the target. More... | |
bool | CodeGenOnly = false |
Disable entirely the optimizer, including importing for ThinLTO. More... | |
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. More... | |
std::string | AAPipeline |
std::string | OverrideTriple |
Setting this field will replace target triples in input files with this triple. More... | |
std::string | DefaultTriple |
Setting this field will replace unspecified target triples in input files with this triple. More... | |
std::string | SampleProfile |
Sample PGO profile path. More... | |
std::string | ProfileRemapping |
Name remapping file for profile data. More... | |
std::string | DwoDir |
The directory to store .dwo files. More... | |
std::string | DwoPath |
The path to write a .dwo file to. More... | |
std::string | RemarksFilename = "" |
Optimization remarks file path. More... | |
bool | RemarksWithHotness = false |
Whether to emit optimization remarks with hotness informations. More... | |
bool | DebugPassManager = false |
Whether to emit the pass manager debuggging informations. More... | |
std::string | StatsFile |
Statistics output file path. More... | |
bool | ShouldDiscardValueNames = true |
DiagnosticHandlerFunction | DiagHandler |
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. More... | |
ModuleHookFn | PreOptModuleHook |
This module hook is called after linking (regular LTO) or loading (ThinLTO) the module, before modifying it. More... | |
ModuleHookFn | PostPromoteModuleHook |
This hook is called after promoting any internal functions (ThinLTO-specific). More... | |
ModuleHookFn | PostInternalizeModuleHook |
This hook is called after internalizing the module. More... | |
ModuleHookFn | PostImportModuleHook |
This hook is called after importing from other modules (ThinLTO-specific). More... | |
ModuleHookFn | PostOptModuleHook |
This module hook is called after optimization is complete. More... | |
ModuleHookFn | PreCodeGenModuleHook |
This module hook is called before code generation. More... | |
CombinedIndexHookFn | CombinedIndexHook |
LTO configuration.
A linker can configure LTO by setting fields in this data structure and passing it to the lto::LTO constructor.
typedef std::function<bool(const ModuleSummaryIndex &Index)> llvm::lto::Config::CombinedIndexHookFn |
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.
typedef std::function<bool(unsigned Task, const Module &)> llvm::lto::Config::ModuleHookFn |
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.
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.
Definition at line 55 of file LTOBackend.cpp.
References llvm::SubtargetFeatures::AddFeature(), CGOptLevel, CodeModel, CombinedIndexHook, CPU, llvm::Target::createTargetMachine(), llvm::errorCodeToError(), llvm::sys::fs::F_None, llvm::sys::fs::F_Text, Features, llvm::Module::getCodeModel(), llvm::SubtargetFeatures::getDefaultSubtargetFeatures(), llvm::Module::getPICLevel(), llvm::SubtargetFeatures::getString(), llvm::Module::getTargetTriple(), MAttrs, llvm::Mod, llvm::PICLevel::NotPIC, Options, OptLevel, llvm::Reloc::PIC_, PostImportModuleHook, PostInternalizeModuleHook, PostOptModuleHook, PostPromoteModuleHook, PreCodeGenModuleHook, PreOptModuleHook, ProfileRemapping, RelocModel, reportOpenError(), ResolutionFile, SampleProfile, ShouldDiscardValueNames, llvm::Reloc::Static, llvm::Error::success(), llvm::SystemZISD::TM, llvm::utostr(), llvm::WriteBitcodeToFile(), and llvm::WriteIndexToFile().
std::string llvm::lto::Config::AAPipeline |
Definition at line 67 of file Config.h.
Referenced by llvm::computeLTOCacheKey().
TargetMachine::CodeGenFileType llvm::lto::Config::CGFileType = TargetMachine::CGFT_ObjectFile |
Definition at line 45 of file Config.h.
Referenced by llvm::computeLTOCacheKey().
CodeGenOpt::Level llvm::lto::Config::CGOptLevel = CodeGenOpt::Default |
Definition at line 44 of file Config.h.
Referenced by addSaveTemps(), and llvm::computeLTOCacheKey().
Disable entirely the optimizer, including importing for ThinLTO.
Definition at line 57 of file Config.h.
Referenced by llvm::lto::backend(), and llvm::lto::thinBackend().
Optional<CodeModel::Model> llvm::lto::Config::CodeModel = None |
Definition at line 43 of file Config.h.
Referenced by addSaveTemps(), and llvm::computeLTOCacheKey().
CombinedIndexHookFn llvm::lto::Config::CombinedIndexHook |
Definition at line 171 of file Config.h.
Referenced by addSaveTemps(), and llvm::lto::createWriteIndexesThinBackend().
std::string llvm::lto::Config::CPU |
Definition at line 39 of file Config.h.
Referenced by addSaveTemps(), and llvm::computeLTOCacheKey().
std::string llvm::lto::Config::DefaultTriple |
Setting this field will replace unspecified target triples in input files with this triple.
Definition at line 75 of file Config.h.
Referenced by llvm::computeLTOCacheKey().
DiagnosticHandlerFunction llvm::lto::Config::DiagHandler |
Definition at line 104 of file Config.h.
Referenced by llvm::lto::LTOLLVMContext::LTOLLVMContext().
std::string llvm::lto::Config::DwoDir |
The directory to store .dwo files.
Definition at line 84 of file Config.h.
Referenced by llvm::computeLTOCacheKey().
std::string llvm::lto::Config::DwoPath |
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.
Flag to indicate that the optimizer should not assume builtins are present on the target.
Definition at line 54 of file Config.h.
Referenced by llvm::computeLTOCacheKey().
std::vector<std::string> llvm::lto::Config::MAttrs |
Definition at line 41 of file Config.h.
Referenced by addSaveTemps(), and llvm::computeLTOCacheKey().
TargetOptions llvm::lto::Config::Options |
Definition at line 40 of file Config.h.
Referenced by addSaveTemps(), and llvm::computeLTOCacheKey().
unsigned llvm::lto::Config::OptLevel = 2 |
Definition at line 46 of file Config.h.
Referenced by addSaveTemps(), llvm::computeLTOCacheKey(), llvm::lto::createWriteIndexesThinBackend(), and llvm::lto::LTO::run().
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 62 of file Config.h.
Referenced by llvm::computeLTOCacheKey().
std::string llvm::lto::Config::OverrideTriple |
Setting this field will replace target triples in input files with this triple.
Definition at line 71 of file Config.h.
Referenced by llvm::computeLTOCacheKey().
ModuleHookFn llvm::lto::Config::PostImportModuleHook |
This hook is called after importing from other modules (ThinLTO-specific).
Definition at line 150 of file Config.h.
Referenced by addSaveTemps().
ModuleHookFn llvm::lto::Config::PostInternalizeModuleHook |
This hook is called after internalizing the module.
Definition at line 147 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 153 of file Config.h.
Referenced by addSaveTemps().
ModuleHookFn llvm::lto::Config::PostPromoteModuleHook |
This hook is called after promoting any internal functions (ThinLTO-specific).
Definition at line 144 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 158 of file Config.h.
Referenced by addSaveTemps().
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 140 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 81 of file Config.h.
Referenced by addSaveTemps(), and llvm::computeLTOCacheKey().
Optional<Reloc::Model> llvm::lto::Config::RelocModel = Reloc::PIC_ |
Definition at line 42 of file Config.h.
Referenced by addSaveTemps(), and llvm::computeLTOCacheKey().
std::string llvm::lto::Config::RemarksFilename = "" |
Optimization remarks file path.
Definition at line 92 of file Config.h.
Referenced by llvm::lto::backend(), and llvm::lto::thinBackend().
Whether to emit optimization remarks with hotness informations.
Definition at line 95 of file Config.h.
Referenced by llvm::lto::backend(), and 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 110 of file Config.h.
Referenced by llvm::lto::LTO::add(), and addSaveTemps().
std::string llvm::lto::Config::SampleProfile |
Sample PGO profile path.
Definition at line 78 of file Config.h.
Referenced by addSaveTemps(), and llvm::computeLTOCacheKey().
Definition at line 103 of file Config.h.
Referenced by addSaveTemps(), and llvm::lto::LTOLLVMContext::LTOLLVMContext().
std::string llvm::lto::Config::StatsFile |
Statistics output file path.
Definition at line 101 of file Config.h.
Referenced by llvm::lto::LTO::run().
Use the new pass manager.
Definition at line 50 of file Config.h.
Referenced by llvm::computeLTOCacheKey().