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 ScalarOptions &Opts, 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 returnsCurrentFrameAddress (const IntrinsicInst *II)
 Returns true if II returns an address in the current function's frame.
static bool markTails (const ScalarOptions &Opts, 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)
 INITIALIZE_PASS_BEGIN (TailCallElim, "tailcallelim", "Tail Call Elimination", false, false) INITIALIZE_PASS_END(TailCallElim

Variables

 tailcallelim
Tail Call Elimination
Tail Call false

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "tailcallelim"

Definition at line 92 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 420 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().

◆ canTRE()

bool canTRE ( Function & F)
static

Scan the specified function for alloca instructions.

If it contains any dynamic allocas, returns false.

Definition at line 141 of file TailRecursionElimination.cpp.

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

◆ INITIALIZE_PASS_BEGIN()

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

◆ isUnaryAccumulatorRecurrence()

bool isUnaryAccumulatorRecurrence ( Instruction * I)
static

Definition at line 463 of file TailRecursionElimination.cpp.

References I, and llvm::isa().

◆ markTails()

◆ returnsCurrentFrameAddress()

bool returnsCurrentFrameAddress ( const IntrinsicInst * II)
static

Returns true if II returns an address in the current function's frame.

Definition at line 245 of file TailRecursionElimination.cpp.

References llvm::cast(), and II.

Referenced by 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

◆ Elimination

Tail Call Elimination

Definition at line 1218 of file TailRecursionElimination.cpp.

◆ false

Tail Call false

Definition at line 1219 of file TailRecursionElimination.cpp.

◆ tailcallelim

tailcallelim

Definition at line 1218 of file TailRecursionElimination.cpp.