LLVM 20.0.0git
Namespaces | Macros | Enumerations | Functions | Variables
LTOBackend.cpp File Reference
#include "llvm/LTO/LTOBackend.h"
#include "llvm/Analysis/AliasAnalysis.h"
#include "llvm/Analysis/CGSCCPassManager.h"
#include "llvm/Analysis/ModuleSummaryAnalysis.h"
#include "llvm/Analysis/TargetLibraryInfo.h"
#include "llvm/Bitcode/BitcodeReader.h"
#include "llvm/Bitcode/BitcodeWriter.h"
#include "llvm/IR/LLVMRemarkStreamer.h"
#include "llvm/IR/LegacyPassManager.h"
#include "llvm/IR/PassManager.h"
#include "llvm/IR/Verifier.h"
#include "llvm/LTO/LTO.h"
#include "llvm/MC/TargetRegistry.h"
#include "llvm/Object/ModuleSymbolTable.h"
#include "llvm/Passes/PassBuilder.h"
#include "llvm/Passes/PassPlugin.h"
#include "llvm/Passes/StandardInstrumentations.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/Program.h"
#include "llvm/Support/ThreadPool.h"
#include "llvm/Support/ToolOutputFile.h"
#include "llvm/Support/VirtualFileSystem.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Target/TargetMachine.h"
#include "llvm/TargetParser/SubtargetFeature.h"
#include "llvm/Transforms/IPO/WholeProgramDevirt.h"
#include "llvm/Transforms/Scalar/LoopPassManager.h"
#include "llvm/Transforms/Utils/FunctionImportUtils.h"
#include "llvm/Transforms/Utils/SplitModule.h"
#include <optional>
#include "llvm/Support/Extension.def"

Go to the source code of this file.

Namespaces

namespace  llvm
 This is an optimization pass for GlobalISel generic memory operations.
 

Macros

#define DEBUG_TYPE   "lto-backend"
 
#define HANDLE_EXTENSION(Ext)    llvm::PassPluginLibraryInfo get##Ext##PluginInfo();
 
#define HANDLE_EXTENSION(Ext)    get##Ext##PluginInfo().RegisterPassBuilderCallbacks(PB);
 

Enumerations

enum class  LTOBitcodeEmbedding { DoNotEmbed = 0 , EmbedOptimized = 1 , EmbedPostMergePreOptimized = 2 }
 

Functions

static void reportOpenError (StringRef Path, Twine Msg)
 
static void RegisterPassPlugins (ArrayRef< std::string > PassPlugins, PassBuilder &PB)
 
static std::unique_ptr< TargetMachinecreateTargetMachine (const Config &Conf, const Target *TheTarget, Module &M)
 
static void runNewPMPasses (const Config &Conf, Module &Mod, TargetMachine *TM, unsigned OptLevel, bool IsThinLTO, ModuleSummaryIndex *ExportSummary, const ModuleSummaryIndex *ImportSummary)
 
static void codegen (const Config &Conf, TargetMachine *TM, AddStreamFn AddStream, unsigned Task, Module &Mod, const ModuleSummaryIndex &CombinedIndex)
 
static void splitCodeGen (const Config &C, TargetMachine *TM, AddStreamFn AddStream, unsigned ParallelCodeGenParallelismLevel, Module &Mod, const ModuleSummaryIndex &CombinedIndex)
 
static Expected< const Target * > initAndLookupTarget (const Config &C, Module &Mod)
 
static void dropDeadSymbols (Module &Mod, const GVSummaryMapTy &DefinedGlobals, const ModuleSummaryIndex &Index)
 

Variables

static cl::opt< LTOBitcodeEmbeddingEmbedBitcode ("lto-embed-bitcode", cl::init(LTOBitcodeEmbedding::DoNotEmbed), cl::values(clEnumValN(LTOBitcodeEmbedding::DoNotEmbed, "none", "Do not embed"), clEnumValN(LTOBitcodeEmbedding::EmbedOptimized, "optimized", "Embed after all optimization passes"), clEnumValN(LTOBitcodeEmbedding::EmbedPostMergePreOptimized, "post-merge-pre-opt", "Embed post merge, but before optimizations")), cl::desc("Embed LLVM bitcode in object files produced by LTO"))
 
static cl::opt< boolThinLTOAssumeMerged ("thinlto-assume-merged", cl::init(false), cl::desc("Assume the input has already undergone ThinLTO function " "importing and the other pre-optimization pipeline changes."))
 
cl::opt< boolllvm::NoPGOWarnMismatch
 

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "lto-backend"

Definition at line 53 of file LTOBackend.cpp.

◆ HANDLE_EXTENSION [1/2]

#define HANDLE_EXTENSION (   Ext)     llvm::PassPluginLibraryInfo get##Ext##PluginInfo();

Definition at line 181 of file LTOBackend.cpp.

◆ HANDLE_EXTENSION [2/2]

#define HANDLE_EXTENSION (   Ext)     get##Ext##PluginInfo().RegisterPassBuilderCallbacks(PB);

Definition at line 181 of file LTOBackend.cpp.

Enumeration Type Documentation

◆ LTOBitcodeEmbedding

enum class LTOBitcodeEmbedding
strong
Enumerator
DoNotEmbed 
EmbedOptimized 
EmbedPostMergePreOptimized 

Definition at line 55 of file LTOBackend.cpp.

Function Documentation

◆ codegen()

static void codegen ( const Config Conf,
TargetMachine TM,
AddStreamFn  AddStream,
unsigned  Task,
Module Mod,
const ModuleSummaryIndex CombinedIndex 
)
static

◆ createTargetMachine()

static std::unique_ptr< TargetMachine > createTargetMachine ( const Config Conf,
const Target TheTarget,
Module M 
)
static

◆ dropDeadSymbols()

static void dropDeadSymbols ( Module Mod,
const GVSummaryMapTy DefinedGlobals,
const ModuleSummaryIndex Index 
)
static

◆ initAndLookupTarget()

static Expected< const Target * > initAndLookupTarget ( const Config C,
Module Mod 
)
static

◆ RegisterPassPlugins()

static void RegisterPassPlugins ( ArrayRef< std::string >  PassPlugins,
PassBuilder PB 
)
static

◆ reportOpenError()

static void reportOpenError ( StringRef  Path,
Twine  Msg 
)
static

Definition at line 81 of file LTOBackend.cpp.

References llvm::errs(), and llvm::raw_ostream::flush().

Referenced by llvm::lto::Config::addSaveTemps().

◆ runNewPMPasses()

static void runNewPMPasses ( const Config Conf,
Module Mod,
TargetMachine TM,
unsigned  OptLevel,
bool  IsThinLTO,
ModuleSummaryIndex ExportSummary,
const ModuleSummaryIndex ImportSummary 
)
static

Definition at line 233 of file LTOBackend.cpp.

References llvm::lto::Config::AAPipeline, llvm::lto::Config::AddFSDiscriminator, llvm::PassManager< IRUnitT, AnalysisManagerT, ExtraArgTs >::addPass(), llvm::PassBuilder::buildLTODefaultPipeline(), llvm::PassBuilder::buildThinLTODefaultPipeline(), CGAM, llvm::PassBuilder::crossRegisterProxies(), llvm::PGOOptions::CSIRInstr, llvm::lto::Config::CSIRProfile, llvm::PGOOptions::CSIRUse, llvm::lto::Config::DebugPassManager, llvm::PGOOptions::Default, llvm::lto::Config::DisableVerify, FAM, llvm::lto::Config::Freestanding, llvm::PassInstrumentationCallbacks::getPassNameForClassName(), llvm::vfs::getRealFileSystem(), llvm::PGOOptions::IRUse, LAM, llvm_unreachable, MAM, llvm::Mod, MPM, llvm::PGOOptions::NoAction, llvm::PGOOptions::NoCSAction, llvm::NoPGOWarnMismatch, llvm::OptimizationLevel::O0, llvm::OptimizationLevel::O1, llvm::OptimizationLevel::O2, llvm::OptimizationLevel::O3, llvm::lto::Config::OptPipeline, OS, llvm::outs(), llvm::PassBuilder::parseAAPipeline(), llvm::PassBuilder::parsePassPipeline(), PassName, llvm::lto::Config::PassPlugins, PB(), llvm::lto::Config::PGOWarnMismatch, PIC, llvm::PassManager< IRUnitT, AnalysisManagerT, ExtraArgTs >::printPipeline(), llvm::PrintPipelinePasses, llvm::lto::Config::ProfileRemapping, llvm::lto::Config::PTO, llvm::PassBuilder::registerCGSCCAnalyses(), llvm::PassBuilder::registerFunctionAnalyses(), llvm::PassBuilder::registerLoopAnalyses(), llvm::PassBuilder::registerModuleAnalyses(), llvm::AnalysisManager< IRUnitT, ExtraArgTs >::registerPass(), RegisterPassPlugins(), llvm::report_fatal_error(), llvm::PassManager< IRUnitT, AnalysisManagerT, ExtraArgTs >::run(), llvm::lto::Config::RunCSIRInstr, llvm::lto::Config::SampleProfile, llvm::PGOOptions::SampleUse, TM, llvm::dwarf::toString(), and llvm::lto::Config::VerifyEach.

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

◆ splitCodeGen()

static void splitCodeGen ( const Config C,
TargetMachine TM,
AddStreamFn  AddStream,
unsigned  ParallelCodeGenParallelismLevel,
Module Mod,
const ModuleSummaryIndex CombinedIndex 
)
static

Variable Documentation

◆ EmbedBitcode

cl::opt< LTOBitcodeEmbedding > EmbedBitcode("lto-embed-bitcode", cl::init(LTOBitcodeEmbedding::DoNotEmbed), cl::values(clEnumValN(LTOBitcodeEmbedding::DoNotEmbed, "none", "Do not embed"), clEnumValN(LTOBitcodeEmbedding::EmbedOptimized, "optimized", "Embed after all optimization passes"), clEnumValN(LTOBitcodeEmbedding::EmbedPostMergePreOptimized, "post-merge-pre-opt", "Embed post merge, but before optimizations")), cl::desc("Embed LLVM bitcode in object files produced by LTO")) ( "lto-embed-bitcode"  ,
cl::init(LTOBitcodeEmbedding::DoNotEmbed ,
cl::values(clEnumValN(LTOBitcodeEmbedding::DoNotEmbed, "none", "Do not embed"), clEnumValN(LTOBitcodeEmbedding::EmbedOptimized, "optimized", "Embed after all optimization passes"), clEnumValN(LTOBitcodeEmbedding::EmbedPostMergePreOptimized, "post-merge-pre-opt", "Embed post merge, but before optimizations"))  ,
cl::desc("Embed LLVM bitcode in object files produced by LTO")   
)
static

◆ ThinLTOAssumeMerged

cl::opt< bool > ThinLTOAssumeMerged("thinlto-assume-merged", cl::init(false), cl::desc("Assume the input has already undergone ThinLTO function " "importing and the other pre-optimization pipeline changes.")) ( "thinlto-assume-merged"  ,
cl::init(false)  ,
cl::desc("Assume the input has already undergone ThinLTO function " "importing and the other pre-optimization pipeline changes.")   
)
static