LLVM 22.0.0git
|
GlobalMergeFunc is a ModulePass that implements a function merging mechanism using stable function hashes. More...
#include "llvm/CodeGen/GlobalMergeFunctions.h"
Public Member Functions | |
GlobalMergeFunc (const ModuleSummaryIndex *Index) | |
void | initializeMergerMode (const Module &M) |
bool | run (Module &M) |
void | analyze (Module &M) |
Analyze module to create stable function into LocalFunctionMap. | |
void | emitFunctionMap (Module &M) |
Emit LocalFunctionMap into __llvm_merge section. | |
bool | merge (Module &M, const StableFunctionMap *FunctionMap) |
Merge functions in the module using the given function map. |
Static Public Attributes | |
static constexpr const char | MergingInstanceSuffix [] = ".Tgm" |
The suffix used to identify the merged function that parameterizes the constant values. |
GlobalMergeFunc is a ModulePass that implements a function merging mechanism using stable function hashes.
It identifies and merges functions with matching hashes across modules to optimize binary size.
Definition at line 50 of file GlobalMergeFunctions.h.
|
inline |
Definition at line 63 of file GlobalMergeFunctions.h.
void GlobalMergeFunc::analyze | ( | Module & | M | ) |
Analyze module to create stable function into LocalFunctionMap.
Definition at line 149 of file GlobalMergeFunctions.cpp.
References llvm::SmallVectorImpl< T >::emplace_back(), llvm::get_stable_name(), ignoreOp(), isEligibleFunction(), and llvm::StructuralHashWithDifferences().
Referenced by run().
void GlobalMergeFunc::emitFunctionMap | ( | Module & | M | ) |
Emit LocalFunctionMap into __llvm_merge section.
Definition at line 524 of file GlobalMergeFunctions.cpp.
References llvm::dbgs(), llvm::embedBufferInModule(), llvm::getCodeGenDataSectionName(), llvm::MemoryBuffer::getMemBuffer(), LLVM_DEBUG, llvm::CGDataOStream::patch(), llvm::StableFunctionMapRecord::serialize(), and llvm::raw_svector_ostream::str().
Referenced by run().
Definition at line 505 of file GlobalMergeFunctions.cpp.
References BuildingHashFuncion, DisableCGDataForMerging, llvm::cgdata::emitCGData(), llvm::cgdata::hasStableFunctionMap(), and UsingHashFunction.
Referenced by run().
bool GlobalMergeFunc::merge | ( | Module & | M, |
const StableFunctionMap * | FunctionMap ) |
Merge functions in the module using the given function map.
Definition at line 392 of file GlobalMergeFunctions.cpp.
References assert(), llvm::StableFunctionMap::at(), llvm::cast(), Changed, checkConstHashCompatible(), checkConstLocationCompatible(), computeParamInfo(), llvm::StableFunctionMap::contains(), createMergedFunction(), createThunk(), llvm::dbgs(), llvm::Value::dump(), llvm::SmallVectorImpl< T >::emplace_back(), F, llvm::Value::getName(), ignoreOp(), llvm::StableFunctionMap::StableFunctionEntry::IndexOperandHashMap, llvm::StableFunctionMap::StableFunctionEntry::InstCount, isEligibleFunction(), LLVM_DEBUG, llvm::SmallVectorTemplateBase< T, bool >::push_back(), llvm::size(), llvm::SmallVectorTemplateCommon< T, typename >::size(), and llvm::StructuralHashWithDifferences().
Referenced by run().
Definition at line 547 of file GlobalMergeFunctions.cpp.
References analyze(), BuildingHashFuncion, emitFunctionMap(), llvm::cgdata::getStableFunctionMap(), initializeMergerMode(), merge(), and UsingHashFunction.
Referenced by llvm::GlobalMergeFuncPass::run().
The suffix used to identify the merged function that parameterizes the constant values.
Note that the original function, without this suffix, becomes a thunk supplying contexts to the merged function via parameters.
Definition at line 61 of file GlobalMergeFunctions.h.
Referenced by createMergedFunction().