4.20 Inline functions

Inline functions offer a trade-off between code size and performance. By default, the compiler decides for itself whether to inline code or not.

As a general rule, when compiling with -Ospace, the compiler makes sensible decisions about inlining with a view to producing code of minimal size. This is because code size for embedded systems is of fundamental importance. When compiling with -Otime, the compiler inlines in most cases, but still avoids large code growth. On NEON, calls to non-inline functions from within a loop inhibit vectorization, and require explicit indication that they are to be inlined for vectorization to take place.
In most circumstances, the decision to inline a particular function is best left to the compiler. However, you can give the compiler a hint that a function is required to be inlined by using the appropriate inline keyword.
Functions that are qualified with the __inline, inline, or __forceinline keywords are called inline functions. In C++, member functions that are defined inside a class, struct, or union, are also inline functions.
The compiler also offers a range of other facilities for modifying its behavior with respect to inlining. There are several factors you must take into account when deciding whether to use these facilities, or more generally, whether to inline a function at all.
The linker is able to apply some degree of function inlining to functions that are very short.
Related concepts
4.21 Compiler decisions on function inlining
4.22 Automatic function inlining and static functions
4.23 Inline functions and removal of unused out-of-line functions at link time
4.24 Automatic function inlining and multifile compilation
4.26 Compiler modes and inline functions
4.27 Inline functions in C++ and C90 mode
4.28 Inline functions in C99 mode
4.29 Inline functions and debugging
Related reference
4.25 Restriction on overriding compiler decisions about function inlining
7.11 --autoinline, --no_autoinline
7.66 --forceinline
9.6 __forceinline
9.8 __inline
7.87 --inline, --no_inline
Related information
--inline, --no_inline linker option
Non-ConfidentialPDF file icon PDF versionARM DUI0375F
Copyright © 2007, 2008, 2011, 2012, 2014 ARM. All rights reserved.