Partial inlining

15 points by fanf


mqudsi

Article is light on the specifics of this, how and when the compiler does it/chooses to do it, and how you can induce the compiler to do this for you.

If you’re using an llvm-based compiler, you can influence this with judicious use of llvm function attributes. In rust, I use a mix of #[inline_always] on the outer function, (nested) function/lambda declarations with #[inline(never)] or #[cold] as needed (llvm doesn’t use coldcc abi to call these, so it can be abused to do what you need, especially with rust’s lack of likely/unlikely hints in stable, which will probably never change).

osa1

I have more examples of this in my blog post if you're interested.