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/ConstantFolding.h"
#include "llvm/Analysis/InlineCost.h"
#include "llvm/Analysis/InstructionSimplify.h"
#include "llvm/Analysis/TargetTransformInfo.h"
#include "llvm/Analysis/ValueLattice.h"
#include "llvm/Analysis/ValueLatticeUtils.h"
#include "llvm/Analysis/ValueTracking.h"
#include "llvm/IR/ConstantFold.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>

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 Cost estimateBasicBlocks (SmallVectorImpl< BasicBlock * > &WorkList, ConstMap &KnownConstants, SCCPSolver &Solver, BlockFrequencyInfo &BFI, TargetTransformInfo &TTI)
 
static ConstantfindConstantFor (Value *V, ConstMap &KnownConstants)
 
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.
 

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< unsignedBlockFreqMultiplier ("funcspec-block-freq-multiplier", cl::init(8), cl::Hidden, cl::desc("Multiplier to scale block frequency of user instructions during " "specialization bonus estimation"))
 
static cl::opt< unsignedMinEntryFreq ("funcspec-min-entry-freq", cl::init(450), cl::Hidden, cl::desc("Do not specialize functions with entry block frequency lower than " "this value"))
 
static cl::opt< unsignedMinScore ("funcspec-min-score", cl::init(2), cl::Hidden, cl::desc("Do not specialize functions with score lower than this value " "(the ratio of specialization bonus over specialization cost)"))
 
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< 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(true), 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 68 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 646 of file FunctionSpecialization.cpp.

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

◆ estimateBasicBlocks()

static Cost estimateBasicBlocks ( SmallVectorImpl< BasicBlock * > &  WorkList,
ConstMap KnownConstants,
SCCPSolver Solver,
BlockFrequencyInfo BFI,
TargetTransformInfo TTI 
)
static

◆ findConstantFor()

static Constant * findConstantFor ( Value V,
ConstMap KnownConstants 
)
static

◆ removeSSACopy()

static void removeSSACopy ( Function F)
static

Definition at line 439 of file FunctionSpecialization.cpp.

References F, and llvm::make_early_inc_range().

Referenced by cloneCandidateFunction().

◆ STATISTIC()

STATISTIC ( NumSpecsCreated  ,
"Number of specializations created"   
)

Variable Documentation

◆ BlockFreqMultiplier

cl::opt< unsigned > BlockFreqMultiplier("funcspec-block-freq-multiplier", cl::init(8), cl::Hidden, cl::desc( "Multiplier to scale block frequency of user instructions during " "specialization bonus estimation")) ( "funcspec-block-freq-multiplier"  ,
cl::init(8)  ,
cl::Hidden  ,
cl::desc( "Multiplier to scale block frequency of user instructions during " "specialization bonus estimation")   
)
static

◆ 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

◆ MinEntryFreq

cl::opt< unsigned > MinEntryFreq("funcspec-min-entry-freq", cl::init(450), cl::Hidden, cl::desc( "Do not specialize functions with entry block frequency lower than " "this value")) ( "funcspec-min-entry-freq"  ,
cl::init(450)  ,
cl::Hidden  ,
cl::desc( "Do not specialize functions with entry block frequency lower than " "this value")   
)
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

◆ MinScore

cl::opt< unsigned > MinScore("funcspec-min-score", cl::init(2), cl::Hidden, cl::desc( "Do not specialize functions with score lower than this value " "(the ratio of specialization bonus over specialization cost)")) ( "funcspec-min-score"  ,
cl::init(2)  ,
cl::Hidden  ,
cl::desc( "Do not specialize functions with score lower than this value " "(the ratio of specialization bonus over specialization cost)")   
)
static

◆ SpecializeLiteralConstant

cl::opt< bool > SpecializeLiteralConstant("funcspec-for-literal-constant", cl::init(true), cl::Hidden, cl::desc( "Enable specialization of functions that take a literal constant as an " "argument")) ( "funcspec-for-literal-constant"  ,
cl::init(true ,
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