IT lexicon › Programming › Leaf function

Leaf function

Programming På svenska → Updated: 2026-11-05

A function that calls no other function, and can therefore skip most of the bookkeeping a call normally requires.

The name comes from the call graph, where such functions sit at the tips of the branches. Since no nested call can clobber anything, a leaf function often needs no stack frame of its own. On ARM and RISC-V the return address simply stays in the link register instead of being saved to the stack, and on System V x86-64 locals can live in the red zone below the stack pointer without the pointer ever moving.

The Microsoft x64 ABI throws in one more perk: a leaf function that leaves the stack pointer and callee-saved registers alone needs no unwind data in the binary. It is also one reason inlining pays off more than it appears to — once the small calls inside a function are inlined, the function itself may become a leaf.

← Back to the lexicon