LLVM  6.0.0svn
Public Types | Public Member Functions | Public Attributes | List of all members
llvm::lto::Config Struct Reference

LTO configuration. More...

#include "llvm/LTO/Config.h"

Collaboration diagram for llvm::lto::Config:
Collaboration graph
[legend]

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::ModelRelocModel = Reloc::PIC_
 
Optional< CodeModel::ModelCodeModel = 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 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 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...
 
bool ShouldDiscardValueNames = true
 
DiagnosticHandlerFunction DiagHandler
 
std::unique_ptr< raw_ostreamResolutionFile
 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
 

Detailed Description

LTO configuration.

A linker can configure LTO by setting fields in this data structure and passing it to the lto::LTO constructor.

Definition at line 36 of file Config.h.

Member Typedef Documentation

◆ 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.

Definition at line 152 of file Config.h.

◆ 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.

Definition at line 118 of file Config.h.

Member Function Documentation

◆ addSaveTemps()

Error Config::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.

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 51 of file LTOBackend.cpp.

References AAPipeline, llvm::legacy::PassManager::add(), llvm::SubtargetFeatures::AddFeature(), llvm::PassManager< IRUnitT, AnalysisManagerT, ExtraArgTs >::addPass(), llvm::TargetMachine::addPassesToEmitFile(), llvm::ThreadPool::async(), llvm::PassBuilder::buildLTODefaultPipeline(), llvm::PassBuilder::buildThinLTODefaultPipeline(), C, CGFileType, CGOptLevel, codegen(), CodeModel, CombinedIndexHook, CPU, llvm::createFunctionInliningPass(), llvm::Target::createTargetMachine(), llvm::createTargetTransformInfoWrapperPass(), llvm::PassBuilder::crossRegisterProxies(), llvm::SmallVectorTemplateCommon< T >::data(), DebugPassManager, DefaultTriple, DisableVerify, llvm::errorCodeToError(), llvm::PassManagerBuilder::ExportSummary, llvm::sys::fs::F_None, llvm::sys::fs::F_Text, Features, llvm::Expected< T >::get(), llvm::SubtargetFeatures::getDefaultSubtargetFeatures(), llvm::Module::getPICLevel(), llvm::SubtargetFeatures::getString(), llvm::TargetMachine::getTarget(), llvm::TargetMachine::getTargetIRAnalysis(), llvm::TargetMachine::getTargetTriple(), llvm::Module::getTargetTriple(), llvm::PassManagerBuilder::ImportSummary, llvm::inconvertibleErrorCode(), llvm::PassManagerBuilder::Inliner, llvm::PassManagerBuilder::LibraryInfo, llvm_unreachable, llvm::TargetRegistry::lookupTarget(), llvm::PassManagerBuilder::LoopVectorize, MAttrs, llvm::Mod, llvm::PICLevel::NotPIC, llvm::PassBuilder::O0, llvm::PassBuilder::O1, llvm::PassBuilder::O2, llvm::PassBuilder::O3, opt, Options, OptLevel, llvm::PassManagerBuilder::OptLevel, OptPipeline, OverrideTriple, llvm::PassBuilder::parseAAPipeline(), llvm::parseBitcodeFile(), llvm::PassBuilder::parsePassPipeline(), llvm::PassManagerBuilder::PGOSampleUse, llvm::Reloc::PIC_, llvm::PassManagerBuilder::populateLTOPassManager(), llvm::PassManagerBuilder::populateThinLTOPassManager(), PostImportModuleHook, PostInternalizeModuleHook, PostOptModuleHook, PostPromoteModuleHook, PreCodeGenModuleHook, PreOptModuleHook, llvm::PassBuilder::registerCGSCCAnalyses(), llvm::PassBuilder::registerFunctionAnalyses(), llvm::PassBuilder::registerLoopAnalyses(), llvm::PassBuilder::registerModuleAnalyses(), llvm::AnalysisManager< IRUnitT, ExtraArgTs >::registerPass(), RelocModel, llvm::report_fatal_error(), reportOpenError(), ResolutionFile, llvm::legacy::PassManager::run(), llvm::PassManager< IRUnitT, AnalysisManagerT, ExtraArgTs >::run(), SampleProfile, llvm::Module::setTargetTriple(), ShouldDiscardValueNames, llvm::SmallVectorTemplateCommon< T >::size(), llvm::PassManagerBuilder::SLPVectorize, llvm::splitCodeGen(), llvm::SplitModule(), llvm::Reloc::Static, llvm::Error::success(), T, llvm::SystemZISD::TM, UseNewPM, llvm::utostr(), llvm::PassManagerBuilder::VerifyInput, llvm::PassManagerBuilder::VerifyOutput, llvm::ThreadPool::wait(), llvm::WriteBitcodeToFile(), and llvm::WriteIndexToFile().

Member Data Documentation

◆ AAPipeline

std::string llvm::lto::Config::AAPipeline

Definition at line 63 of file Config.h.

Referenced by addSaveTemps(), and computeCacheKey().

◆ CGFileType

Definition at line 45 of file Config.h.

Referenced by addSaveTemps(), and computeCacheKey().

◆ CGOptLevel

CodeGenOpt::Level llvm::lto::Config::CGOptLevel = CodeGenOpt::Default

Definition at line 44 of file Config.h.

Referenced by addSaveTemps(), and computeCacheKey().

◆ CodeGenOnly

bool llvm::lto::Config::CodeGenOnly = false

Disable entirely the optimizer, including importing for ThinLTO.

Definition at line 53 of file Config.h.

Referenced by llvm::lto::backend(), llvm::lto::LTO::run(), and llvm::lto::thinBackend().

◆ CodeModel

Optional<CodeModel::Model> llvm::lto::Config::CodeModel = None

Definition at line 43 of file Config.h.

Referenced by addSaveTemps(), and computeCacheKey().

◆ CombinedIndexHook

CombinedIndexHookFn llvm::lto::Config::CombinedIndexHook

Definition at line 153 of file Config.h.

Referenced by addSaveTemps(), and llvm::lto::createWriteIndexesThinBackend().

◆ CPU

std::string llvm::lto::Config::CPU

Definition at line 39 of file Config.h.

Referenced by addSaveTemps(), and computeCacheKey().

◆ DebugPassManager

bool llvm::lto::Config::DebugPassManager = false

Whether to emit the pass manager debuggging informations.

Definition at line 83 of file Config.h.

Referenced by addSaveTemps().

◆ DefaultTriple

std::string llvm::lto::Config::DefaultTriple

Setting this field will replace unspecified target triples in input files with this triple.

Definition at line 71 of file Config.h.

Referenced by addSaveTemps(), and computeCacheKey().

◆ DiagHandler

DiagnosticHandlerFunction llvm::lto::Config::DiagHandler

Definition at line 86 of file Config.h.

Referenced by llvm::lto::LTOLLVMContext::LTOLLVMContext().

◆ DisableVerify

bool llvm::lto::Config::DisableVerify = false

Definition at line 47 of file Config.h.

Referenced by addSaveTemps().

◆ MAttrs

std::vector<std::string> llvm::lto::Config::MAttrs

Definition at line 41 of file Config.h.

Referenced by addSaveTemps(), and computeCacheKey().

◆ Options

TargetOptions llvm::lto::Config::Options

Definition at line 40 of file Config.h.

Referenced by addSaveTemps(), and computeCacheKey().

◆ OptLevel

unsigned llvm::lto::Config::OptLevel = 2

◆ OptPipeline

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 58 of file Config.h.

Referenced by addSaveTemps(), and computeCacheKey().

◆ OverrideTriple

std::string llvm::lto::Config::OverrideTriple

Setting this field will replace target triples in input files with this triple.

Definition at line 67 of file Config.h.

Referenced by addSaveTemps(), and computeCacheKey().

◆ PostImportModuleHook

ModuleHookFn llvm::lto::Config::PostImportModuleHook

This hook is called after importing from other modules (ThinLTO-specific).

Definition at line 132 of file Config.h.

Referenced by addSaveTemps(), and llvm::lto::thinBackend().

◆ PostInternalizeModuleHook

ModuleHookFn llvm::lto::Config::PostInternalizeModuleHook

This hook is called after internalizing the module.

Definition at line 129 of file Config.h.

Referenced by addSaveTemps(), llvm::lto::LTO::run(), and llvm::lto::thinBackend().

◆ PostOptModuleHook

ModuleHookFn llvm::lto::Config::PostOptModuleHook

This module hook is called after optimization is complete.

Definition at line 135 of file Config.h.

Referenced by addSaveTemps().

◆ PostPromoteModuleHook

ModuleHookFn llvm::lto::Config::PostPromoteModuleHook

This hook is called after promoting any internal functions (ThinLTO-specific).

Definition at line 126 of file Config.h.

Referenced by addSaveTemps(), and llvm::lto::thinBackend().

◆ PreCodeGenModuleHook

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 140 of file Config.h.

Referenced by addSaveTemps().

◆ PreOptModuleHook

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 122 of file Config.h.

Referenced by addSaveTemps(), llvm::lto::LTO::run(), and llvm::lto::thinBackend().

◆ RelocModel

Optional<Reloc::Model> llvm::lto::Config::RelocModel = Reloc::PIC_

Definition at line 42 of file Config.h.

Referenced by addSaveTemps(), and computeCacheKey().

◆ RemarksFilename

std::string llvm::lto::Config::RemarksFilename = ""

Optimization remarks file path.

Definition at line 77 of file Config.h.

Referenced by llvm::lto::backend().

◆ RemarksWithHotness

bool llvm::lto::Config::RemarksWithHotness = false

Whether to emit optimization remarks with hotness informations.

Definition at line 80 of file Config.h.

Referenced by llvm::lto::backend().

◆ ResolutionFile

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 92 of file Config.h.

Referenced by llvm::lto::LTO::add(), and addSaveTemps().

◆ SampleProfile

std::string llvm::lto::Config::SampleProfile

Sample PGO profile path.

Definition at line 74 of file Config.h.

Referenced by addSaveTemps(), and computeCacheKey().

◆ ShouldDiscardValueNames

bool llvm::lto::Config::ShouldDiscardValueNames = true

Definition at line 85 of file Config.h.

Referenced by addSaveTemps(), and llvm::lto::LTOLLVMContext::LTOLLVMContext().

◆ UseNewPM

bool llvm::lto::Config::UseNewPM = false

Use the new pass manager.

Definition at line 50 of file Config.h.

Referenced by addSaveTemps(), and computeCacheKey().


The documentation for this struct was generated from the following files: