41 ms·
For inlining in general, I think the wikipedia article is good https://en.wikipedia.org/wiki/Inline_expansion https://en.wikipedia.org/wiki/Inline_expansion. T
by xavxav 4y ago
For inlining in general, I think the wikipedia article is good https://en.wikipedia.org/wiki/Inline_expansion https://en.wikipedia.org/wiki/Inline_expansion.
The reason it's so important is that inlining synergises with other optimizations, its often run before or after other passes like constant propagation. Consider something like:
fn add(x : usize, y : usize) -> usize { x + y }
fn main() {
add(5, 1)
}
Without inlining we can't easily optimize the code of `main`. However, if we inline `add` into main, constant propagation will then directly see `5 + 1` and optimize that into `6`.
- weinzierl 4y agoI understand, thank you!