Movatterモバイル変換


[0]ホーム

URL:


LLVM 20.0.0git
Macros |Functions |Variables
MergeFunctions.cpp File Reference
#include "llvm/Transforms/IPO/MergeFunctions.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/IR/Argument.h"
#include "llvm/IR/BasicBlock.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/DebugInfoMetadata.h"
#include "llvm/IR/DebugLoc.h"
#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/GlobalValue.h"
#include "llvm/IR/IRBuilder.h"
#include "llvm/IR/InstrTypes.h"
#include "llvm/IR/Instruction.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/IntrinsicInst.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/StructuralHash.h"
#include "llvm/IR/Type.h"
#include "llvm/IR/Use.h"
#include "llvm/IR/User.h"
#include "llvm/IR/Value.h"
#include "llvm/IR/ValueHandle.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Transforms/IPO.h"
#include "llvm/Transforms/Utils/FunctionComparator.h"
#include "llvm/Transforms/Utils/ModuleUtils.h"
#include <algorithm>
#include <cassert>
#include <iterator>
#include <set>
#include <utility>
#include <vector>

Go to the source code of this file.

Macros

#define DEBUG_TYPE   "mergefunc"
 

Functions

 STATISTIC (NumFunctionsMerged, "Number offunctions merged")
 
 STATISTIC (NumThunksWritten, "Number of thunks generated")
 
 STATISTIC (NumAliasesWritten, "Number of aliases generated")
 
 STATISTIC (NumDoubleWeak, "Number of newfunctions created")
 
staticbool hasDistinctMetadataIntrinsic (constFunction &F)
 Check whetherF has an intrinsic which references distinct metadata as an operand.
 
staticbool isEligibleForMerging (Function &F)
 Check whetherF is eligible for function merging.
 
FunctionasPtr (Function *Fn)
 
FunctionasPtr (Function &Fn)
 
staticValuecreateCast (IRBuilder<> &Builder,Value *V,Type *DestTy)
 
staticbool canCreateThunkFor (Function *F)
 Whether this function may be replaced by a forwarding thunk.
 
static void copyMetadataIfPresent (Function *From,Function *To,StringRef Kind)
 Copy all metadata of a specific kind from one function to another.
 
staticbool canCreateAliasFor (Function *F)
 
staticbool isFuncOrderCorrect (constFunction *F,constFunction *G)
 

Variables

staticcl::opt<unsignedNumFunctionsForVerificationCheck ("mergefunc-verify",cl::desc("How manyfunctions in a module could be usedfor " "MergeFunctions topass a basic correctness check. " "'0' disables this check. Worksonly with '-debug' key."), cl::init(0), cl::Hidden)
 
staticcl::opt<boolMergeFunctionsPDI ("mergefunc-preserve-debug-info", cl::Hidden, cl::init(false),cl::desc("Preservedebuginfo in thunk when mergefunc " "transformations are made."))
 
staticcl::opt<boolMergeFunctionsAliases ("mergefunc-use-aliases", cl::Hidden, cl::init(false),cl::desc("Allow mergefunc to create aliases"))
 

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "mergefunc"

Definition at line131 of fileMergeFunctions.cpp.

Function Documentation

◆ asPtr()[1/2]

Function * asPtr(FunctionFn)
inline

Definition at line435 of fileMergeFunctions.cpp.

◆ asPtr()[2/2]

Function * asPtr(FunctionFn)
inline

Definition at line434 of fileMergeFunctions.cpp.

◆ canCreateAliasFor()

staticbool canCreateAliasFor(FunctionF)
static

Definition at line844 of fileMergeFunctions.cpp.

Referencesassert(),F, andMergeFunctionsAliases.

◆ canCreateThunkFor()

staticbool canCreateThunkFor(FunctionF)
static

Whether this function may be replaced by a forwarding thunk.

Definition at line726 of fileMergeFunctions.cpp.

Referencesllvm::dbgs(),F, andLLVM_DEBUG.

◆ copyMetadataIfPresent()

static void copyMetadataIfPresent(FunctionFrom,
FunctionTo,
StringRef Kind 
)
static

Copy all metadata of a specific kind from one function to another.

Definition at line743 of fileMergeFunctions.cpp.

Referencesllvm::GlobalObject::addMetadata(), andFrom.

◆ createCast()

staticValue * createCast(IRBuilder<> & Builder,
ValueV,
TypeDestTy 
)
static

Definition at line516 of fileMergeFunctions.cpp.

Referencesassert(),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::isIntegerTy(),llvm::Type::isPointerTy(), andllvm::Type::isStructTy().

◆ hasDistinctMetadataIntrinsic()

staticbool hasDistinctMetadataIntrinsic(constFunctionF)
static

Check whetherF has an intrinsic which references distinct metadata as an operand.

The most common instance of this would be CFI checks for function-local types.

Definition at line409 of fileMergeFunctions.cpp.

ReferencesF,I, andN.

Referenced byisEligibleForMerging().

◆ isEligibleForMerging()

staticbool isEligibleForMerging(FunctionF)
static

Check whetherF is eligible for function merging.

Definition at line429 of fileMergeFunctions.cpp.

ReferencesF, andhasDistinctMetadataIntrinsic().

◆ isFuncOrderCorrect()

staticbool isFuncOrderCorrect(constFunctionF,
constFunctionG 
)
static

Definition at line988 of fileMergeFunctions.cpp.

ReferencesF, andG.

◆ STATISTIC()[1/4]

STATISTIC(NumAliasesWritten ,
"Number of aliases generated"  
)

◆ STATISTIC()[2/4]

STATISTIC(NumDoubleWeak ,
"Number of newfunctions created"  
)

◆ STATISTIC()[3/4]

STATISTIC(NumFunctionsMerged ,
"Number offunctions merged"  
)

◆ STATISTIC()[4/4]

STATISTIC(NumThunksWritten ,
"Number of thunks generated"  
)

Variable Documentation

◆ MergeFunctionsAliases

cl::opt<bool > MergeFunctionsAliases("mergefunc-use-aliases", cl::Hidden, cl::init(false),cl::desc("Allow mergefunc to create aliases"))("mergefunc-use-aliases" ,
cl::Hidden ,
cl::init(false) ,
cl::desc("Allow mergefunc to create aliases")  
)
static

Referenced bycanCreateAliasFor().

◆ MergeFunctionsPDI

cl::opt<bool > MergeFunctionsPDI("mergefunc-preserve-debug-info", cl::Hidden, cl::init(false),cl::desc("Preservedebuginfo in thunk when mergefunc " "transformations are made."))("mergefunc-preserve-debug-info" ,
cl::Hidden ,
cl::init(false) ,
cl::desc("Preservedebuginfo in thunk when mergefunc " "transformations are made.")  
)
static

◆ NumFunctionsForVerificationCheck

cl::opt<unsigned > NumFunctionsForVerificationCheck("mergefunc-verify",cl::desc("How manyfunctions in a module could be usedfor " "MergeFunctions topass a basic correctness check. " "'0' disables this check. Worksonly with '-debug' key."), cl::init(0), cl::Hidden)("mergefunc-verify" ,
cl::desc("How manyfunctions in a module could be usedfor " "MergeFunctions topass a basic correctness check. " "'0' disables this check. Worksonly with '-debug' key.") ,
cl::init(0) ,
cl::Hidden  
)
static

Generated on Sun Jul 20 2025 15:03:38 for LLVM by doxygen 1.9.6
[8]ページ先頭

©2009-2025 Movatter.jp