llir-opt  0.0.1
Low-Level Post-Link Optimiser for OCaml and C
Public Member Functions | Static Public Attributes | List of all members
TailRecElimPass Class Referencefinal

#include <passes/tail_rec_elim.h>

Inheritance diagram for TailRecElimPass:
Inheritance graph
[legend]
Collaboration diagram for TailRecElimPass:
Collaboration graph
[legend]

Public Member Functions

 TailRecElimPass (PassManager *passManager)
 Initialises the pass.
 
bool Run (Prog &prog) override
 Runs the pass.
 
const char * GetPassName () const override
 Returns the name of the pass.
 
- Public Member Functions inherited from Pass
 Pass (PassManager *passManager)
 
virtual ~Pass ()
 
template<typename T >
T * getAnalysis ()
 Returns an available analysis.
 

Static Public Attributes

static const char * kPassID = "tail-rec-elim"
 Pass identifier.
 

Additional Inherited Members

- Protected Member Functions inherited from Pass
const PassConfigGetConfig () const
 Returns a reference to the configuration.
 
const TargetGetTarget () const
 Returns a reference to the target.
 
- Protected Attributes inherited from Pass
PassManagerpassManager_
 Pass manager scheduling this pass.
 

Detailed Description

Tail recursion-to-iteration pass.

Turns tail-recursive methods into iterative loops, enabling our optimiser and LLVM to further improve them. The lowering of loops in OCaml is not particularly effective, but its optimiser and code generator handle tail recursion well. The opposite is true of LLVM and LLIR, which are based on SSA: most optimisation passes target loops and prologue/epilogue insertion is not optimal on tail-recursive methods. In addition, transforming tail recursion into a loop aids register allocation, since arguments are no longer fixed to specific registers at the point of the backwards jump.


The documentation for this class was generated from the following files: