LLVM 24.0.0git
TailRecursionElimination.cpp File Reference

Go to the source code of this file.

Macros

#define DEBUG_TYPE   "tailcallelim"

Functions

 STATISTIC (NumEliminated, "Number of tail calls removed")
 STATISTIC (NumRetDuped, "Number of return duplicated")
 STATISTIC (NumAccumAdded, "Number of accumulators introduced")
 STATISTIC (NumTREPreventedCold, "Number of tail calls/recursion eliminations prevented due to cold " "calling convention or attribute")
static bool shouldDisableTailCallsForCold (const CallBase *CB, const Function *Caller, const ProfileSummaryInfo *PSI, BlockFrequencyInfo *BFI)
static bool canTRE (Function &F)
 Scan the specified function for alloca instructions.
static bool markTails (Function &F, OptimizationRemarkEmitter *ORE, ProfileSummaryInfo *PSI, BlockFrequencyInfo *BFI)
static bool canMoveAboveCall (Instruction *I, CallInst *CI, AliasAnalysis *AA)
 Return true if it is safe to move the specified instruction from after the call to before the call, assuming that all instructions between the call and this instruction are movable.
static bool isUnaryAccumulatorRecurrence (Instruction *I)
static ConstantfindBaseCaseRetConstant (Function &F, Instruction *AccRecInstr)
static ConstantcanTransformAccumulatorRecursion (Instruction *I, CallInst *CI)
 INITIALIZE_PASS_BEGIN (TailCallElim, "tailcallelim", "Tail Call Elimination", false, false) INITIALIZE_PASS_END(TailCallElim

Variables

static cl::opt< boolDisableEntryCountRecompute ("tre-disable-entrycount-recompute", cl::init(false), cl::Hidden, cl::desc("Force disabling recomputing of function entry count, on " "successful tail recursion elimination."))
static cl::opt< boolDisableTailCallElimForColdCalls ("disable-tail-call-elim-for-cold-calls", cl::Hidden, cl::init(false), cl::desc("Disable tail call elimination and optimization for cold calls or " "in cold functions"))
 tailcallelim
Tail Call Elimination
Tail Call false

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "tailcallelim"

Definition at line 88 of file TailRecursionElimination.cpp.

Function Documentation

◆ canMoveAboveCall()

bool canMoveAboveCall ( Instruction * I,
CallInst * CI,
AliasAnalysis * AA )
static

Return true if it is safe to move the specified instruction from after the call to before the call, assuming that all instructions between the call and this instruction are movable.

Definition at line 394 of file TailRecursionElimination.cpp.

References DL, llvm::dyn_cast(), llvm::MemoryLocation::get(), I, II, llvm::is_contained(), llvm::isModSet(), llvm::isSafeToLoadUnconditionally(), and llvm::Instruction::mayHaveSideEffects().

◆ canTransformAccumulatorRecursion()

◆ canTRE()

bool canTRE ( Function & F)
static

Scan the specified function for alloca instructions.

If it contains any dynamic allocas, returns false.

Definition at line 146 of file TailRecursionElimination.cpp.

References llvm::all_of(), llvm::dyn_cast(), F, I, and instructions.

◆ findBaseCaseRetConstant()

Constant * findBaseCaseRetConstant ( Function & F,
Instruction * AccRecInstr )
static

Definition at line 465 of file TailRecursionElimination.cpp.

References C(), llvm::dyn_cast(), and F.

Referenced by canTransformAccumulatorRecursion().

◆ INITIALIZE_PASS_BEGIN()

INITIALIZE_PASS_BEGIN ( TailCallElim ,
"tailcallelim" ,
"Tail Call Elimination" ,
false ,
false  )

◆ isUnaryAccumulatorRecurrence()

bool isUnaryAccumulatorRecurrence ( Instruction * I)
static

Definition at line 437 of file TailRecursionElimination.cpp.

References I, and llvm::isa().

Referenced by canTransformAccumulatorRecursion().

◆ markTails()

◆ shouldDisableTailCallsForCold()

◆ STATISTIC() [1/4]

STATISTIC ( NumAccumAdded ,
"Number of accumulators introduced"  )

◆ STATISTIC() [2/4]

STATISTIC ( NumEliminated ,
"Number of tail calls removed"  )

◆ STATISTIC() [3/4]

STATISTIC ( NumRetDuped ,
"Number of return duplicated"  )

◆ STATISTIC() [4/4]

STATISTIC ( NumTREPreventedCold ,
"Number of tail calls/recursion eliminations prevented due to cold " "calling convention or attribute"  )

Variable Documentation

◆ DisableEntryCountRecompute

cl::opt< bool > DisableEntryCountRecompute("tre-disable-entrycount-recompute", cl::init(false), cl::Hidden, cl::desc("Force disabling recomputing of function entry count, on " "successful tail recursion elimination.")) ( "tre-disable-entrycount-recompute" ,
cl::init(false) ,
cl::Hidden ,
cl::desc("Force disabling recomputing of function entry count, on " "successful tail recursion elimination.")  )
static

◆ DisableTailCallElimForColdCalls

cl::opt< bool > DisableTailCallElimForColdCalls("disable-tail-call-elim-for-cold-calls", cl::Hidden, cl::init(false), cl::desc("Disable tail call elimination and optimization for cold calls or " "in cold functions")) ( "disable-tail-call-elim-for-cold-calls" ,
cl::Hidden ,
cl::init(false) ,
cl::desc("Disable tail call elimination and optimization for cold calls or " "in cold functions")  )
static

◆ Elimination

Tail Call Elimination

Definition at line 1145 of file TailRecursionElimination.cpp.

◆ false

Tail Call false

Definition at line 1146 of file TailRecursionElimination.cpp.

◆ tailcallelim

tailcallelim

Definition at line 1145 of file TailRecursionElimination.cpp.