about summary refs log tree commit diff
path: root/compiler/rustc_codegen_llvm/src/coverageinfo/map_data.rs
diff options
context:
space:
mode:
authorZalathar <Zalathar@users.noreply.github.com>2023-08-31 16:03:12 +1000
committerZalathar <Zalathar@users.noreply.github.com>2023-10-18 21:23:58 +1100
commit79f935b96c2447c979124628187125a9e381e9dc (patch)
tree51a2db55f12bcf106cc6bf8b25240549046cac7a /compiler/rustc_codegen_llvm/src/coverageinfo/map_data.rs
parenta18c5f3b751dbfa6c192dc48a6c6f28250e9bc97 (diff)
downloadrust-79f935b96c2447c979124628187125a9e381e9dc.tar.gz
rust-79f935b96c2447c979124628187125a9e381e9dc.zip
coverage: Rename `Operand` to `CovTerm`
Later patches in this PR will use `CovTerm` to represent things that are not
expression operands.
Diffstat (limited to 'compiler/rustc_codegen_llvm/src/coverageinfo/map_data.rs')
-rw-r--r--compiler/rustc_codegen_llvm/src/coverageinfo/map_data.rs32
1 files changed, 16 insertions, 16 deletions
diff --git a/compiler/rustc_codegen_llvm/src/coverageinfo/map_data.rs b/compiler/rustc_codegen_llvm/src/coverageinfo/map_data.rs
index 4dbc0e403fd..9798c18f21b 100644
--- a/compiler/rustc_codegen_llvm/src/coverageinfo/map_data.rs
+++ b/compiler/rustc_codegen_llvm/src/coverageinfo/map_data.rs
@@ -3,15 +3,15 @@ use crate::coverageinfo::ffi::{Counter, CounterExpression, ExprKind};
 use rustc_data_structures::fx::FxIndexSet;
 use rustc_index::IndexVec;
 use rustc_middle::mir::coverage::{
-    CodeRegion, CounterId, ExpressionId, FunctionCoverageInfo, Op, Operand,
+    CodeRegion, CounterId, CovTerm, ExpressionId, FunctionCoverageInfo, Op,
 };
 use rustc_middle::ty::Instance;
 
 #[derive(Clone, Debug, PartialEq)]
 pub struct Expression {
-    lhs: Operand,
+    lhs: CovTerm,
     op: Op,
-    rhs: Operand,
+    rhs: CovTerm,
     code_regions: Vec<CodeRegion>,
 }
 
@@ -101,15 +101,15 @@ impl<'tcx> FunctionCoverage<'tcx> {
     /// code regions mapped to that expression.
     ///
     /// Both counters and "counter expressions" (or simply, "expressions") can be operands in other
-    /// expressions. These are tracked as separate variants of `Operand`, so there is no ambiguity
+    /// expressions. These are tracked as separate variants of `CovTerm`, so there is no ambiguity
     /// between operands that are counter IDs and operands that are expression IDs.
     #[instrument(level = "debug", skip(self))]
     pub(crate) fn add_counter_expression(
         &mut self,
         expression_id: ExpressionId,
-        lhs: Operand,
+        lhs: CovTerm,
         op: Op,
-        rhs: Operand,
+        rhs: CovTerm,
         code_regions: &[CodeRegion],
     ) {
         debug_assert!(
@@ -151,7 +151,7 @@ impl<'tcx> FunctionCoverage<'tcx> {
         // The set of expressions that either were optimized out entirely, or
         // have zero as both of their operands, and will therefore always have
         // a value of zero. Other expressions that refer to these as operands
-        // can have those operands replaced with `Operand::Zero`.
+        // can have those operands replaced with `CovTerm::Zero`.
         let mut zero_expressions = FxIndexSet::default();
 
         // For each expression, perform simplifications based on lower-numbered
@@ -168,10 +168,10 @@ impl<'tcx> FunctionCoverage<'tcx> {
             };
 
             // If an operand refers to an expression that is always zero, then
-            // that operand can be replaced with `Operand::Zero`.
-            let maybe_set_operand_to_zero = |operand: &mut Operand| match &*operand {
-                Operand::Expression(id) if zero_expressions.contains(id) => {
-                    *operand = Operand::Zero;
+            // that operand can be replaced with `CovTerm::Zero`.
+            let maybe_set_operand_to_zero = |operand: &mut CovTerm| match &*operand {
+                CovTerm::Expression(id) if zero_expressions.contains(id) => {
+                    *operand = CovTerm::Zero;
                 }
                 _ => (),
             };
@@ -181,13 +181,13 @@ impl<'tcx> FunctionCoverage<'tcx> {
             // Coverage counter values cannot be negative, so if an expression
             // involves subtraction from zero, assume that its RHS must also be zero.
             // (Do this after simplifications that could set the LHS to zero.)
-            if let Expression { lhs: Operand::Zero, op: Op::Subtract, .. } = expression {
-                expression.rhs = Operand::Zero;
+            if let Expression { lhs: CovTerm::Zero, op: Op::Subtract, .. } = expression {
+                expression.rhs = CovTerm::Zero;
             }
 
             // After the above simplifications, if both operands are zero, then
             // we know that this expression is always zero too.
-            if let Expression { lhs: Operand::Zero, rhs: Operand::Zero, .. } = expression {
+            if let Expression { lhs: CovTerm::Zero, rhs: CovTerm::Zero, .. } = expression {
                 zero_expressions.insert(id);
             }
         }
@@ -254,12 +254,12 @@ impl<'tcx> FunctionCoverage<'tcx> {
                 &Some(Expression { lhs, op, rhs, .. }) => {
                     // Convert the operands and operator as normal.
                     CounterExpression::new(
-                        Counter::from_operand(lhs),
+                        Counter::from_term(lhs),
                         match op {
                             Op::Add => ExprKind::Add,
                             Op::Subtract => ExprKind::Subtract,
                         },
-                        Counter::from_operand(rhs),
+                        Counter::from_term(rhs),
                     )
                 }
             })