Function rustc_codegen_llvm::coverageinfo::mapgen::add_unused_functions [−][src]
fn add_unused_functions<'ll, 'tcx>(cx: &CodegenCx<'ll, 'tcx>)
Expand description
When finalizing the coverage map, FunctionCoverage
only has the CodeRegion
s and counters for
the functions that went through codegen; such as public functions and “used” functions
(functions referenced by other “used” or public items). Any other functions considered unused,
or “Unreachable”, were still parsed and processed through the MIR stage, but were not
codegenned. (Note that -Clink-dead-code
can force some unused code to be codegenned, but
that flag is known to cause other errors, when combined with -Z instrument-coverage
; and
-Clink-dead-code
will not generate code for unused generic functions.)
We can find the unused functions (including generic functions) by the set difference of all MIR
DefId
s (tcx
query mir_keys
) minus the codegenned DefId
s (tcx
query
codegened_and_inlined_items
).
HOWEVER the codegenned DefId
s are partitioned across multiple CodegenUnit
s (CGUs), and
this function is processing a function_coverage_map
for the functions (Instance
/DefId
)
allocated to only one of those CGUs. We must NOT inject any unused functions’s CodeRegion
s
more than once, so we have to pick a CGUs function_coverage_map
into which the unused
function will be inserted.