Skip to content

Commit

Permalink
coverage: Re-enable UnreachablePropagation for coverage builds
Browse files Browse the repository at this point in the history
  • Loading branch information
Zalathar committed Mar 26, 2024
1 parent 54116c8 commit 1cca252
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
6 changes: 1 addition & 5 deletions compiler/rustc_mir_transform/src/unreachable_prop.rs
Expand Up @@ -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>) {
Expand Down
6 changes: 3 additions & 3 deletions tests/coverage/unreachable.cov-map
Expand Up @@ -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)

0 comments on commit 1cca252

Please sign in to comment.