LLVM  14.0.0git
Classes | Macros | Functions | Variables
FunctionSpecialization.cpp File Reference
#include "llvm/ADT/Statistic.h"
#include "llvm/Analysis/AssumptionCache.h"
#include "llvm/Analysis/CodeMetrics.h"
#include "llvm/Analysis/DomTreeUpdater.h"
#include "llvm/Analysis/InlineCost.h"
#include "llvm/Analysis/LoopInfo.h"
#include "llvm/Analysis/TargetLibraryInfo.h"
#include "llvm/Analysis/TargetTransformInfo.h"
#include "llvm/Transforms/Scalar/SCCP.h"
#include "llvm/Transforms/Utils/Cloning.h"
#include "llvm/Transforms/Utils/SizeOpts.h"
#include <cmath>
Include dependency graph for FunctionSpecialization.cpp:

Go to the source code of this file.

Classes

class  FunctionSpecializer
 

Macros

#define DEBUG_TYPE   "function-specialization"
 

Functions

 STATISTIC (NumFuncSpecialized, "Number of functions specialized")
 
static bool isConstant (const ValueLatticeElement &LV)
 
static bool isOverdefined (const ValueLatticeElement &LV)
 
static ConstantgetPromotableAlloca (AllocaInst *Alloca, CallInst *Call)
 
static ConstantgetConstantStackValue (CallInst *Call, Value *Val, SCCPSolver &Solver)
 
static void constantArgPropagation (SmallVectorImpl< Function * > &WorkList, Module &M, SCCPSolver &Solver)
 
static void removeSSACopy (Function &F)
 
static void removeSSACopy (Module &M)
 

Variables

static 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"))
 
static cl::opt< unsigned > FuncSpecializationMaxIters ("func-specialization-max-iters", cl::Hidden, cl::desc("The maximum number of iterations function specialization is run"), cl::init(1))
 
static cl::opt< unsigned > MaxConstantsThreshold ("func-specialization-max-constants", cl::Hidden, cl::desc("The maximum number of clones allowed for a single function " "specialization"), cl::init(3))
 
static 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))
 
static cl::opt< unsigned > AvgLoopIterationCount ("func-specialization-avg-iters-cost", cl::Hidden, cl::desc("Average loop iteration count cost"), cl::init(10))
 
static cl::opt< bool > SpecializeOnAddresses ("func-specialization-on-address", cl::init(false), cl::Hidden, cl::desc("Enable function specialization on the address of global values"))
 
static 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."))
 

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "function-specialization"

Definition at line 53 of file FunctionSpecialization.cpp.

Function Documentation

◆ constantArgPropagation()

static void constantArgPropagation ( SmallVectorImpl< Function * > &  WorkList,
Module M,
SCCPSolver Solver 
)
static

◆ getConstantStackValue()

static Constant* getConstantStackValue ( CallInst Call,
Value Val,
SCCPSolver Solver 
)
static

◆ getPromotableAlloca()

static Constant* getPromotableAlloca ( AllocaInst Alloca,
CallInst Call 
)
static

◆ isConstant()

static bool isConstant ( const ValueLatticeElement LV)
static

◆ isOverdefined()

static bool isOverdefined ( const ValueLatticeElement LV)
static

◆ removeSSACopy() [1/2]

static void removeSSACopy ( Function F)
static

Definition at line 213 of file FunctionSpecialization.cpp.

References BB, F, and llvm::make_early_inc_range().

Referenced by removeSSACopy(), and llvm::runFunctionSpecialization().

◆ removeSSACopy() [2/2]

static void removeSSACopy ( Module M)
static

Definition at line 227 of file FunctionSpecialization.cpp.

References F, M, and removeSSACopy().

◆ 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))
static

◆ 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."))
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"))
static

◆ FuncSpecializationMaxIters

cl::opt<unsigned> FuncSpecializationMaxIters("func-specialization-max-iters", cl::Hidden, cl::desc("The maximum number of iterations function specialization is run"), cl::init(1))
static

◆ MaxConstantsThreshold

cl::opt<unsigned> MaxConstantsThreshold("func-specialization-max-constants", 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))
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"))
static