Rollup merge of #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 #116171.
This commit is contained in:
commit
8a7f285cbc
3 changed files with 95 additions and 79 deletions
|
@ -14,11 +14,7 @@ pub struct UnreachablePropagation;
|
|||
impl MirPass<'_> for UnreachablePropagation {
|
||||
fn is_enabled(&self, sess: &rustc_session::Session) -> bool {
|
||||
// Enable only under -Zmir-opt-level=2 as this can make programs less debuggable.
|
||||
|
||||
// FIXME(#116171) Coverage gets confused by MIR passes that can remove all
|
||||
// coverage statements from an instrumented function. This pass can be
|
||||
// re-enabled when coverage codegen is robust against that happening.
|
||||
sess.mir_opt_level() >= 2 && !sess.instrument_coverage()
|
||||
sess.mir_opt_level() >= 2
|
||||
}
|
||||
|
||||
fn run_pass<'tcx>(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue