LLVM 20.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 175 of file GlobalMergeFunctions.cpp.
References llvm::SmallVectorImpl< T >::emplace_back(), llvm::get_stable_name(), ignoreOp(), isEligibleFunction(), llvm::StringRef::str(), and llvm::StructuralHashWithDifferences().
Referenced by run().
void GlobalMergeFunc::emitFunctionMap | ( | Module & | M | ) |
Emit LocalFunctionMap into __llvm_merge section.
Definition at line 551 of file GlobalMergeFunctions.cpp.
References llvm::dbgs(), llvm::embedBufferInModule(), llvm::getCodeGenDataSectionName(), llvm::MemoryBuffer::getMemBuffer(), LLVM_DEBUG, OS, and llvm::StableFunctionMapRecord::serialize().
Referenced by run().
Definition at line 532 of file GlobalMergeFunctions.cpp.
References DisableCGDataForMerging, llvm::cgdata::emitCGData(), llvm::ModuleSummaryIndex::hasExportedFunctions(), and llvm::cgdata::hasStableFunctionMap().
Referenced by run().
bool GlobalMergeFunc::merge | ( | Module & | M, |
const StableFunctionMap * | FunctionMap | ||
) |
Merge functions in the module using the given function map.
Definition at line 418 of file GlobalMergeFunctions.cpp.
References assert(), checkConstHashCompatible(), checkConstLocationCompatible(), computeParamInfo(), createMergedFunction(), createThunk(), llvm::dbgs(), llvm::Value::dump(), llvm::SmallVectorImpl< T >::emplace_back(), llvm::SmallVectorBase< Size_T >::empty(), F, llvm::StableFunctionMap::getFunctionMap(), llvm::Value::getName(), ignoreOp(), llvm::StableFunctionMap::StableFunctionEntry::IndexOperandHashMap, llvm::StableFunctionMap::StableFunctionEntry::InstCount, isEligibleFunction(), LLVM_DEBUG, llvm::SmallVectorTemplateBase< T, bool >::push_back(), llvm::SmallVectorBase< Size_T >::size(), llvm::size(), and llvm::StructuralHashWithDifferences().
Referenced by run().
Definition at line 571 of file GlobalMergeFunctions.cpp.
References analyze(), emitFunctionMap(), llvm::cgdata::getStableFunctionMap(), initializeMergerMode(), and merge().
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().