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 (NumSpecsCreated, "Number of specializations created")
 
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< boolForceSpecialization ("force-specialization", cl::init(false), cl::Hidden, cl::desc("Force function specialization for every call site with a constant " "argument"))
 
static cl::opt< unsignedMaxClones ("funcspec-max-clones", cl::init(3), cl::Hidden, cl::desc("The maximum number of clones allowed for a single function " "specialization"))
 
static cl::opt< unsignedMinFunctionSize ("funcspec-min-function-size", cl::init(100), cl::Hidden, cl::desc("Don't specialize functions that have less than this number of " "instructions"))
 
static cl::opt< unsignedAvgLoopIters ("funcspec-avg-loop-iters", cl::init(10), cl::Hidden, cl::desc("Average loop iteration count"))
 
static cl::opt< boolSpecializeOnAddress ("funcspec-on-address", cl::init(false), cl::Hidden, cl::desc("Enable function specialization on the address of global values"))
 
static cl::opt< boolSpecializeLiteralConstant ("funcspec-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 402 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 218 of file FunctionSpecialization.cpp.

References F, and llvm::make_early_inc_range().

Referenced by cloneCandidateFunction().

◆ STATISTIC()

STATISTIC ( NumSpecsCreated  ,
"Number of specializations created"   
)

Variable Documentation

◆ AvgLoopIters

cl::opt< unsigned > AvgLoopIters("funcspec-avg-loop-iters", cl::init(10), cl::Hidden, cl::desc( "Average loop iteration count")) ( "funcspec-avg-loop-iters"  ,
cl::init(10)  ,
cl::Hidden  ,
cl::desc( "Average loop iteration count")   
)
static

Referenced by getUserBonus().

◆ ForceSpecialization

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

◆ MaxClones

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

◆ MinFunctionSize

cl::opt< unsigned > MinFunctionSize("funcspec-min-function-size", cl::init(100), cl::Hidden, cl::desc( "Don't specialize functions that have less than this number of " "instructions")) ( "funcspec-min-function-size"  ,
cl::init(100)  ,
cl::Hidden  ,
cl::desc( "Don't specialize functions that have less than this number of " "instructions")   
)
static

◆ SpecializeLiteralConstant

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

◆ SpecializeOnAddress

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