LLVM  8.0.1
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 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_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 170 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 136 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 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().

Member Data Documentation

◆ AAPipeline

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

Definition at line 67 of file Config.h.

Referenced by llvm::computeLTOCacheKey().

◆ CGFileType

Definition at line 45 of file Config.h.

Referenced by llvm::computeLTOCacheKey().

◆ CGOptLevel

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

Definition at line 44 of file Config.h.

Referenced by addSaveTemps(), and llvm::computeLTOCacheKey().

◆ CodeGenOnly

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

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().

◆ CodeModel

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

Definition at line 43 of file Config.h.

Referenced by addSaveTemps(), and llvm::computeLTOCacheKey().

◆ CombinedIndexHook

CombinedIndexHookFn llvm::lto::Config::CombinedIndexHook

Definition at line 171 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 llvm::computeLTOCacheKey().

◆ DebugPassManager

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

Whether to emit the pass manager debuggging informations.

Definition at line 98 of file Config.h.

◆ DefaultTriple

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().

◆ DiagHandler

DiagnosticHandlerFunction llvm::lto::Config::DiagHandler

Definition at line 104 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.

◆ DwoDir

std::string llvm::lto::Config::DwoDir

The directory to store .dwo files.

Definition at line 84 of file Config.h.

Referenced by llvm::computeLTOCacheKey().

◆ DwoPath

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.

Definition at line 89 of file Config.h.

◆ Freestanding

bool llvm::lto::Config::Freestanding = false

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().

◆ MAttrs

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

Definition at line 41 of file Config.h.

Referenced by addSaveTemps(), and llvm::computeLTOCacheKey().

◆ Options

TargetOptions llvm::lto::Config::Options

Definition at line 40 of file Config.h.

Referenced by addSaveTemps(), and llvm::computeLTOCacheKey().

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

Referenced by llvm::computeLTOCacheKey().

◆ OverrideTriple

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().

◆ PostImportModuleHook

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().

◆ PostInternalizeModuleHook

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().

◆ PostOptModuleHook

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().

◆ PostPromoteModuleHook

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().

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

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

◆ ProfileRemapping

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().

◆ RelocModel

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

Definition at line 42 of file Config.h.

Referenced by addSaveTemps(), and llvm::computeLTOCacheKey().

◆ RemarksFilename

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().

◆ RemarksWithHotness

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

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().

◆ 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 110 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 78 of file Config.h.

Referenced by addSaveTemps(), and llvm::computeLTOCacheKey().

◆ ShouldDiscardValueNames

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

Definition at line 103 of file Config.h.

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

◆ StatsFile

std::string llvm::lto::Config::StatsFile

Statistics output file path.

Definition at line 101 of file Config.h.

Referenced by llvm::lto::LTO::run().

◆ UseNewPM

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

Use the new pass manager.

Definition at line 50 of file Config.h.

Referenced by llvm::computeLTOCacheKey().


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