-
Notifications
You must be signed in to change notification settings - Fork 13.3k
#[optimize(none)] should imply #[inline(never)] #136329
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Comments
cc #128657 Looks like it's being inlined in MIR |
This is surprisingly subtle. On the one hand, in LLVM IR every function marked
And IPO passes can lead to inlining-equivalent effects, as discussed (for example) in #73739. So I don't know if the proposed fix is actually a reliable way to achieve "call to |
…thlin `#[optimize(none)]` implies `#[inline(never)]` Fixes rust-lang#136329
…thlin `#[optimize(none)]` implies `#[inline(never)]` Fixes rust-lang#136329
…thlin `#[optimize(none)]` implies `#[inline(never)]` Fixes rust-lang#136329
…thlin `#[optimize(none)]` implies `#[inline(never)]` Fixes rust-lang#136329
…thlin `#[optimize(none)]` implies `#[inline(never)]` Fixes rust-lang#136329
Rollup merge of rust-lang#136358 - clubby789:opt-none-noinline, r=saethlin `#[optimize(none)]` implies `#[inline(never)]` Fixes rust-lang#136329
As I mentioned in #136358 (comment), it seems like the real problem is that the MIR optimizer isn't correctly obeying |
I compiled this code with
-C opt-level=3
:I expected the assembly to either contain the number 123 somewhere, or produce a warning or error. Instead, I got this assembly:
Godbolt link
Adding
#[inline(never)]
tofoo()
gives the expected behavior. Godbolt linkAssembly after adding `#[inline(never)]`
The
#[optimize(none)]
attribute was recently added in #128657. And according to the discussion in the tracking issue at #54882, it seems like the main motivation of#[optimize(none)]
is for debugging.In this case, it seems like the compiler is inlining
foo()
intobar()
and then proceeding to optimizebar()
. This seems counterproductive for debugging. Therefore, I think that#[optimize(none)]
should imply#[inline(never)]
. Or if that is "too magic", then the compiler should at least produce a warning or error.Meta
Reproduces on godbolt with
rustc 1.86.0-nightly (ae5de6c75 2025-01-29)
The text was updated successfully, but these errors were encountered: