-
Notifications
You must be signed in to change notification settings - Fork 13k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#[optimize(none)] should imply #[inline(never)] #136329
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
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: