rustc_codegen_llvm::coverageinfo::mapgen

Function gather_unused_function_instances

Source
fn gather_unused_function_instances<'tcx>(
    cx: &CodegenCx<'_, 'tcx>,
) -> Vec<Instance<'tcx>>
Expand description

Each CGU will normally only emit coverage metadata for the functions that it actually generates. But since we don’t want unused functions to disappear from coverage reports, we also scan for functions that were instrumented but are not participating in codegen.

These unused functions don’t need to be codegenned, but we do need to add them to the function coverage map (in a single designated CGU) so that we still emit coverage mappings for them. We also end up adding their symbol names to a special global array that LLVM will include in its embedded coverage data.