coverage: Eagerly deduplicate covspans with the same span
This commit is contained in:
parent
7168c13579
commit
ec91209f96
3 changed files with 18 additions and 15 deletions
|
@ -52,14 +52,19 @@ pub(super) fn mir_to_initial_sorted_coverage_spans(
|
|||
// - Span A extends further left, or
|
||||
// - Both have the same start and span A extends further right
|
||||
.then_with(|| Ord::cmp(&a.span.hi(), &b.span.hi()).reverse())
|
||||
// If both spans are equal, sort the BCBs in dominator order,
|
||||
// so that dominating BCBs come before other BCBs they dominate.
|
||||
.then_with(|| basic_coverage_blocks.cmp_in_dominator_order(a.bcb, b.bcb))
|
||||
// If two spans are otherwise identical, put closure spans first,
|
||||
// as this seems to be what the refinement step expects.
|
||||
// If two spans have the same lo & hi, put closure spans first,
|
||||
// as they take precedence over non-closure spans.
|
||||
.then_with(|| Ord::cmp(&a.is_closure, &b.is_closure).reverse())
|
||||
// After deduplication, we want to keep only the most-dominated BCB.
|
||||
.then_with(|| basic_coverage_blocks.cmp_in_dominator_order(a.bcb, b.bcb).reverse())
|
||||
});
|
||||
|
||||
// Among covspans with the same span, keep only one. Closure spans take
|
||||
// precedence, otherwise keep the one with the most-dominated BCB.
|
||||
// (Ideally we should try to preserve _all_ non-dominating BCBs, but that
|
||||
// requires a lot more complexity in the span refiner, for little benefit.)
|
||||
initial_spans.dedup_by(|b, a| a.span.source_equal(b.span));
|
||||
|
||||
initial_spans
|
||||
}
|
||||
|
||||
|
|
|
@ -7,18 +7,17 @@ Number of file 0 mappings: 1
|
|||
- Code(Counter(0)) at (prev + 29, 1) to (start + 2, 2)
|
||||
|
||||
Function name: closure_macro::main
|
||||
Raw bytes (43): 0x[01, 01, 02, 01, 05, 05, 02, 07, 01, 21, 01, 01, 21, 02, 02, 09, 00, 0f, 05, 00, 12, 00, 13, 02, 00, 12, 00, 13, 05, 00, 54, 00, 55, 02, 02, 09, 02, 0b, 07, 03, 01, 00, 02]
|
||||
Raw bytes (38): 0x[01, 01, 02, 01, 05, 05, 02, 06, 01, 21, 01, 01, 21, 02, 02, 09, 00, 12, 02, 00, 0f, 00, 54, 05, 00, 54, 00, 55, 02, 02, 09, 02, 0b, 07, 03, 01, 00, 02]
|
||||
Number of files: 1
|
||||
- file 0 => global file 1
|
||||
Number of expressions: 2
|
||||
- expression 0 operands: lhs = Counter(0), rhs = Counter(1)
|
||||
- expression 1 operands: lhs = Counter(1), rhs = Expression(0, Sub)
|
||||
Number of file 0 mappings: 7
|
||||
Number of file 0 mappings: 6
|
||||
- Code(Counter(0)) at (prev + 33, 1) to (start + 1, 33)
|
||||
- Code(Expression(0, Sub)) at (prev + 2, 9) to (start + 0, 15)
|
||||
- Code(Expression(0, Sub)) at (prev + 2, 9) to (start + 0, 18)
|
||||
= (c0 - c1)
|
||||
- Code(Counter(1)) at (prev + 0, 18) to (start + 0, 19)
|
||||
- Code(Expression(0, Sub)) at (prev + 0, 18) to (start + 0, 19)
|
||||
- Code(Expression(0, Sub)) at (prev + 0, 15) to (start + 0, 84)
|
||||
= (c0 - c1)
|
||||
- Code(Counter(1)) at (prev + 0, 84) to (start + 0, 85)
|
||||
- Code(Expression(0, Sub)) at (prev + 2, 9) to (start + 2, 11)
|
||||
|
|
|
@ -15,18 +15,17 @@ Number of file 0 mappings: 1
|
|||
- Code(Counter(0)) at (prev + 35, 1) to (start + 0, 43)
|
||||
|
||||
Function name: closure_macro_async::test::{closure#0}
|
||||
Raw bytes (43): 0x[01, 01, 02, 01, 05, 05, 02, 07, 01, 23, 2b, 01, 21, 02, 02, 09, 00, 0f, 05, 00, 12, 00, 13, 02, 00, 12, 00, 13, 05, 00, 54, 00, 55, 02, 02, 09, 02, 0b, 07, 03, 01, 00, 02]
|
||||
Raw bytes (38): 0x[01, 01, 02, 01, 05, 05, 02, 06, 01, 23, 2b, 01, 21, 02, 02, 09, 00, 12, 02, 00, 0f, 00, 54, 05, 00, 54, 00, 55, 02, 02, 09, 02, 0b, 07, 03, 01, 00, 02]
|
||||
Number of files: 1
|
||||
- file 0 => global file 1
|
||||
Number of expressions: 2
|
||||
- expression 0 operands: lhs = Counter(0), rhs = Counter(1)
|
||||
- expression 1 operands: lhs = Counter(1), rhs = Expression(0, Sub)
|
||||
Number of file 0 mappings: 7
|
||||
Number of file 0 mappings: 6
|
||||
- Code(Counter(0)) at (prev + 35, 43) to (start + 1, 33)
|
||||
- Code(Expression(0, Sub)) at (prev + 2, 9) to (start + 0, 15)
|
||||
- Code(Expression(0, Sub)) at (prev + 2, 9) to (start + 0, 18)
|
||||
= (c0 - c1)
|
||||
- Code(Counter(1)) at (prev + 0, 18) to (start + 0, 19)
|
||||
- Code(Expression(0, Sub)) at (prev + 0, 18) to (start + 0, 19)
|
||||
- Code(Expression(0, Sub)) at (prev + 0, 15) to (start + 0, 84)
|
||||
= (c0 - c1)
|
||||
- Code(Counter(1)) at (prev + 0, 84) to (start + 0, 85)
|
||||
- Code(Expression(0, Sub)) at (prev + 2, 9) to (start + 2, 11)
|
||||
|
|
Loading…
Add table
Reference in a new issue