LLVM 20.0.0git
Macros | Functions | Variables
TailRecursionElimination.cpp File Reference
#include "llvm/Transforms/Scalar/TailRecursionElimination.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/Analysis/DomTreeUpdater.h"
#include "llvm/Analysis/GlobalsModRef.h"
#include "llvm/Analysis/InstructionSimplify.h"
#include "llvm/Analysis/Loads.h"
#include "llvm/Analysis/OptimizationRemarkEmitter.h"
#include "llvm/Analysis/PostDominators.h"
#include "llvm/Analysis/TargetTransformInfo.h"
#include "llvm/Analysis/ValueTracking.h"
#include "llvm/IR/CFG.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/DiagnosticInfo.h"
#include "llvm/IR/Dominators.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/IRBuilder.h"
#include "llvm/IR/InstIterator.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/IntrinsicInst.h"
#include "llvm/IR/Module.h"
#include "llvm/InitializePasses.h"
#include "llvm/Pass.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Transforms/Scalar.h"
#include "llvm/Transforms/Utils/BasicBlockUtils.h"

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")
 
static bool canTRE (Function &F)
 Scan the specified function for alloca instructions.
 
static bool markTails (Function &F, OptimizationRemarkEmitter *ORE)
 
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 canTransformAccumulatorRecursion (Instruction *I, CallInst *CI)
 
static InstructionfirstNonDbg (BasicBlock::iterator 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 84 of file TailRecursionElimination.cpp.

Function Documentation

◆ canMoveAboveCall()

static 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 337 of file TailRecursionElimination.cpp.

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

◆ canTransformAccumulatorRecursion()

static bool canTransformAccumulatorRecursion ( Instruction I,
CallInst CI 
)
static

◆ canTRE()

static bool canTRE ( Function F)
static

Scan the specified function for alloca instructions.

If it contains any dynamic allocas, returns false.

Definition at line 92 of file TailRecursionElimination.cpp.

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

◆ firstNonDbg()

static Instruction * firstNonDbg ( BasicBlock::iterator  I)
static

Definition at line 399 of file TailRecursionElimination.cpp.

References I.

◆ INITIALIZE_PASS_BEGIN()

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

◆ markTails()

static bool markTails ( Function F,
OptimizationRemarkEmitter ORE 
)
static

◆ STATISTIC() [1/3]

STATISTIC ( NumAccumAdded  ,
"Number of accumulators introduced"   
)

◆ STATISTIC() [2/3]

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

◆ STATISTIC() [3/3]

STATISTIC ( NumRetDuped  ,
"Number of return duplicated"   
)

Variable Documentation

◆ Elimination

Tail Call Elimination

Definition at line 940 of file TailRecursionElimination.cpp.

◆ false

Tail Call false

Definition at line 941 of file TailRecursionElimination.cpp.

◆ tailcallelim

tailcallelim

Definition at line 940 of file TailRecursionElimination.cpp.