Keil™, An ARM® Company

RealView Compiler User's Guide

How the compiler decides to inline

4.4.1. How the compiler decides to inline

When inlining is enabled, the compiler uses a complex decision tree to decide when a function is inlined. The compiler uses the following simplified algorithm to determine if a function is to be inlined:

  1. If the function is qualified with __forceinline, then the function is inlined if it is possible to do so.

  2. If the function is qualified with __inline and the option --forceinline is selected, then the function is inlined if it is possible to do so.

    If the function is qualified with __inline and the option --forceinline is not selected, then the function is inlined if it is sensible to do so.

  3. If the optimization level is -O2 or higher, or --autoinline is selected, then the function is inlined if it is sensible to inline the function, and it is possible to do so.

When deciding if it is practical to inline a function, the compiler takes into account several other criteria, including whether you select ‑Ospace or ‑Otime. Select ‑Otime to increase the likelihood that a function is inlined. See When is it practical for the compiler to inline? for more information.

You cannot override any decision made by the compiler about when it is practical to inline a function. For example, you cannot force a function to be inlined if the compiler thinks it is not sensible.

Copyright © 2007 ARM Limited. All rights reserved.ARM DUI 0375A