ARM Technical Support Knowledge Articles

What is a leaf function?

Applies to: DS-5, RealView Development Suite (RVDS)


A 'leaf function' is the classification given to a function at the end of a call tree.

                     /  \
                    /    \  
      f1          f5     f8
      /\         /  \     | 
     /  \       /    \    |
   f2    f3    f6    f7  f9   

In the diagram above, functions f2, f3, f6, f7 and f9 are leaf functions. These functions are called by functions f1, f5 and f8 respectively, but these functions do not make any calls themselves.

The ARM Application Binary Interface mandates that the stack must be 8-byte aligned at all "externally visible boundaries", i.e. when one function calls another. By definition, a leaf function makes no calls to other functions, and so does not need to maintain this 8-byte stack alignment.

To help you remember what a leaf function is, picture an image of a deciduous tree. There are no more branches or twigs that stem from a leaf. The leaf is the last item in the chain.

Article last edited on: 2011-09-01 19:27:41

Rate this article

Disagree? Move your mouse over the bar and click

Did you find this article helpful? Yes No

How can we improve this article?

Link to this article
Copyright © 2011 ARM Limited. All rights reserved. External (Open), Non-Confidential