Matt Godbolt's blog
15 hours ago
- Inlining is a fundamental compiler optimization that copies function bodies into call sites, enabling further optimizations like constant propagation and dead code elimination.
- Inlining can reduce call overhead but its primary benefit is allowing the compiler to specialize code at the inline site, such as simplifying branches based on known constants.
- Drawbacks of inlining include increased code size, which can strain instruction caches, and complex heuristic-driven decisions that vary between compilers.
- Inlining requires visibility of the function definition; declaring functions without bodies prevents inlining, though link-time optimization (LTO) can help across translation units.
- The effectiveness of inlining depends on context, with nuanced trade-offs for branch prediction and performance that compilers must guess at without runtime information.