1
Fork 0

coverage: Attach an optional FunctionCoverageInfo to mir::Body

This allows coverage information to be attached to the function as a whole when
appropriate, instead of being smuggled through coverage statements in the
function's basic blocks.

As an example, this patch moves the `function_source_hash` value out of
individual `CoverageKind::Counter` statements and into the per-function info.

When synthesizing unused functions for coverage purposes, the absence of this
info is taken to indicate that a function was not eligible for coverage and
should not be synthesized.
This commit is contained in:
Zalathar 2023-09-10 16:35:37 +10:00
parent 6d7160ce97
commit c479bc7f3b
7 changed files with 74 additions and 54 deletions

View file

@ -60,6 +60,7 @@ pub(super) fn build_custom_mir<'tcx>(
tainted_by_errors: None,
injection_phase: None,
pass_count: 0,
function_coverage_info: None,
};
body.local_decls.push(LocalDecl::new(return_ty, return_ty_span));