diff options
| author | Zalathar <Zalathar@users.noreply.github.com> | 2023-08-14 12:16:29 +1000 |
|---|---|---|
| committer | Zalathar <Zalathar@users.noreply.github.com> | 2023-08-20 12:02:40 +1000 |
| commit | 72f4c78dc6d5fc4a09d946f979ccfbf3fa763585 (patch) | |
| tree | e65809e1dd6aaa41a93e0976838f41bdc438f29e /compiler/rustc_mir_transform/src/coverage/counters.rs | |
| parent | fbab055e7704a1cd321628a1896333e0c13ebc2f (diff) | |
| download | rust-72f4c78dc6d5fc4a09d946f979ccfbf3fa763585.tar.gz rust-72f4c78dc6d5fc4a09d946f979ccfbf3fa763585.zip | |
coverage: Don't store `function_source_hash` in `BcbCounter::Counter`
This shows one small benefit of separating `BcbCounter` from `CoverageKind`. The function source hash will be the same for all counters within a function, so instead of passing it through `CoverageCounters` and storing it in every counter, we can just supply it during the final conversion to `CoverageKind`.
Diffstat (limited to 'compiler/rustc_mir_transform/src/coverage/counters.rs')
| -rw-r--r-- | compiler/rustc_mir_transform/src/coverage/counters.rs | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/compiler/rustc_mir_transform/src/coverage/counters.rs b/compiler/rustc_mir_transform/src/coverage/counters.rs index 3eca2610de6..3d442e5dca9 100644 --- a/compiler/rustc_mir_transform/src/coverage/counters.rs +++ b/compiler/rustc_mir_transform/src/coverage/counters.rs @@ -20,7 +20,7 @@ use std::fmt::{self, Debug}; /// BCB node or BCB edge. #[derive(Clone)] pub(super) enum BcbCounter { - Counter { function_source_hash: u64, id: CounterId }, + Counter { id: CounterId }, Expression { id: ExpressionId, lhs: Operand, op: Op, rhs: Operand }, } @@ -59,7 +59,6 @@ impl Debug for BcbCounter { /// Generates and stores coverage counter and coverage expression information /// associated with nodes/edges in the BCB graph. pub(super) struct CoverageCounters { - function_source_hash: u64, next_counter_id: CounterId, next_expression_id: ExpressionId, @@ -81,11 +80,10 @@ pub(super) struct CoverageCounters { } impl CoverageCounters { - pub(super) fn new(function_source_hash: u64, basic_coverage_blocks: &CoverageGraph) -> Self { + pub(super) fn new(basic_coverage_blocks: &CoverageGraph) -> Self { let num_bcbs = basic_coverage_blocks.num_nodes(); Self { - function_source_hash, next_counter_id: CounterId::START, next_expression_id: ExpressionId::START, @@ -119,10 +117,7 @@ impl CoverageCounters { where F: Fn() -> Option<String>, { - let counter = BcbCounter::Counter { - function_source_hash: self.function_source_hash, - id: self.next_counter(), - }; + let counter = BcbCounter::Counter { id: self.next_counter() }; if self.debug_counters.is_enabled() { self.debug_counters.add_counter(&counter, (debug_block_label_fn)()); } |
