Leaf routine
A leaf routine, leaf subroutine, leaf function, or leaf procedure is a function that does not in turn call another function. Some compilers can apply special program optimizations to leaf routines to make them more efficient, such as the use of link registers to avoid having to push the return address on the stack, or not allocating a register window on CPU architectures descended from Berkeley RISC. The term "leaf" refers to their position as leaf nodes in the call graph of the program. Usually, most non-leaf routines call more than one other function. When this is the case, the majority of function calls in the call graph are calls to leaf routines, because a binary tree has more leaf nodes than non-leaf nodes (assuming that all non-leaf nodes have two children). Consequently, the efficiency of calls to leaf routines often has a significant effect on the efficiency of the whole program.
A leaf routine, leaf subroutine, leaf function, or leaf procedure is a function that does not in turn call another function. Some compilers can apply special program optimizations to leaf routines to make them more efficient, such as the use of link registers to avoid having to push the return address on the stack, or not allocating a register window on CPU architectures descended from Berkeley RISC. The term "leaf" refers to their position as leaf nodes in the call graph of the program. Usually, most non-leaf routines call more than one other function. When this is the case, the majority of function calls in the call graph are calls to leaf routines, because a binary tree has more leaf nodes than non-leaf nodes (assuming that all non-leaf nodes have two children). Consequently, the efficiency of calls to leaf routines often has a significant effect on the efficiency of the whole program.
References
No reference rows published for this article.
Cite this article
MLA
"Leaf routine." encyclopegia.org, 2025, https://encyclopegia.org/wiki/leaf-routine. Accessed 24 November 2026.
Chicago
"Leaf routine." encyclopegia.org. Accessed November 24, 2026. https://encyclopegia.org/wiki/leaf-routine.
APA
encyclopegia.org. (2025). Leaf routine. Retrieved November 24, 2026, from https://encyclopegia.org/wiki/leaf-routine
Accessed November 24, 2026 · CC BY-SA 4.0 · citation page · JSON