diff options
| author | Zalathar <Zalathar@users.noreply.github.com> | 2023-10-06 12:51:48 +1100 |
|---|---|---|
| committer | Zalathar <Zalathar@users.noreply.github.com> | 2023-10-22 20:11:45 +1100 |
| commit | 371883a05acf04be9fb8d3c0766990ba56cd22e3 (patch) | |
| tree | 0fa1b305972db444ea92397b32cc6f07b9a8eb3e /compiler/rustc_codegen_llvm/src/coverageinfo/mapgen.rs | |
| parent | cc3dce5bd07057818f3f69c3ce93bfd596fd8f0f (diff) | |
| download | rust-371883a05acf04be9fb8d3c0766990ba56cd22e3.tar.gz rust-371883a05acf04be9fb8d3c0766990ba56cd22e3.zip | |
coverage: Split `FunctionCoverage` into distinct collector/finished phases
This gives us a clearly-defined place to run code after the instance's MIR has been traversed by codegen, but before we emit its `__llvm_covfun` record.
Diffstat (limited to 'compiler/rustc_codegen_llvm/src/coverageinfo/mapgen.rs')
| -rw-r--r-- | compiler/rustc_codegen_llvm/src/coverageinfo/mapgen.rs | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/compiler/rustc_codegen_llvm/src/coverageinfo/mapgen.rs b/compiler/rustc_codegen_llvm/src/coverageinfo/mapgen.rs index 2f825b801ac..5b2dae2c0a4 100644 --- a/compiler/rustc_codegen_llvm/src/coverageinfo/mapgen.rs +++ b/compiler/rustc_codegen_llvm/src/coverageinfo/mapgen.rs @@ -1,7 +1,7 @@ use crate::common::CodegenCx; use crate::coverageinfo; use crate::coverageinfo::ffi::CounterMappingRegion; -use crate::coverageinfo::map_data::FunctionCoverage; +use crate::coverageinfo::map_data::{FunctionCoverage, FunctionCoverageCollector}; use crate::llvm; use rustc_codegen_ssa::traits::{BaseTypeMethods, ConstMethods}; @@ -62,6 +62,7 @@ pub fn finalize(cx: &CodegenCx<'_, '_>) { // Encode coverage mappings and generate function records let mut function_data = Vec::new(); for (instance, function_coverage) in function_coverage_map { + let function_coverage = function_coverage.into_finished(); debug!("Generate function coverage for {}, {:?}", cx.codegen_unit.name(), instance); let mangled_function_name = tcx.symbol_name(instance).name; @@ -419,7 +420,7 @@ fn add_unused_function_coverage<'tcx>( ) { // An unused function's mappings will automatically be rewritten to map to // zero, because none of its counters/expressions are marked as seen. - let function_coverage = FunctionCoverage::unused(instance, function_coverage_info); + let function_coverage = FunctionCoverageCollector::unused(instance, function_coverage_info); if let Some(coverage_context) = cx.coverage_context() { coverage_context.function_coverage_map.borrow_mut().insert(instance, function_coverage); |
