Skip to content

Commit 5c0a545

Browse files
committed
!! (WIP) De-duplicate mappings
1 parent 77bf818 commit 5c0a545

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

compiler/rustc_codegen_llvm/src/coverageinfo/map_data.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,13 @@ impl<'tcx> FunctionCoverage<'tcx> {
160160
CovTerm::Zero => u8::MAX,
161161
};
162162
for mappings in self.mappings_per_file.values_mut() {
163-
mappings.sort_by_key(|(mapping_kind, _)| mapping_kind_sort_key(mapping_kind));
163+
mappings.sort_by(|(a, a_region), (b, b_region)| {
164+
Ord::cmp(a_region, b_region)
165+
.then_with(|| Ord::cmp(&mapping_kind_sort_key(a), &mapping_kind_sort_key(b)))
166+
});
167+
mappings.dedup_by(|(b, b_region), (a, a_region)| {
168+
a_region == b_region && ((a == b) || matches!(b, CovTerm::Zero))
169+
});
164170
}
165171
}
166172

tests/coverage-map/status-quo/issue-84561.cov-map

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
Function name: <issue_84561::Foo as core::cmp::PartialEq>::eq
2-
Raw bytes (14): 0x[01, 01, 00, 02, 01, 04, 0a, 00, 13, 00, 00, 0a, 00, 13]
2+
Raw bytes (9): 0x[01, 01, 00, 01, 01, 04, 0a, 00, 13]
33
Number of files: 1
44
- file 0 => global file 1
55
Number of expressions: 0
6-
Number of file 0 mappings: 2
6+
Number of file 0 mappings: 1
77
- Code(Counter(0)) at (prev + 4, 10) to (start + 0, 19)
8-
- Code(Zero) at (prev + 0, 10) to (start + 0, 19)
98

109
Function name: <issue_84561::Foo as core::fmt::Debug>::fmt
1110
Raw bytes (29): 0x[01, 01, 02, 01, 05, 05, 02, 04, 01, 89, 01, 09, 00, 25, 05, 00, 25, 00, 26, 02, 01, 09, 00, 0f, 07, 01, 05, 00, 06]

0 commit comments

Comments
 (0)