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
Rust beta/nightly optimises everything away #5782
Comments
Our flags are:
and with the filters off we only see:
so...not sure what's going on here! |
if i add -C link-dead-code=yes it stays setting inline-threshold=0 didn't do it (it's not an inlining thing) |
As of recently, rustc started to automatically add |
Your can pass But there's no real fix, because rustc internals don't permit one currently. The problem is that rustc computes symbol visibility before doing its own pre-LLVM optimizations, so the visibility needs to be conservative enough so the MIR inliner doesn't make symbols public that weren't before. So "cross-crate-inlinable" means that the function is both lazily lowered (which means the assembly disappears) and the function becomes possible for the MIR inliner to inline. Adding #[no_mangle] or #[inline(never)] does cause the function to be lowered in the current crate, but causes the same knock-on effect, where calls to that function stop being inlined. In general my advice is to set -Zcross-crate-inline-threshold=0 or =never. never is a more recent option and prevents cost=0 functions from getting the cross-crate codegen strategy. And then wait for us to fix the inliner visibility issue, it is a bug and we should get to it eventually. |
Thanks everyone! |
I think i'm going to close this as "working as intended" ... it's unfortunate but we can't go putting too many byzantine surprising compiler options into the compiler to work around things the compiler's trying hard to do for us... |
FWIW, this property has been surprising to a lot of people at this point; it wouldn't hurt to have a note (in the UI? I swear I saw the guidance to add |
Could change the default example https://github.com/compiler-explorer/compiler-explorer/blob/main/examples/rust/default.rs |
I wonder if it would make sense for CE to provide a small helper macro for Rust code, eg #[codegen]
fn foo() {} that expands to just #[inline(never)]
pub foo() {} Probably not worth the effort though, as it hard to predict what else might break in the future, and if fixing those case can be done with a attribute |
Not sure why but:
https://godbolt.org/z/71erEzGT6 optimizes to nothing, but removing the
-O
generates code as expected.Not sure if this is a new thing where unused code is deleted that we don't understand?
The text was updated successfully, but these errors were encountered: