Link register


A link register is a special-purpose register which holds the address to return to when a function call completes. This is more efficient than the more traditional scheme of storing return addressed on a call stack, sometimes called a machine stack. The link register does not require the writes and reads of the memory containing the stack which can save a considerable percentage of execution time with repeated calls of small subroutines.
A link register is used in many instruction set architectures, such as PowerPC, ARM, and PA-RISC. Other architectures have a register with the same purpose but another name.
The usage of a link register allows for faster calls to leaf subroutines. When the subroutine is non-leaf, passing the return address in a register can still result in generation of more efficient code for thunks, e.g. for a function whose sole purpose is to call another function with arguments rearranged in some way. Other subroutines can benefit from the use of link register because it can be saved in a batch with other callee-used registers—e.g. an ARM subroutine pushes registers 4-7 along with the link register, LR, by the single instruction
STMDB SP!, pipelining all memory writes required.