Compiler Function Inlining
This cluster focuses on discussions about function inlining by compilers, its impact on performance by reducing call overhead and enabling further optimizations, and factors influencing when inlining happens or doesn't.
Activity Over Time
Top Contributors
Keywords
Sample Comments
Only if the function is inlined, at least it seems that way from experimenting on godbolt.org.
This is like a compiler inlining code for faster performance, with exactly the same reasons
Not explicitly, but because hot functions get inlined and inlining enables optimizations, something roughly similar does happen.
Yes, especially if callees are inlined.
Function calls do none of those things if they’re inlined, and compilers have been able to inline functions for a long time. Perhaps this code is even older than that.
The effect you're describing can happen to any inlined function.
Why can inlining functions cause disasters? Just instruction cache misses, or other things as well?
Thanks for the link to the issue. I was wondering why the post was talking about function call overhead instead of being able to inline it.
If the compiler doesn't inline something, you generally have no way of knowing if the reason was had good or bad.
The compiler can inline things for you. There is a way to specify that a function should be inlined: inline.https://en.cppreference.com/w/cpp/language/inlineIf this specifier is used, then when your inlined function is compiled there will be no function call, just the inlined code.This is just a hint for the compiler, though. The compiler can ignore