LLVM  14.0.0git
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

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. More...
 
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). 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
 
std::vector< std::string > PassPlugins
 
std::function< void(legacy::PassManager &)> PreCodeGenPassesHook
 For adding passes that run right before codegen. More...
 
Optional< Reloc::ModelRelocModel = Reloc::PIC_
 
Optional< CodeModel::ModelCodeModel = None
 
CodeGenOpt::Level CGOptLevel = CodeGenOpt::Default
 
CodeGenFileType CGFileType = CGFT_ObjectFile
 
unsigned OptLevel = 2
 
bool DisableVerify = false
 
bool UseNewPM = LLVM_ENABLE_NEW_PASS_MANAGER
 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...
 
bool RunCSIRInstr = false
 Run PGO context sensitive IR instrumentation. More...
 
bool PGOWarnMismatch = true
 Turn on/off the warning about a hash mismatch in the PGO profile data. More...
 
bool HasWholeProgramVisibility = false
 Asserts whether we can assume whole program visibility during the LTO link. More...
 
bool AlwaysEmitRegularLTOObj = false
 Always emit a Regular LTO object even when it is empty because no Regular LTO modules were linked. More...
 
VisScheme VisibilityScheme = FromPrevailing
 Allows non-imported definitions to get the potentially more constraining visibility from the prevailing definition. 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 CSIRProfile
 Context Sensitive PGO profile path. 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 SplitDwarfFile
 The name for the split debug info file used for the DW_AT_[GNU_]dwo_name attribute in the skeleton CU. More...
 
std::string SplitDwarfOutput
 The path to write a .dwo file to. More...
 
std::string RemarksFilename
 Optimization remarks file path. More...
 
std::string RemarksPasses
 Optimization remarks pass filter. More...
 
bool RemarksWithHotness = false
 Whether to emit optimization remarks with hotness informations. More...
 
llvm::Optional< uint64_tRemarksHotnessThreshold = 0
 The minimum hotness value a diagnostic needs in order to be included in optimization diagnostics. More...
 
std::string RemarksFormat
 The format used for serializing remarks (default: YAML). More...
 
bool DebugPassManager = false
 Whether to emit the pass manager debuggging informations. More...
 
std::string StatsFile
 Statistics output file path. More...
 
std::vector< std::string > ThinLTOModulesToCompile
 Specific thinLTO modules to compile. More...
 
bool TimeTraceEnabled = false
 Time trace enabled. More...
 
unsigned TimeTraceGranularity = 500
 Time trace granularity. More...
 
bool ShouldDiscardValueNames = true
 
DiagnosticHandlerFunction DiagHandler
 
bool AddFSDiscriminator = false
 Add FSAFDO discriminators. More...
 
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...
 
PipelineTuningOptions PTO
 Tunable parameters for passes in the default pipelines. 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 40 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 248 of file Config.h.

◆ ModuleHookFn

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.

Definition at line 213 of file Config.h.

Member Enumeration Documentation

◆ VisScheme

Enumerator
FromPrevailing 
ELF 

Definition at line 41 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 87 of file LTOBackend.cpp.

References CombinedIndexHook, llvm::errorCodeToError(), Index, M, llvm::sys::fs::OF_None, llvm::sys::fs::OF_TextWithCRLF, PostImportModuleHook, PostInternalizeModuleHook, PostOptModuleHook, PostPromoteModuleHook, PreCodeGenModuleHook, PreOptModuleHook, reportOpenError(), ResolutionFile, ShouldDiscardValueNames, llvm::Error::success(), llvm::WriteBitcodeToFile(), and llvm::WriteIndexToFile().

Member Data Documentation

◆ AAPipeline

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

Definition at line 99 of file Config.h.

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

◆ AddFSDiscriminator

bool llvm::lto::Config::AddFSDiscriminator = false

Add FSAFDO discriminators.

Definition at line 178 of file Config.h.

Referenced by runNewPMPasses().

◆ AlwaysEmitRegularLTOObj

bool llvm::lto::Config::AlwaysEmitRegularLTOObj = false

Always emit a Regular LTO object even when it is empty because no Regular LTO modules were linked.

This option is useful for some build system which want to know a priori all possible output files.

Definition at line 83 of file Config.h.

◆ CGFileType

CodeGenFileType llvm::lto::Config::CGFileType = CGFT_ObjectFile

Definition at line 56 of file Config.h.

Referenced by llvm::computeLTOCacheKey(), and llvm::LTOCodeGenerator::setFileType().

◆ CGOptLevel

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

◆ CodeGenOnly

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

◆ CodeModel

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

◆ CombinedIndexHook

CombinedIndexHookFn llvm::lto::Config::CombinedIndexHook

Definition at line 249 of file Config.h.

Referenced by addSaveTemps().

◆ CPU

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

◆ CSIRProfile

std::string llvm::lto::Config::CSIRProfile

Context Sensitive PGO profile path.

Definition at line 110 of file Config.h.

Referenced by runNewPMPasses(), and runOldPMPasses().

◆ DebugPassManager

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

Whether to emit the pass manager debuggging informations.

Definition at line 160 of file Config.h.

Referenced by runNewPMPasses().

◆ DefaultTriple

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

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

Definition at line 107 of file Config.h.

Referenced by llvm::computeLTOCacheKey().

◆ DiagHandler

DiagnosticHandlerFunction llvm::lto::Config::DiagHandler

Definition at line 175 of file Config.h.

◆ DisableVerify

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

Definition at line 58 of file Config.h.

Referenced by runOldPMPasses(), and llvm::LTOCodeGenerator::setDisableVerify().

◆ DwoDir

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

The directory to store .dwo files.

Definition at line 119 of file Config.h.

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

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

Referenced by llvm::computeLTOCacheKey(), runNewPMPasses(), runOldPMPasses(), and llvm::LTOCodeGenerator::setFreestanding().

◆ HasWholeProgramVisibility

bool llvm::lto::Config::HasWholeProgramVisibility = false

Asserts whether we can assume whole program visibility during the LTO link.

Definition at line 78 of file Config.h.

◆ MAttrs

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

◆ Options

TargetOptions llvm::lto::Config::Options

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

Referenced by llvm::computeLTOCacheKey(), and llvm::lto::opt().

◆ OverrideTriple

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

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

Definition at line 103 of file Config.h.

Referenced by llvm::computeLTOCacheKey().

◆ PassPlugins

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

Definition at line 50 of file Config.h.

Referenced by runNewPMPasses().

◆ PGOWarnMismatch

bool llvm::lto::Config::PGOWarnMismatch = true

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

◆ PostImportModuleHook

ModuleHookFn llvm::lto::Config::PostImportModuleHook

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

Definition at line 227 of file Config.h.

Referenced by addSaveTemps().

◆ PostInternalizeModuleHook

ModuleHookFn llvm::lto::Config::PostInternalizeModuleHook

This hook is called after internalizing the module.

Definition at line 224 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 230 of file Config.h.

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

◆ PostPromoteModuleHook

ModuleHookFn llvm::lto::Config::PostPromoteModuleHook

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

Definition at line 221 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 235 of file Config.h.

Referenced by addSaveTemps(), and codegen().

◆ PreCodeGenPassesHook

std::function<void(legacy::PassManager &)> llvm::lto::Config::PreCodeGenPassesHook

For adding passes that run right before codegen.

Definition at line 52 of file Config.h.

Referenced by llvm::LTOCodeGenerator::LTOCodeGenerator().

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

Referenced by runNewPMPasses().

◆ PTO

PipelineTuningOptions llvm::lto::Config::PTO

Tunable parameters for passes in the default pipelines.

Definition at line 187 of file Config.h.

Referenced by runNewPMPasses(), and llvm::LTOCodeGenerator::setOptLevel().

◆ RelocModel

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

◆ RemarksFilename

std::string llvm::lto::Config::RemarksFilename

Optimization remarks file path.

Definition at line 133 of file Config.h.

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

◆ RemarksFormat

std::string llvm::lto::Config::RemarksFormat

The format used for serializing remarks (default: YAML).

Definition at line 157 of file Config.h.

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

◆ RemarksHotnessThreshold

llvm::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:

  1. 0 => threshold disabled. All emarks will be printed.
  2. positive int => manual threshold by user. Remarks with hotness exceed threshold will be printed.
  3. None => 'auto' threshold by user. The actual value is not available at command line, but will be synced with hotness threhold from profile summary during compilation.

If threshold option is not specified, it is disabled by default.

Definition at line 154 of file Config.h.

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

◆ RemarksPasses

std::string llvm::lto::Config::RemarksPasses

Optimization remarks pass filter.

Definition at line 136 of file Config.h.

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

◆ RemarksWithHotness

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

Whether to emit optimization remarks with hotness informations.

Definition at line 139 of file Config.h.

Referenced by 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 184 of file Config.h.

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

◆ RunCSIRInstr

bool llvm::lto::Config::RunCSIRInstr = false

Run PGO context sensitive IR instrumentation.

Definition at line 71 of file Config.h.

Referenced by runNewPMPasses(), and runOldPMPasses().

◆ SampleProfile

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

Sample PGO profile path.

Definition at line 113 of file Config.h.

Referenced by runNewPMPasses(), and runOldPMPasses().

◆ ShouldDiscardValueNames

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

Definition at line 174 of file Config.h.

Referenced by addSaveTemps().

◆ SplitDwarfFile

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

Referenced by codegen().

◆ SplitDwarfOutput

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

Referenced by codegen().

◆ StatsFile

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

Statistics output file path.

Definition at line 163 of file Config.h.

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

◆ ThinLTOModulesToCompile

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

Specific thinLTO modules to compile.

Definition at line 166 of file Config.h.

◆ TimeTraceEnabled

bool llvm::lto::Config::TimeTraceEnabled = false

Time trace enabled.

Definition at line 169 of file Config.h.

◆ TimeTraceGranularity

unsigned llvm::lto::Config::TimeTraceGranularity = 500

Time trace granularity.

Definition at line 172 of file Config.h.

◆ UseNewPM

bool llvm::lto::Config::UseNewPM = LLVM_ENABLE_NEW_PASS_MANAGER

Use the new pass manager.

Definition at line 61 of file Config.h.

Referenced by llvm::computeLTOCacheKey(), llvm::lto::opt(), and llvm::LTOCodeGenerator::setUseNewPM().

◆ VisibilityScheme

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

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


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