-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
Don't codegen dead code #104860
Don't codegen dead code #104860
Conversation
r? @davidtwco (rustbot has picked a reviewer for you, use r? to override) |
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
⌛ Trying commit 87ade9eb4e10ffec341aad7dc47bcac2b5c5256d with merge e3cd8ee648dc72d29df7fcfe928b572f5523d06a... |
💔 Test failed - checks-actions |
87ade9e
to
4219733
Compare
This is the internal-facing portion of rust-lang#103356; it should not be user-visible in any way.
4219733
to
d64517d
Compare
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
⌛ Trying commit d64517d with merge 50dbcf2ac6a27d114f1a1d61c861b0c986127002... |
This comment has been minimized.
This comment has been minimized.
if !live_symbols.contains(&def_id) && !self.tcx.sess.link_dead_code() { | ||
// This is dead code; ignore it. | ||
return; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why would this condition even be true when not compiling in incr comp mode? Also won't this remove all global_asm!() usages?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why would this condition even happen when not compiling in incr comp mode?
I've observed this to happen with every unreachable item.
rust/compiler/rustc_monomorphize/src/collector.rs
Lines 376 to 379 in d64517d
let crate_items = tcx.hir_crate_items(()); | |
for id in crate_items.items() { | |
collector.process_item(id); |
I hadn't considered global_asm, I can special-case it here if you think it's necessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Global_asm mut never be removed. Also please make this early exit conditional on the lazy collection mode. The eager collection mode doesn't omit anything on purpose to improve incr comp object file reuse.
The job Click to see the possible cause of the failure (guessed by this bot)
|
Does this affect code coverage of the test suite? |
☀️ Try build successful - checks-actions |
This comment has been minimized.
This comment has been minimized.
Finished benchmarking commit (50dbcf2ac6a27d114f1a1d61c861b0c986127002): comparison URL. Overall result: ❌ regressions - ACTION NEEDEDBenchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. While you can manually mark this PR as fit for rollup, we strongly recommend not doing so since this PR may lead to changes in compiler perf. Next Steps: If you can justify the regressions found in this try perf run, please indicate this with @bors rollup=never Instruction countThis is a highly reliable metric that was used to determine the overall result at the top of this comment.
Max RSS (memory usage)ResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
CyclesResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
|
In the existing implementation, dead code is already omitted based on the results of reachability pass in |
Ah, thanks! looks like I was putting the |
This would have avoided a bug in rust-lang#104860. In practice this shouldn't matter since nothing uses the query other than the `dead_code` lint, but this isn't documented as an internal-only query so it seems nice for it to be accurate. I think for `dead_code` it doesn't matter because the relevant code is generated by `rustc_builtin_macros` and isn't linted.
…miasko Mark `proc_macro_decls_static` as always used This would have avoided a bug in rust-lang#104860. In practice this shouldn't matter since nothing uses the query other than the `dead_code` lint, but this isn't documented as an internal-only query so it seems nice for it to be accurate. I think for `dead_code` it doesn't matter because the relevant code is generated by `rustc_builtin_macros` and isn't linted. I think `@tmiasko` or `@bjorn3` would be a good reviewer? r? `@tmiasko`
This is the internal-facing portion of #103356; it should not be user-visible in any way, since we already stripped dead code at the linker level.
Fixes #104858.