From 8efdd4cca61df9adf7f90c40fcc176a2842a9c28 Mon Sep 17 00:00:00 2001 From: Zalathar Date: Mon, 4 Sep 2023 12:50:51 +1000 Subject: coverage: Collect a function's coverage mappings into a single list This is an intermediate step towards being able to store all of a function's mappings in function coverage info. --- compiler/rustc_codegen_llvm/src/coverageinfo/mapgen.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'compiler/rustc_codegen_llvm/src/coverageinfo/mapgen.rs') diff --git a/compiler/rustc_codegen_llvm/src/coverageinfo/mapgen.rs b/compiler/rustc_codegen_llvm/src/coverageinfo/mapgen.rs index a2bf53e605d..cde12b13307 100644 --- a/compiler/rustc_codegen_llvm/src/coverageinfo/mapgen.rs +++ b/compiler/rustc_codegen_llvm/src/coverageinfo/mapgen.rs @@ -61,7 +61,7 @@ pub fn finalize(cx: &CodegenCx<'_, '_>) { let mut function_data = Vec::new(); for (instance, mut function_coverage) in function_coverage_map { debug!("Generate function coverage for {}, {:?}", cx.codegen_unit.name(), instance); - function_coverage.simplify_expressions(); + function_coverage.finalize(); let function_coverage = function_coverage; let mangled_function_name = tcx.symbol_name(instance).name; @@ -169,10 +169,11 @@ fn encode_mappings_for_function( let mut virtual_file_mapping = IndexVec::::new(); let mut mapping_regions = Vec::with_capacity(counter_regions.len()); - // Sort the list of (counter, region) mapping pairs by region, so that they - // can be grouped by filename. Prepare file IDs for each filename, and - // prepare the mapping data so that we can pass it through FFI to LLVM. - counter_regions.sort_by_key(|(_counter, region)| *region); + // Sort and group the list of (counter, region) mapping pairs by filename. + // (Preserve any further ordering imposed by `FunctionCoverage`.) + // Prepare file IDs for each filename, and prepare the mapping data so that + // we can pass it through FFI to LLVM. + counter_regions.sort_by_key(|(_counter, region)| region.file_name); for counter_regions_for_file in counter_regions.group_by(|(_, a), (_, b)| a.file_name == b.file_name) { -- cgit 1.4.1-3-g733a5