-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
coverage: Re-enable UnreachablePropagation
for coverage builds
#122860
Conversation
rustbot has assigned @petrochenkov. Use |
Some changes occurred to MIR optimizations cc @rust-lang/wg-mir-opt |
This comment was marked as resolved.
This comment was marked as resolved.
7b22c4d
to
7988ddd
Compare
@rustbot ready |
}) | ||
.filter({ | ||
// We only need one arbitrary instance per definition. | ||
let mut seen = FxHashSet::default(); |
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.
No need to create an inner scope for this. A function-level binding is good enough, it's moved into the closure anyway.
@@ -354,78 +346,94 @@ fn add_unused_functions(cx: &CodegenCx<'_, '_>) { | |||
assert!(cx.codegen_unit.is_code_coverage_dead_code_cgu()); | |||
|
|||
let tcx = cx.tcx; | |||
let usage = prepare_usage_sets(tcx); | |||
|
|||
let is_unused_fn = |def_id: &&LocalDefId| -> bool { |
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.
The closure should take by value, and let the caller dereference.
@bors try @rust-timer queue |
Awaiting bors try build completion. @rustbot label: +S-waiting-on-perf |
coverage: Re-enable `UnreachablePropagation` for coverage builds This is a sequence of 3 related changes: - Clean up the existing code that scans for unused functions - Detect functions that were instrumented for coverage, but have had all their coverage statements removed by later MIR transforms (e.g. `UnreachablePropagation`) - Re-enable `UnreachablePropagation` in coverage builds Because we now detect functions that have lost their coverage statements, and treat them as unused, we don't need to worry about `UnreachablePropagation` removing all of those statements. This is demonstrated by `tests/coverage/unreachable.rs`. Fixes rust-lang#116171.
If a function was instrumented for coverage, but all of its coverage statements have been removed by later MIR transforms, it should be treated as "unused" even if the compiler generates an unreachable stub for it.
Addressed feedback (diff). I think I still prefer the way it was, but 🤷♂️. |
I'm not 100% sure, but I don't think we have any benchmarks that actually enable coverage. |
Thanks. |
…llaumeGomez Rollup of 6 pull requests Successful merges: - rust-lang#121843 (Implement `-L KIND=`@RUSTC_BUILTIN/...`)` - rust-lang#122860 (coverage: Re-enable `UnreachablePropagation` for coverage builds) - rust-lang#123021 (Make `TyCtxt::coroutine_layout` take coroutine's kind parameter) - rust-lang#123024 (CFI: Enable KCFI testing of run-pass tests) - rust-lang#123083 (lib: fix some unnecessary_cast clippy lint) - rust-lang#123116 (rustdoc: Swap fields and variant documentations) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#122860 - Zalathar:unused, r=cjgillot coverage: Re-enable `UnreachablePropagation` for coverage builds This is a sequence of 3 related changes: - Clean up the existing code that scans for unused functions - Detect functions that were instrumented for coverage, but have had all their coverage statements removed by later MIR transforms (e.g. `UnreachablePropagation`) - Re-enable `UnreachablePropagation` in coverage builds Because we now detect functions that have lost their coverage statements, and treat them as unused, we don't need to worry about `UnreachablePropagation` removing all of those statements. This is demonstrated by `tests/coverage/unreachable.rs`. Fixes rust-lang#116171.
This is a sequence of 3 related changes:
UnreachablePropagation
)UnreachablePropagation
in coverage buildsBecause we now detect functions that have lost their coverage statements, and treat them as unused, we don't need to worry about
UnreachablePropagation
removing all of those statements. This is demonstrated bytests/coverage/unreachable.rs
.Fixes #116171.