There are two several separate decisions that the compiler makes regarding a function:
- whether a specific function call is built in;
- Is there a non-built-in version of the function?
The first is determined by the compiler in each case, if insertion is possible at this point. This will not be possible if the function is virtual or called through the function pointer, and it cannot determine at compile time which function to call. This is not possible if the definition is not available to the compiler, possibly because it is defined in a different translation unit, and the compiler does not perform "optimization of the entire program". The decision may or may not be influenced by whether the inline function is declared, and other factors, such as the size and frequency of its call.
The second depends on whether a non-embedded version is required. This will be required if any call is not attached to it. It will also be (according to your quote) if something needs a function address, since then it must have an address. This can happen either directly (for example, by assigning an address to a function pointer), or indirectly (for example, virtual functions will need their address stored somewhere to search at runtime according to the dynamic type of the object).
The existence of a non-built-in version will not prevent any particular function call from being built-in, although it is possible that this may affect the decision of the compiler, especially if it is configured to optimize for code size.
To summarize, your quote is simplified and not entirely accurate; the compiler can still "perform inlining", if the address is done, it simply cannot omit the non-embedded version.
source share