diff options
| author | Zalathar <Zalathar@users.noreply.github.com> | 2023-06-26 22:28:48 +1000 |
|---|---|---|
| committer | Zalathar <Zalathar@users.noreply.github.com> | 2023-08-01 11:29:55 +1000 |
| commit | 1a014d42f45de1b829ca7916d8f639fda6e0770a (patch) | |
| tree | ccd46f428dc2fd95e16837179a05b4abb6deb72a /compiler/rustc_mir_transform/src/coverage/graph.rs | |
| parent | 5a808d40f41c9d021361c4a9c4f53e099af40dc5 (diff) | |
| download | rust-1a014d42f45de1b829ca7916d8f639fda6e0770a.tar.gz rust-1a014d42f45de1b829ca7916d8f639fda6e0770a.zip | |
Replace `ExpressionOperandId` with enum `Operand`
Because the three kinds of operand are now distinguished explicitly, we no longer need fiddly code to disambiguate counter IDs and expression IDs based on the total number of counters/expressions in a function. This does increase the size of operands from 4 bytes to 8 bytes, but that shouldn't be a big deal since they are mostly stored inside boxed structures, and the current coverage code is not particularly size-optimized anyway.
Diffstat (limited to 'compiler/rustc_mir_transform/src/coverage/graph.rs')
| -rw-r--r-- | compiler/rustc_mir_transform/src/coverage/graph.rs | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/compiler/rustc_mir_transform/src/coverage/graph.rs b/compiler/rustc_mir_transform/src/coverage/graph.rs index 5d843f4ade0..f94dad4c8da 100644 --- a/compiler/rustc_mir_transform/src/coverage/graph.rs +++ b/compiler/rustc_mir_transform/src/coverage/graph.rs @@ -345,10 +345,7 @@ impl BasicCoverageBlockData { &mir_body[self.last_bb()].terminator() } - pub fn set_counter( - &mut self, - counter_kind: CoverageKind, - ) -> Result<ExpressionOperandId, Error> { + pub fn set_counter(&mut self, counter_kind: CoverageKind) -> Result<Operand, Error> { debug_assert!( // If the BCB has an edge counter (to be injected into a new `BasicBlock`), it can also // have an expression (to be injected into an existing `BasicBlock` represented by this @@ -356,7 +353,7 @@ impl BasicCoverageBlockData { self.edge_from_bcbs.is_none() || counter_kind.is_expression(), "attempt to add a `Counter` to a BCB target with existing incoming edge counters" ); - let operand = counter_kind.as_operand_id(); + let operand = counter_kind.as_operand(); if let Some(replaced) = self.counter_kind.replace(counter_kind) { Error::from_string(format!( "attempt to set a BasicCoverageBlock coverage counter more than once; \ @@ -381,7 +378,7 @@ impl BasicCoverageBlockData { &mut self, from_bcb: BasicCoverageBlock, counter_kind: CoverageKind, - ) -> Result<ExpressionOperandId, Error> { + ) -> Result<Operand, Error> { if level_enabled!(tracing::Level::DEBUG) { // If the BCB has an edge counter (to be injected into a new `BasicBlock`), it can also // have an expression (to be injected into an existing `BasicBlock` represented by this @@ -393,7 +390,7 @@ impl BasicCoverageBlockData { )); } } - let operand = counter_kind.as_operand_id(); + let operand = counter_kind.as_operand(); if let Some(replaced) = self.edge_from_bcbs.get_or_insert_default().insert(from_bcb, counter_kind) { |
