about summary refs log tree commit diff
path: root/compiler/rustc_codegen_llvm/src/coverageinfo/mapgen.rs
diff options
context:
space:
mode:
authorZalathar <Zalathar@users.noreply.github.com>2024-12-11 15:03:31 +1100
committerZalathar <Zalathar@users.noreply.github.com>2024-12-11 18:25:10 +1100
commit6a8c016266a6b7514ff8284dc6d8b056e34b9399 (patch)
tree7cd593c7218d33a8bd9f3fdbc2dee77a14c87aff /compiler/rustc_codegen_llvm/src/coverageinfo/mapgen.rs
parent7c4ac71ad1bef9b1e4cb5a3fd10d0b2ef7b418c4 (diff)
downloadrust-6a8c016266a6b7514ff8284dc6d8b056e34b9399.tar.gz
rust-6a8c016266a6b7514ff8284dc6d8b056e34b9399.zip
coverage: Reify `CovfunRecord` as an intermediate step
Diffstat (limited to 'compiler/rustc_codegen_llvm/src/coverageinfo/mapgen.rs')
-rw-r--r--compiler/rustc_codegen_llvm/src/coverageinfo/mapgen.rs22
1 files changed, 12 insertions, 10 deletions
diff --git a/compiler/rustc_codegen_llvm/src/coverageinfo/mapgen.rs b/compiler/rustc_codegen_llvm/src/coverageinfo/mapgen.rs
index 5da7848b39c..39fb0aeed07 100644
--- a/compiler/rustc_codegen_llvm/src/coverageinfo/mapgen.rs
+++ b/compiler/rustc_codegen_llvm/src/coverageinfo/mapgen.rs
@@ -19,6 +19,7 @@ use tracing::debug;
 use crate::common::CodegenCx;
 use crate::coverageinfo::llvm_cov;
 use crate::coverageinfo::map_data::FunctionCoverage;
+use crate::coverageinfo::mapgen::covfun::prepare_covfun_record;
 use crate::llvm;
 
 mod covfun;
@@ -85,16 +86,17 @@ pub(crate) fn finalize(cx: &CodegenCx<'_, '_>) {
 
     let mut unused_function_names = Vec::new();
 
-    // Encode coverage mappings and generate function records
-    for (instance, function_coverage) in function_coverage_map {
-        covfun::prepare_and_generate_covfun_record(
-            cx,
-            &global_file_table,
-            filenames_ref,
-            &mut unused_function_names,
-            instance,
-            &function_coverage,
-        );
+    let covfun_records = function_coverage_map
+        .into_iter()
+        .filter_map(|(instance, function_coverage)| {
+            prepare_covfun_record(tcx, &global_file_table, instance, &function_coverage)
+        })
+        .collect::<Vec<_>>();
+
+    for covfun in &covfun_records {
+        unused_function_names.extend(covfun.mangled_function_name_if_unused());
+
+        covfun::generate_covfun_record(cx, filenames_ref, covfun)
     }
 
     // For unused functions, we need to take their mangled names and store them