diff --git a/llvm/include/llvm/Transforms/Scalar.h b/llvm/include/llvm/Transforms/Scalar.h index b240f58dc83c..796d57b578a5 100644 --- a/llvm/include/llvm/Transforms/Scalar.h +++ b/llvm/include/llvm/Transforms/Scalar.h @@ -241,6 +241,13 @@ void SplitCriticalEdge(TerminatorInst *TI, unsigned SuccNum, Pass *P = 0); Pass *createLoopPreheaderInsertionPass(); extern const PassInfo *LoopPreheadersID; +//===----------------------------------------------------------------------===// +// +// This pass eliminates call instructions to the current function which occur +// immediately before return instructions. +// +FunctionPass *createTailCallEliminationPass(); + //===----------------------------------------------------------------------===// // This pass convert malloc and free instructions to %malloc & %free function diff --git a/llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp b/llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp index f0c5ba73b917..3945af3db75c 100644 --- a/llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp +++ b/llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp @@ -19,6 +19,7 @@ // //===----------------------------------------------------------------------===// +#include "llvm/Transforms/Scalar.h" #include "llvm/DerivedTypes.h" #include "llvm/Function.h" #include "llvm/Instructions.h" @@ -34,6 +35,8 @@ namespace { RegisterOpt X("tailcallelim", "Tail Call Elimination"); } +FunctionPass *createTailCallEliminationPass() { return new TailCallElim(); } + bool TailCallElim::runOnFunction(Function &F) { // If this function is a varargs function, we won't be able to PHI the args