From 968f8ce4ccf898f6a98367871ee1b6df554d41cf Mon Sep 17 00:00:00 2001 From: Zalathar Date: Fri, 22 Mar 2024 13:34:26 +1100 Subject: [PATCH] coverage: Re-enable `UnreachablePropagation` for coverage builds --- compiler/rustc_mir_transform/src/unreachable_prop.rs | 6 +----- tests/coverage/unreachable.cov-map | 6 +++--- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/compiler/rustc_mir_transform/src/unreachable_prop.rs b/compiler/rustc_mir_transform/src/unreachable_prop.rs index bff59aa602377..8ad7bc394c5ae 100644 --- a/compiler/rustc_mir_transform/src/unreachable_prop.rs +++ b/compiler/rustc_mir_transform/src/unreachable_prop.rs @@ -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>) { diff --git a/tests/coverage/unreachable.cov-map b/tests/coverage/unreachable.cov-map index 55d124a16f592..9d4698527d092 100644 --- a/tests/coverage/unreachable.cov-map +++ b/tests/coverage/unreachable.cov-map @@ -14,11 +14,11 @@ Number of expressions: 0 Number of file 0 mappings: 1 - Code(Counter(0)) at (prev + 17, 1) to (start + 1, 37) -Function name: unreachable::unreachable_intrinsic -Raw bytes (9): 0x[01, 01, 00, 01, 01, 16, 01, 01, 2c] +Function name: unreachable::unreachable_intrinsic (unused) +Raw bytes (9): 0x[01, 01, 00, 01, 00, 16, 01, 01, 2c] Number of files: 1 - file 0 => global file 1 Number of expressions: 0 Number of file 0 mappings: 1 -- Code(Counter(0)) at (prev + 22, 1) to (start + 1, 44) +- Code(Zero) at (prev + 22, 1) to (start + 1, 44)