-
Notifications
You must be signed in to change notification settings - Fork 109
Description
From rust-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 attribute alwaysinline in unoptimized builds. LLVM will inline functions with alwaysinline 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 produce different 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.