LLVM  16.0.0git
Macros | Typedefs | Functions | Variables
FunctionSpecialization.cpp File Reference
#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.

Macros

#define DEBUG_TYPE   "function-specialization"
 

Typedefs

using FuncList = SmallVectorImpl< Function * >
 
using CallArgBinding = std::pair< CallBase *, Constant * >
 
using CallSpecBinding = std::pair< CallBase *, SpecializationInfo >
 
using SpecializationMap = SmallMapVector< CallBase *, SpecializationInfo, 8 >
 

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 (FuncList &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 > MaxClonesThreshold ("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< 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 64 of file FunctionSpecialization.cpp.

Typedef Documentation

◆ CallArgBinding

using CallArgBinding = std::pair<CallBase *, Constant *>

Definition at line 121 of file FunctionSpecialization.cpp.

◆ CallSpecBinding

using CallSpecBinding = std::pair<CallBase *, SpecializationInfo>

Definition at line 122 of file FunctionSpecialization.cpp.

◆ FuncList

Definition at line 120 of file FunctionSpecialization.cpp.

◆ SpecializationMap

using SpecializationMap = SmallMapVector<CallBase *, SpecializationInfo, 8>

Definition at line 125 of file FunctionSpecialization.cpp.

Function Documentation

◆ constantArgPropagation()

static void constantArgPropagation ( FuncList 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 249 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 263 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

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