LLVM 20.0.0git
Namespaces | Macros | Functions | Variables
ThinLTOCodeGenerator.cpp File Reference
#include "llvm/LTO/legacy/ThinLTOCodeGenerator.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/ADT/ScopeExit.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/Analysis/AliasAnalysis.h"
#include "llvm/Analysis/ModuleSummaryAnalysis.h"
#include "llvm/Analysis/ProfileSummaryInfo.h"
#include "llvm/Analysis/TargetLibraryInfo.h"
#include "llvm/Bitcode/BitcodeReader.h"
#include "llvm/Bitcode/BitcodeWriter.h"
#include "llvm/Bitcode/BitcodeWriterPass.h"
#include "llvm/Config/llvm-config.h"
#include "llvm/IR/DebugInfo.h"
#include "llvm/IR/DiagnosticPrinter.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/LLVMRemarkStreamer.h"
#include "llvm/IR/LegacyPassManager.h"
#include "llvm/IR/Mangler.h"
#include "llvm/IR/PassTimingInfo.h"
#include "llvm/IR/Verifier.h"
#include "llvm/IRReader/IRReader.h"
#include "llvm/LTO/LTO.h"
#include "llvm/MC/TargetRegistry.h"
#include "llvm/Object/IRObjectFile.h"
#include "llvm/Passes/PassBuilder.h"
#include "llvm/Passes/StandardInstrumentations.h"
#include "llvm/Remarks/HotnessThresholdParser.h"
#include "llvm/Support/CachePruning.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/FormatVariadic.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/SHA1.h"
#include "llvm/Support/SmallVectorMemoryBuffer.h"
#include "llvm/Support/ThreadPool.h"
#include "llvm/Support/Threading.h"
#include "llvm/Support/ToolOutputFile.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Target/TargetMachine.h"
#include "llvm/TargetParser/SubtargetFeature.h"
#include "llvm/Transforms/IPO/FunctionAttrs.h"
#include "llvm/Transforms/IPO/FunctionImport.h"
#include "llvm/Transforms/IPO/Internalize.h"
#include "llvm/Transforms/IPO/WholeProgramDevirt.h"
#include "llvm/Transforms/ObjCARC.h"
#include "llvm/Transforms/Utils/FunctionImportUtils.h"
#include <numeric>
#include <unistd.h>

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   "thinlto"
 

Functions

static void saveTempBitcode (const Module &TheModule, StringRef TempDir, unsigned count, StringRef Suffix)
 
static const GlobalValueSummarygetFirstDefinitionForLinker (const GlobalValueSummaryList &GVSummaryList)
 
static void computePrevailingCopies (const ModuleSummaryIndex &Index, DenseMap< GlobalValue::GUID, const GlobalValueSummary * > &PrevailingCopy)
 
static StringMap< lto::InputFile * > generateModuleMap (std::vector< std::unique_ptr< lto::InputFile > > &Modules)
 
static void promoteModule (Module &TheModule, const ModuleSummaryIndex &Index, bool ClearDSOLocalOnDeclarations)
 
static void verifyLoadedModule (Module &TheModule)
 Verify the module and strip broken debug info.
 
static std::unique_ptr< ModuleloadModuleFromInput (lto::InputFile *Input, LLVMContext &Context, bool Lazy, bool IsImporting)
 
static void crossImportIntoModule (Module &TheModule, const ModuleSummaryIndex &Index, StringMap< lto::InputFile * > &ModuleMap, const FunctionImporter::ImportMapTy &ImportList, bool ClearDSOLocalOnDeclarations)
 
static void optimizeModule (Module &TheModule, TargetMachine &TM, unsigned OptLevel, bool Freestanding, bool DebugPassManager, ModuleSummaryIndex *Index)
 
static void addUsedSymbolToPreservedGUID (const lto::InputFile &File, DenseSet< GlobalValue::GUID > &PreservedGUID)
 
static void computeGUIDPreservedSymbols (const lto::InputFile &File, const StringSet<> &PreservedSymbols, const Triple &TheTriple, DenseSet< GlobalValue::GUID > &GUIDs)
 
static DenseSet< GlobalValue::GUIDcomputeGUIDPreservedSymbols (const lto::InputFile &File, const StringSet<> &PreservedSymbols, const Triple &TheTriple)
 
static std::unique_ptr< MemoryBuffercodegenModule (Module &TheModule, TargetMachine &TM)
 
static std::unique_ptr< MemoryBufferProcessThinLTOModule (Module &TheModule, ModuleSummaryIndex &Index, StringMap< lto::InputFile * > &ModuleMap, TargetMachine &TM, const FunctionImporter::ImportMapTy &ImportList, const FunctionImporter::ExportSetTy &ExportList, const DenseSet< GlobalValue::GUID > &GUIDPreservedSymbols, const GVSummaryMapTy &DefinedGlobals, const ThinLTOCodeGenerator::CachingOptions &CacheOptions, bool DisableCodeGen, StringRef SaveTempsDir, bool Freestanding, unsigned OptLevel, unsigned count, bool DebugPassManager)
 
static void resolvePrevailingInIndex (ModuleSummaryIndex &Index, StringMap< std::map< GlobalValue::GUID, GlobalValue::LinkageTypes > > &ResolvedODR, const DenseSet< GlobalValue::GUID > &GUIDPreservedSymbols, const DenseMap< GlobalValue::GUID, const GlobalValueSummary * > &PrevailingCopy)
 Resolve prevailing symbols.
 
static void initTMBuilder (TargetMachineBuilder &TMBuilder, const Triple &TheTriple)
 
static void computeDeadSymbolsInIndex (ModuleSummaryIndex &Index, const DenseSet< GlobalValue::GUID > &GUIDPreservedSymbols)
 

Variables

static cl::opt< int > ThreadCount ("threads", cl::init(0))
 

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "thinlto"

Definition at line 75 of file ThinLTOCodeGenerator.cpp.

Function Documentation

◆ addUsedSymbolToPreservedGUID()

static void addUsedSymbolToPreservedGUID ( const lto::InputFile File,
DenseSet< GlobalValue::GUID > &  PreservedGUID 
)
static

◆ codegenModule()

static std::unique_ptr< MemoryBuffer > codegenModule ( Module TheModule,
TargetMachine TM 
)
static

◆ computeDeadSymbolsInIndex()

static void computeDeadSymbolsInIndex ( ModuleSummaryIndex Index,
const DenseSet< GlobalValue::GUID > &  GUIDPreservedSymbols 
)
static

◆ computeGUIDPreservedSymbols() [1/2]

static DenseSet< GlobalValue::GUID > computeGUIDPreservedSymbols ( const lto::InputFile File,
const StringSet<> &  PreservedSymbols,
const Triple TheTriple 
)
static

Definition at line 318 of file ThinLTOCodeGenerator.cpp.

References computeGUIDPreservedSymbols(), and PreservedSymbols.

◆ computeGUIDPreservedSymbols() [2/2]

static void computeGUIDPreservedSymbols ( const lto::InputFile File,
const StringSet<> &  PreservedSymbols,
const Triple TheTriple,
DenseSet< GlobalValue::GUID > &  GUIDs 
)
static

◆ computePrevailingCopies()

static void computePrevailingCopies ( const ModuleSummaryIndex Index,
DenseMap< GlobalValue::GUID, const GlobalValueSummary * > &  PrevailingCopy 
)
static

◆ crossImportIntoModule()

static void crossImportIntoModule ( Module TheModule,
const ModuleSummaryIndex Index,
StringMap< lto::InputFile * > &  ModuleMap,
const FunctionImporter::ImportMapTy ImportList,
bool  ClearDSOLocalOnDeclarations 
)
static

◆ generateModuleMap()

static StringMap< lto::InputFile * > generateModuleMap ( std::vector< std::unique_ptr< lto::InputFile > > &  Modules)
static

◆ getFirstDefinitionForLinker()

static const GlobalValueSummary * getFirstDefinitionForLinker ( const GlobalValueSummaryList GVSummaryList)
static

◆ initTMBuilder()

static void initTMBuilder ( TargetMachineBuilder TMBuilder,
const Triple TheTriple 
)
static

◆ loadModuleFromInput()

static std::unique_ptr< Module > loadModuleFromInput ( lto::InputFile Input,
LLVMContext Context,
bool  Lazy,
bool  IsImporting 
)
static

◆ optimizeModule()

static void optimizeModule ( Module TheModule,
TargetMachine TM,
unsigned  OptLevel,
bool  Freestanding,
bool  DebugPassManager,
ModuleSummaryIndex Index 
)
static

◆ ProcessThinLTOModule()

static std::unique_ptr< MemoryBuffer > ProcessThinLTOModule ( Module TheModule,
ModuleSummaryIndex Index,
StringMap< lto::InputFile * > &  ModuleMap,
TargetMachine TM,
const FunctionImporter::ImportMapTy ImportList,
const FunctionImporter::ExportSetTy ExportList,
const DenseSet< GlobalValue::GUID > &  GUIDPreservedSymbols,
const GVSummaryMapTy DefinedGlobals,
const ThinLTOCodeGenerator::CachingOptions CacheOptions,
bool  DisableCodeGen,
StringRef  SaveTempsDir,
bool  Freestanding,
unsigned  OptLevel,
unsigned  count,
bool  DebugPassManager 
)
static

◆ promoteModule()

static void promoteModule ( Module TheModule,
const ModuleSummaryIndex Index,
bool  ClearDSOLocalOnDeclarations 
)
static

◆ resolvePrevailingInIndex()

static void resolvePrevailingInIndex ( ModuleSummaryIndex Index,
StringMap< std::map< GlobalValue::GUID, GlobalValue::LinkageTypes > > &  ResolvedODR,
const DenseSet< GlobalValue::GUID > &  GUIDPreservedSymbols,
const DenseMap< GlobalValue::GUID, const GlobalValueSummary * > &  PrevailingCopy 
)
static

Resolve prevailing symbols.

Record resolutions in the ResolvedODR map for caching, and in the Index for application during the ThinLTO backends. This is needed for correctness for exported symbols (ensure at least one copy kept) and a compile-time optimization (to drop duplicate copies when possible).

Definition at line 508 of file ThinLTOCodeGenerator.cpp.

References llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::end(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::find(), and llvm::thinLTOResolvePrevailingInIndex().

Referenced by llvm::ThinLTOCodeGenerator::internalize(), llvm::ThinLTOCodeGenerator::promote(), and llvm::ThinLTOCodeGenerator::run().

◆ saveTempBitcode()

static void saveTempBitcode ( const Module TheModule,
StringRef  TempDir,
unsigned  count,
StringRef  Suffix 
)
static

◆ verifyLoadedModule()

static void verifyLoadedModule ( Module TheModule)
static

Variable Documentation

◆ ThreadCount

cl::opt< int > ThreadCount("threads", cl::init(0)) ( "threads"  ,
cl::init(0)   
)
static