diff options
| author | Zalathar <Zalathar@users.noreply.github.com> | 2024-12-15 00:34:06 +1100 |
|---|---|---|
| committer | Zalathar <Zalathar@users.noreply.github.com> | 2024-12-17 13:30:11 +1100 |
| commit | fe412af4fce43aa5222b8940e068da3a19188e4b (patch) | |
| tree | 0f766535853e649b39276488fe55ec898e09d021 /compiler/rustc_codegen_llvm/src/coverageinfo | |
| parent | 13b77c687c0f5ad06a579af6d0787fe562747501 (diff) | |
| download | rust-fe412af4fce43aa5222b8940e068da3a19188e4b.tar.gz rust-fe412af4fce43aa5222b8940e068da3a19188e4b.zip | |
coverage: Use `is_eligible_for_coverage` to filter unused functions
The checks in `is_eligible_for_coverage` include `is_fn_like`, but will also exclude various function-like things that cannot possibly have coverage instrumentation.
Diffstat (limited to 'compiler/rustc_codegen_llvm/src/coverageinfo')
| -rw-r--r-- | compiler/rustc_codegen_llvm/src/coverageinfo/mapgen.rs | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/compiler/rustc_codegen_llvm/src/coverageinfo/mapgen.rs b/compiler/rustc_codegen_llvm/src/coverageinfo/mapgen.rs index 4f2af732527..c57946cc317 100644 --- a/compiler/rustc_codegen_llvm/src/coverageinfo/mapgen.rs +++ b/compiler/rustc_codegen_llvm/src/coverageinfo/mapgen.rs @@ -271,16 +271,15 @@ fn add_unused_functions(cx: &CodegenCx<'_, '_>) { let usage = prepare_usage_sets(tcx); let is_unused_fn = |def_id: LocalDefId| -> bool { - let def_id = def_id.to_def_id(); - - // To be eligible for "unused function" mappings, a definition must: - // - Be function-like + // Usage sets expect `DefId`, so convert from `LocalDefId`. + let d: DefId = LocalDefId::to_def_id(def_id); + // To be potentially eligible for "unused function" mappings, a definition must: + // - Be eligible for coverage instrumentation // - Not participate directly in codegen (or have lost all its coverage statements) // - Not have any coverage statements inlined into codegenned functions - tcx.def_kind(def_id).is_fn_like() - && (!usage.all_mono_items.contains(&def_id) - || usage.missing_own_coverage.contains(&def_id)) - && !usage.used_via_inlining.contains(&def_id) + tcx.is_eligible_for_coverage(def_id) + && (!usage.all_mono_items.contains(&d) || usage.missing_own_coverage.contains(&d)) + && !usage.used_via_inlining.contains(&d) }; // Scan for unused functions that were instrumented for coverage. |
