LLVM 17.0.0git
Classes | Macros | Functions | Variables
FunctionSpecialization.cpp File Reference
#include "llvm/Transforms/IPO/FunctionSpecialization.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/Analysis/CodeMetrics.h"
#include "llvm/Analysis/InlineCost.h"
#include "llvm/Analysis/LoopInfo.h"
#include "llvm/Analysis/TargetTransformInfo.h"
#include "llvm/Analysis/ValueLattice.h"
#include "llvm/Analysis/ValueLatticeUtils.h"
#include "llvm/IR/IntrinsicInst.h"
#include "llvm/Transforms/Scalar/SCCP.h"
#include "llvm/Transforms/Utils/Cloning.h"
#include "llvm/Transforms/Utils/SCCPSolver.h"
#include "llvm/Transforms/Utils/SizeOpts.h"
#include <cmath>
Include dependency graph for FunctionSpecialization.cpp:

Go to the source code of this file.

Classes

struct  llvm::DenseMapInfo< SpecSig >
 

Macros

#define DEBUG_TYPE   "function-specialization"
 

Functions

 STATISTIC (NumFuncSpecialized, "Number of functions specialized")
 
static void removeSSACopy (Function &F)
 
static FunctioncloneCandidateFunction (Function *F)
 Clone the function F and remove the ssa_copy intrinsics added by the SCCPSolver in the cloned version.
 
static InstructionCost getUserBonus (User *U, llvm::TargetTransformInfo &TTI, const LoopInfo &LI)
 

Variables

static cl::opt< boolForceFunctionSpecialization ("force-function-specialization", cl::init(false), cl::Hidden, cl::desc("Force function specialization for every call site with a " "constant argument"))
 
static cl::opt< unsignedMaxClonesThreshold ("func-specialization-max-clones", cl::Hidden, cl::desc("The maximum number of clones allowed for a single function " "specialization"), cl::init(3))
 
static cl::opt< unsignedSmallFunctionThreshold ("func-specialization-size-threshold", cl::Hidden, cl::desc("Don't specialize functions that have less than this theshold " "number of instructions"), cl::init(100))
 
static cl::opt< unsignedAvgLoopIterationCount ("func-specialization-avg-iters-cost", cl::Hidden, cl::desc("Average loop iteration count cost"), cl::init(10))
 
static cl::opt< boolSpecializeOnAddresses ("func-specialization-on-address", cl::init(false), cl::Hidden, cl::desc("Enable function specialization on the address of global values"))
 
static cl::opt< boolEnableSpecializationForLiteralConstant ("function-specialization-for-literal-constant", cl::init(false), cl::Hidden, cl::desc("Enable specialization of functions that take a literal constant " "as an argument."))
 

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "function-specialization"

Definition at line 65 of file FunctionSpecialization.cpp.

Function Documentation

◆ cloneCandidateFunction()

static Function * cloneCandidateFunction ( Function F)
static

Clone the function F and remove the ssa_copy intrinsics added by the SCCPSolver in the cloned version.

Definition at line 396 of file FunctionSpecialization.cpp.

References llvm::CloneFunction(), F, Mappings, and removeSSACopy().

◆ getUserBonus()

static InstructionCost getUserBonus ( User U,
llvm::TargetTransformInfo TTI,
const LoopInfo LI 
)
static

◆ removeSSACopy()

static void removeSSACopy ( Function F)
static

Definition at line 217 of file FunctionSpecialization.cpp.

References F, and llvm::make_early_inc_range().

Referenced by cloneCandidateFunction().

◆ STATISTIC()

STATISTIC ( NumFuncSpecialized  ,
"Number of functions specialized"   
)

Variable Documentation

◆ AvgLoopIterationCount

cl::opt< unsigned > AvgLoopIterationCount("func-specialization-avg-iters-cost", cl::Hidden, cl::desc("Average loop iteration count cost"), cl::init(10)) ( "func-specialization-avg-iters-cost"  ,
cl::Hidden  ,
cl::desc("Average loop iteration count cost")  ,
cl::init(10)   
)
static

Referenced by getUserBonus().

◆ EnableSpecializationForLiteralConstant

cl::opt< bool > EnableSpecializationForLiteralConstant("function-specialization-for-literal-constant", cl::init(false), cl::Hidden, cl::desc("Enable specialization of functions that take a literal constant " "as an argument.")) ( "function-specialization-for-literal-constant"  ,
cl::init(false)  ,
cl::Hidden  ,
cl::desc("Enable specialization of functions that take a literal constant " "as an argument.")   
)
static

◆ ForceFunctionSpecialization

cl::opt< bool > ForceFunctionSpecialization("force-function-specialization", cl::init(false), cl::Hidden, cl::desc("Force function specialization for every call site with a " "constant argument")) ( "force-function-specialization"  ,
cl::init(false)  ,
cl::Hidden  ,
cl::desc("Force function specialization for every call site with a " "constant argument")   
)
static

◆ MaxClonesThreshold

cl::opt< unsigned > MaxClonesThreshold("func-specialization-max-clones", cl::Hidden, cl::desc("The maximum number of clones allowed for a single function " "specialization"), cl::init(3)) ( "func-specialization-max-clones"  ,
cl::Hidden  ,
cl::desc("The maximum number of clones allowed for a single function " "specialization")  ,
cl::init(3)   
)
static

◆ SmallFunctionThreshold

cl::opt< unsigned > SmallFunctionThreshold("func-specialization-size-threshold", cl::Hidden, cl::desc("Don't specialize functions that have less than this theshold " "number of instructions"), cl::init(100)) ( "func-specialization-size-threshold"  ,
cl::Hidden  ,
cl::desc("Don't specialize functions that have less than this theshold " "number of instructions")  ,
cl::init(100)   
)
static

◆ SpecializeOnAddresses

cl::opt< bool > SpecializeOnAddresses("func-specialization-on-address", cl::init(false), cl::Hidden, cl::desc("Enable function specialization on the address of global values")) ( "func-specialization-on-address"  ,
cl::init(false)  ,
cl::Hidden  ,
cl::desc("Enable function specialization on the address of global values")   
)
static