- Notifications
You must be signed in to change notification settings - Fork105
Description
Fromrust-lang/rfcs#3711 (comment)
My original finding is this perf report:rust-lang/rust#121417 (comment) which is based on a compiler diff that just makes#[inline(always)] not emit the LLVM attributealwaysinline in unoptimized builds. LLVM will inline functions withalwaysinline even in unoptimized builds (I don't know if rustc sets up some specific pass list to make this happen).
And in optimized builds the always-inliner runs first, so#[inline(always)] on a function that will be inlined anyway may produce better optimizations. I believe we have examples of compiler performance fluctuations that certainly indicate this effect can producedifferent optimizations, which are sometimes better.
So I think what you really want is a cfg or a feature like you have in regex; the tripping hazard is that the compiler doesn't provide a way to change your attributes based on the optimization level.