LLVM API Documentation

TailRecursionElimination.cpp File Reference

#include "llvm/Transforms/Scalar.h"
#include "llvm/Constants.h"
#include "llvm/DerivedTypes.h"
#include "llvm/Function.h"
#include "llvm/Instructions.h"
#include "llvm/Pass.h"
#include "llvm/Support/CFG.h"
#include "llvm/ADT/Statistic.h"

Include dependency graph for TailRecursionElimination.cpp:

Go to the source code of this file.

Functions

FunctionPass * llvm::createTailCallEliminationPass ()
static bool AllocaMightEscapeToCalls (AllocaInst *AI)
static bool CheckForEscapingAllocas (BasicBlock *BB, bool &CannotTCETailMarkedCall)
static bool isDynamicConstant (Value *V, CallInst *CI)
static Value * getCommonReturnValue (ReturnInst *TheRI, CallInst *CI)

Variables

Statistic NumEliminated ("tailcallelim","Number of tail calls removed")
Statistic NumAccumAdded ("tailcallelim","Number of accumulators introduced")
RegisterOpt< TailCallElim > X ("tailcallelim","Tail Call Elimination")


Function Documentation

static bool AllocaMightEscapeToCalls ( AllocaInst *  AI  )  [static]

AllocaMightEscapeToCalls - Return true if this alloca may be accessed by callees of this function. We only do very simple analysis right now, this could be expanded in the future to use mod/ref information for particular call sites if desired.

Definition at line 91 of file TailRecursionElimination.cpp.

Referenced by CheckForEscapingAllocas().

static bool CheckForEscapingAllocas ( BasicBlock *  BB,
bool &  CannotTCETailMarkedCall 
) [static]

FunctionContainsAllocas - Scan the specified basic block for alloca instructions. If it contains any that might be accessed by calls, return true.

Definition at line 99 of file TailRecursionElimination.cpp.

References AI, AllocaMightEscapeToCalls(), BB, llvm::BasicBlock::begin(), E, llvm::BasicBlock::end(), llvm::Function::front(), llvm::AllocationInst::getArraySize(), llvm::BasicBlock::getParent(), and I.

static Value* getCommonReturnValue ( ReturnInst *  TheRI,
CallInst *  CI 
) [static]

Definition at line 235 of file TailRecursionElimination.cpp.

References E, F, llvm::Constant::getOperand(), llvm::BasicBlock::getParent(), llvm::Instruction::getParent(), and isDynamicConstant().

static bool isDynamicConstant ( Value *  V,
CallInst *  CI 
) [static]

Definition at line 209 of file TailRecursionElimination.cpp.

References AI, F, llvm::User::getOperand(), llvm::BasicBlock::getParent(), llvm::Instruction::getParent(), and V.

Referenced by getCommonReturnValue().


Variable Documentation

Statistic NumAccumAdded("tailcallelim","Number of accumulators introduced") [static]

Statistic NumEliminated("tailcallelim","Number of tail calls removed") [static]

RegisterOpt<TailCallElim> X("tailcallelim","Tail Call Elimination") [static]