diff options
| author | Zalathar <Zalathar@users.noreply.github.com> | 2024-12-14 23:14:19 +1100 |
|---|---|---|
| committer | Zalathar <Zalathar@users.noreply.github.com> | 2024-12-17 13:55:20 +1100 |
| commit | d34c365eb0c40d907daf42fff42b7b6ebdc314ab (patch) | |
| tree | a25374c643d742c0a71207b4b38c6226175e8616 | |
| parent | 527f8127bbde4d189ee292dee0d6070550ec0ba6 (diff) | |
| download | rust-d34c365eb0c40d907daf42fff42b7b6ebdc314ab.tar.gz rust-d34c365eb0c40d907daf42fff42b7b6ebdc314ab.zip | |
coverage: Pull function source hash out of `map_data.rs`
3 files changed, 7 insertions, 12 deletions
diff --git a/compiler/rustc_codegen_llvm/src/coverageinfo/map_data.rs b/compiler/rustc_codegen_llvm/src/coverageinfo/map_data.rs index e1b2a1b87bb..261a014c3d1 100644 --- a/compiler/rustc_codegen_llvm/src/coverageinfo/map_data.rs +++ b/compiler/rustc_codegen_llvm/src/coverageinfo/map_data.rs @@ -1,6 +1,7 @@ use rustc_middle::mir::coverage::{CoverageIdsInfo, FunctionCoverageInfo}; pub(crate) struct FunctionCoverage<'tcx> { + #[expect(unused)] // This whole file gets deleted later in the same PR. pub(crate) function_coverage_info: &'tcx FunctionCoverageInfo, /// If `None`, the corresponding function is unused. ids_info: Option<&'tcx CoverageIdsInfo>, @@ -22,10 +23,4 @@ impl<'tcx> FunctionCoverage<'tcx> { pub(crate) fn is_used(&self) -> bool { self.ids_info.is_some() } - - /// Return the source hash, generated from the HIR node structure, and used to indicate whether - /// or not the source code structure changed between different compilations. - pub(crate) fn source_hash(&self) -> u64 { - if self.is_used() { self.function_coverage_info.function_source_hash } else { 0 } - } } diff --git a/compiler/rustc_codegen_llvm/src/coverageinfo/mapgen.rs b/compiler/rustc_codegen_llvm/src/coverageinfo/mapgen.rs index 0c7ad300a8b..9bc33967044 100644 --- a/compiler/rustc_codegen_llvm/src/coverageinfo/mapgen.rs +++ b/compiler/rustc_codegen_llvm/src/coverageinfo/mapgen.rs @@ -81,7 +81,8 @@ pub(crate) fn finalize(cx: &CodegenCx<'_, '_>) { // instances were visited during codegen. .sorted_by_cached_key(|&(instance, _)| tcx.symbol_name(instance).name) .filter_map(|(instance, function_coverage)| { - prepare_covfun_record(tcx, &mut global_file_table, instance, &function_coverage) + let is_used = function_coverage.is_used(); + prepare_covfun_record(tcx, &mut global_file_table, instance, is_used) }) .collect::<Vec<_>>(); diff --git a/compiler/rustc_codegen_llvm/src/coverageinfo/mapgen/covfun.rs b/compiler/rustc_codegen_llvm/src/coverageinfo/mapgen/covfun.rs index fa0af8415e7..8e853f057be 100644 --- a/compiler/rustc_codegen_llvm/src/coverageinfo/mapgen/covfun.rs +++ b/compiler/rustc_codegen_llvm/src/coverageinfo/mapgen/covfun.rs @@ -19,7 +19,6 @@ use rustc_target::spec::HasTargetSpec; use tracing::debug; use crate::common::CodegenCx; -use crate::coverageinfo::map_data::FunctionCoverage; use crate::coverageinfo::mapgen::{GlobalFileTable, VirtualFileMapping, span_file_name}; use crate::coverageinfo::{ffi, llvm_cov}; use crate::llvm; @@ -49,17 +48,17 @@ pub(crate) fn prepare_covfun_record<'tcx>( tcx: TyCtxt<'tcx>, global_file_table: &mut GlobalFileTable, instance: Instance<'tcx>, - function_coverage: &FunctionCoverage<'tcx>, + is_used: bool, ) -> Option<CovfunRecord<'tcx>> { let fn_cov_info = tcx.instance_mir(instance.def).function_coverage_info.as_deref()?; let ids_info = tcx.coverage_ids_info(instance.def); - let expressions = prepare_expressions(fn_cov_info, ids_info, function_coverage.is_used()); + let expressions = prepare_expressions(fn_cov_info, ids_info, is_used); let mut covfun = CovfunRecord { mangled_function_name: tcx.symbol_name(instance).name, - source_hash: function_coverage.source_hash(), - is_used: function_coverage.is_used(), + source_hash: if is_used { fn_cov_info.function_source_hash } else { 0 }, + is_used, virtual_file_mapping: VirtualFileMapping::default(), expressions, regions: ffi::Regions::default(), |
