LLVM 20.0.0git |
#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. | |
Function * | asPtr (Function *Fn) |
Function * | asPtr (Function &Fn) |
staticValue * | createCast (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<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) |
staticcl::opt<bool > | MergeFunctionsPDI ("mergefunc-preserve-debug-info", cl::Hidden, cl::init(false),cl::desc("Preservedebuginfo in thunk when mergefunc " "transformations are made.")) |
staticcl::opt<bool > | MergeFunctionsAliases ("mergefunc-use-aliases", cl::Hidden, cl::init(false),cl::desc("Allow mergefunc to create aliases")) |
#define DEBUG_TYPE "mergefunc" |
Definition at line131 of fileMergeFunctions.cpp.
Definition at line435 of fileMergeFunctions.cpp.
Definition at line434 of fileMergeFunctions.cpp.
Definition at line844 of fileMergeFunctions.cpp.
Referencesassert(),F, andMergeFunctionsAliases.
Whether this function may be replaced by a forwarding thunk.
Definition at line726 of fileMergeFunctions.cpp.
Referencesllvm::dbgs(),F, andLLVM_DEBUG.
Copy all metadata of a specific kind from one function to another.
Definition at line743 of fileMergeFunctions.cpp.
Referencesllvm::GlobalObject::addMetadata(), andFrom.
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().
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.
Referenced byisEligibleForMerging().
Check whetherF
is eligible for function merging.
Definition at line429 of fileMergeFunctions.cpp.
ReferencesF, andhasDistinctMetadataIntrinsic().
Definition at line988 of fileMergeFunctions.cpp.
STATISTIC | ( | NumAliasesWritten | , |
"Number of aliases generated" | |||
) |
STATISTIC | ( | NumDoubleWeak | , |
"Number of newfunctions created" | |||
) |
STATISTIC | ( | NumFunctionsMerged | , |
"Number offunctions merged" | |||
) |
STATISTIC | ( | NumThunksWritten | , |
"Number of thunks generated" | |||
) |
| static |
Referenced bycanCreateAliasFor().
| static |
| static |