LLVM 20.0.0git
|
#include "llvm/CodeGen/GlobalMergeFunctions.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/Analysis/ModuleSummaryAnalysis.h"
#include "llvm/CGData/CodeGenData.h"
#include "llvm/IR/IRBuilder.h"
#include "llvm/IR/StructuralHash.h"
#include "llvm/InitializePasses.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Transforms/Utils/ModuleUtils.h"
Go to the source code of this file.
Classes | |
struct | FuncMergeInfo |
Tuple to hold function info to process merging. More... | |
Namespaces | |
namespace | llvm |
This is an optimization pass for GlobalISel generic memory operations. | |
Macros | |
#define | DEBUG_TYPE "global-merge-func" |
Functions | |
STATISTIC (NumMergedFunctions, "Number of functions that are actually merged using function hash") | |
STATISTIC (NumAnalyzedModues, "Number of modules that are analyzed") | |
STATISTIC (NumAnalyzedFunctions, "Number of functions that are analyzed") | |
STATISTIC (NumEligibleFunctions, "Number of functions that are eligible") | |
static bool | isCalleeOperand (const CallBase *CI, unsigned OpIdx) |
Returns true if the \OpIdx operand of CI is the callee operand. | |
static bool | canParameterizeCallOperand (const CallBase *CI, unsigned OpIdx) |
bool | isEligibleFunction (Function *F) |
Returns true if function F is eligible for merging. | |
static bool | isEligibleInstructionForConstantSharing (const Instruction *I) |
static bool | ignoreOp (const Instruction *I, unsigned OpIdx) |
static Value * | createCast (IRBuilder<> &Builder, Value *V, Type *DestTy) |
static Function * | createMergedFunction (FuncMergeInfo &FI, ArrayRef< Type * > ConstParamTypes, const ParamLocsVecTy &ParamLocsVec) |
static void | createThunk (FuncMergeInfo &FI, ArrayRef< Constant * > Params, Function *ToFunc) |
static bool | checkConstHashCompatible (const DenseMap< IndexPair, stable_hash > &OldInstOpndIndexToConstHash, const DenseMap< IndexPair, stable_hash > &CurrInstOpndIndexToConstHash) |
static bool | checkConstLocationCompatible (const StableFunctionMap::StableFunctionEntry &SF, const IndexInstrMap &IndexInstruction, const ParamLocsVecTy &ParamLocsVec) |
static ParamLocsVecTy | computeParamInfo (const SmallVector< std::unique_ptr< StableFunctionMap::StableFunctionEntry > > &SFS) |
INITIALIZE_PASS_BEGIN (GlobalMergeFuncPassWrapper, "global-merge-func", "Global merge function pass", false, false) INITIALIZE_PASS_END(GlobalMergeFuncPassWrapper | |
ModulePass * | llvm::createGlobalMergeFuncPass () |
This pass performs merging similar functions globally. | |
Variables | |
static cl::opt< bool > | DisableCGDataForMerging ("disable-cgdata-for-merging", cl::Hidden, cl::desc("Disable codegen data for function merging. Local " "merging is still enabled within a module."), cl::init(false)) |
global merge | func |
global merge Global merge function | pass |
global merge Global merge function | false |
#define DEBUG_TYPE "global-merge-func" |
Definition at line 23 of file GlobalMergeFunctions.cpp.
Definition at line 45 of file GlobalMergeFunctions.cpp.
References llvm::CallBase::getCalledOperand(), llvm::CallBase::getOperandBundle(), isCalleeOperand(), llvm::CallBase::isInlineAsm(), Name, llvm::LLVMContext::OB_ptrauth, and llvm::Value::stripPointerCasts().
Referenced by ignoreOp().
|
static |
Definition at line 331 of file GlobalMergeFunctions.cpp.
References llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::end(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::find(), and llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::insert().
Referenced by llvm::GlobalMergeFunc::merge().
|
static |
Definition at line 354 of file GlobalMergeFunctions.cpp.
References assert(), llvm::StableFunctionMap::StableFunctionEntry::IndexOperandHashMap, llvm::MapVector< KeyT, ValueT, MapType, VectorType >::lookup(), and llvm::MapVector< KeyT, ValueT, MapType, VectorType >::size().
Referenced by llvm::GlobalMergeFunc::merge().
|
static |
Definition at line 378 of file GlobalMergeFunctions.cpp.
References llvm::SmallVectorTemplateBase< T, bool >::push_back(), llvm::SmallVectorBase< Size_T >::size(), and llvm::sort().
Referenced by llvm::GlobalMergeFunc::merge().
Definition at line 137 of file GlobalMergeFunctions.cpp.
References assert(), llvm::IRBuilderBase::CreateBitCast(), createCast(), llvm::IRBuilderBase::CreateExtractValue(), llvm::IRBuilderBase::CreateInsertValue(), llvm::IRBuilderBase::CreateIntToPtr(), llvm::IRBuilderBase::CreatePtrToInt(), llvm::PoisonValue::get(), llvm::Type::getStructElementType(), llvm::Type::getStructNumElements(), I, llvm::Type::isArrayTy(), llvm::Type::isIntegerTy(), llvm::Type::isPointerTy(), and llvm::Type::isStructTy().
Referenced by createCast(), createMergedFunction(), and createThunk().
|
static |
Definition at line 212 of file GlobalMergeFunctions.cpp.
References llvm::Function::addFnAttr(), llvm::SmallVectorImpl< T >::append(), llvm::Function::arg_begin(), assert(), llvm::Function::begin(), llvm::ArrayRef< T >::begin(), llvm::Function::copyAttributesFrom(), llvm::Function::Create(), createCast(), llvm::GlobalValue::DefaultStorageClass, llvm::ArrayRef< T >::end(), FuncMergeInfo::F, llvm::FunctionType::get(), llvm::Function::getArg(), llvm::Value::getName(), llvm::Value::getType(), FuncMergeInfo::IndexInstruction, llvm::GlobalValue::InternalLinkage, llvm::MapVector< KeyT, ValueT, MapType, VectorType >::lookup(), llvm::GlobalMergeFunc::MergingInstanceSuffix, llvm::Value::replaceAllUsesWith(), llvm::GlobalValue::setDLLStorageClass(), llvm::GlobalValue::setLinkage(), llvm::Function::setSubprogram(), llvm::SmallVectorBase< Size_T >::size(), llvm::Function::splice(), and llvm::StringRef::str().
Referenced by llvm::GlobalMergeFunc::merge().
|
static |
Definition at line 277 of file GlobalMergeFunctions.cpp.
References assert(), llvm::BasicBlock::Create(), llvm::IRBuilderBase::CreateCall(), createCast(), llvm::IRBuilderBase::CreateRet(), llvm::IRBuilderBase::CreateRetVoid(), FuncMergeInfo::F, llvm::Function::getAttributes(), llvm::Function::getCallingConv(), llvm::Function::getFunctionType(), llvm::FunctionType::getNumParams(), llvm::CallBase::setAttributes(), llvm::CallBase::setCallingConv(), llvm::CallInst::setTailCallKind(), llvm::ArrayRef< T >::size(), llvm::CallingConv::SwiftTail, llvm::CallInst::TCK_MustTail, and llvm::CallInst::TCK_Tail.
Referenced by llvm::GlobalMergeFunc::merge().
|
static |
Definition at line 121 of file GlobalMergeFunctions.cpp.
References canParameterizeCallOperand(), I, and isEligibleInstructionForConstantSharing().
Referenced by llvm::GlobalMergeFunc::analyze(), and llvm::GlobalMergeFunc::merge().
INITIALIZE_PASS_BEGIN | ( | GlobalMergeFuncPassWrapper | , |
"global-merge-func" | , | ||
"Global merge function pass" | , | ||
false | , | ||
false | |||
) |
Returns true if the \OpIdx operand of CI
is the callee operand.
Definition at line 41 of file GlobalMergeFunctions.cpp.
References llvm::CallBase::getCalledOperandUse(), and llvm::User::getOperandUse().
Referenced by canParameterizeCallOperand().
Returns true if function F
is eligible for merging.
Definition at line 73 of file GlobalMergeFunctions.cpp.
References F, I, and llvm::CallingConv::SwiftTail.
Referenced by llvm::GlobalMergeFunc::analyze(), and llvm::GlobalMergeFunc::merge().
|
static |
STATISTIC | ( | NumAnalyzedFunctions | , |
"Number of functions that are analyzed" | |||
) |
STATISTIC | ( | NumAnalyzedModues | , |
"Number of modules that are analyzed" | |||
) |
STATISTIC | ( | NumEligibleFunctions | , |
"Number of functions that are eligible" | |||
) |
STATISTIC | ( | NumMergedFunctions | , |
"Number of functions that are actually merged using function hash" | |||
) |
|
static |
Referenced by llvm::GlobalMergeFunc::initializeMergerMode().
Definition at line 617 of file GlobalMergeFunctions.cpp.
global merge func |
Definition at line 616 of file GlobalMergeFunctions.cpp.
Referenced by llvm::cl::AddExtraVersionPrinter(), llvm::WebAssembly::getLibcallSignature(), tomp::makeList(), llvm::yaml::MappingTraits< FunctionYAML >::mapping(), and llvm::cl::SetVersionPrinter().
Definition at line 617 of file GlobalMergeFunctions.cpp.
Referenced by LLVMTargetMachineEmit(), and llvm::verifySafepointIR().