about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--compiler/rustc_mir_transform/src/coverage/counters.rs8
-rw-r--r--compiler/rustc_mir_transform/src/coverage/query.rs19
-rw-r--r--tests/coverage/assert_not.cov-map12
-rw-r--r--tests/coverage/async2.cov-map12
-rw-r--r--tests/coverage/bad_counter_ids.cov-map18
-rw-r--r--tests/coverage/conditions.cov-map321
-rw-r--r--tests/coverage/drop_trait.cov-map6
-rw-r--r--tests/coverage/generics.cov-map6
-rw-r--r--tests/coverage/loops_branches.cov-map34
-rw-r--r--tests/coverage/try_error_result.cov-map24
-rw-r--r--tests/coverage/while.cov-map6
11 files changed, 237 insertions, 229 deletions
diff --git a/compiler/rustc_mir_transform/src/coverage/counters.rs b/compiler/rustc_mir_transform/src/coverage/counters.rs
index 6f9984d5d0a..039f346495b 100644
--- a/compiler/rustc_mir_transform/src/coverage/counters.rs
+++ b/compiler/rustc_mir_transform/src/coverage/counters.rs
@@ -114,12 +114,8 @@ pub(crate) fn transcribe_counters(
         let mut new_counters_for_sites = |sites: Vec<BasicCoverageBlock>| {
             sites.into_iter().map(|node| new.ensure_phys_counter(node)).collect::<Vec<_>>()
         };
-        let mut pos = new_counters_for_sites(pos);
-        let mut neg = new_counters_for_sites(neg);
-
-        // These sorts are also not strictly necessary; see above.
-        pos.sort();
-        neg.sort();
+        let pos = new_counters_for_sites(pos);
+        let neg = new_counters_for_sites(neg);
 
         let pos_counter = new.make_sum(&pos).unwrap_or(CovTerm::Zero);
         let new_counter = new.make_subtracted_sum(pos_counter, &neg);
diff --git a/compiler/rustc_mir_transform/src/coverage/query.rs b/compiler/rustc_mir_transform/src/coverage/query.rs
index cd89fbe772d..ef86358b205 100644
--- a/compiler/rustc_mir_transform/src/coverage/query.rs
+++ b/compiler/rustc_mir_transform/src/coverage/query.rs
@@ -123,11 +123,20 @@ fn coverage_ids_info<'tcx>(
         }
     }
 
-    // FIXME(Zalathar): It should be possible to sort `priority_list[1..]` by
-    // `!bcbs_seen.contains(bcb)` to simplify the mappings even further, at the
-    // expense of some churn in the tests. When doing so, also consider removing
-    // the sorts in `transcribe_counters`.
-    let node_counters = make_node_counters(&fn_cov_info.node_flow_data, &fn_cov_info.priority_list);
+    // Clone the priority list so that we can re-sort it.
+    let mut priority_list = fn_cov_info.priority_list.clone();
+    // The first ID in the priority list represents the synthetic "sink" node,
+    // and must remain first so that it _never_ gets a physical counter.
+    debug_assert_eq!(priority_list[0], priority_list.iter().copied().max().unwrap());
+    assert!(!bcbs_seen.contains(priority_list[0]));
+    // Partition the priority list, so that unreachable nodes (removed by MIR opts)
+    // are sorted later and therefore are _more_ likely to get a physical counter.
+    // This is counter-intuitive, but it means that `transcribe_counters` can
+    // easily skip those unused physical counters and replace them with zero.
+    // (The original ordering remains in effect within both partitions.)
+    priority_list[1..].sort_by_key(|&bcb| !bcbs_seen.contains(bcb));
+
+    let node_counters = make_node_counters(&fn_cov_info.node_flow_data, &priority_list);
     let coverage_counters = transcribe_counters(&node_counters, &bcb_needs_counter, &bcbs_seen);
 
     let CoverageCounters {
diff --git a/tests/coverage/assert_not.cov-map b/tests/coverage/assert_not.cov-map
index 35568a98af4..526110ebbb7 100644
--- a/tests/coverage/assert_not.cov-map
+++ b/tests/coverage/assert_not.cov-map
@@ -1,13 +1,13 @@
 Function name: assert_not::main
-Raw bytes (29): 0x[01, 01, 00, 05, 01, 06, 01, 01, 12, 05, 02, 05, 00, 14, 09, 01, 05, 00, 14, 0d, 01, 05, 00, 16, 0d, 01, 01, 00, 02]
+Raw bytes (29): 0x[01, 01, 00, 05, 01, 06, 01, 01, 12, 01, 02, 05, 00, 14, 01, 01, 05, 00, 14, 01, 01, 05, 00, 16, 01, 01, 01, 00, 02]
 Number of files: 1
 - file 0 => global file 1
 Number of expressions: 0
 Number of file 0 mappings: 5
 - Code(Counter(0)) at (prev + 6, 1) to (start + 1, 18)
-- Code(Counter(1)) at (prev + 2, 5) to (start + 0, 20)
-- Code(Counter(2)) at (prev + 1, 5) to (start + 0, 20)
-- Code(Counter(3)) at (prev + 1, 5) to (start + 0, 22)
-- Code(Counter(3)) at (prev + 1, 1) to (start + 0, 2)
-Highest counter ID seen: c3
+- Code(Counter(0)) at (prev + 2, 5) to (start + 0, 20)
+- Code(Counter(0)) at (prev + 1, 5) to (start + 0, 20)
+- Code(Counter(0)) at (prev + 1, 5) to (start + 0, 22)
+- Code(Counter(0)) at (prev + 1, 1) to (start + 0, 2)
+Highest counter ID seen: c0
 
diff --git a/tests/coverage/async2.cov-map b/tests/coverage/async2.cov-map
index 7660f917b65..c2a0645ee9a 100644
--- a/tests/coverage/async2.cov-map
+++ b/tests/coverage/async2.cov-map
@@ -8,16 +8,16 @@ Number of file 0 mappings: 1
 Highest counter ID seen: c0
 
 Function name: async2::async_func::{closure#0}
-Raw bytes (24): 0x[01, 01, 00, 04, 01, 0f, 17, 03, 09, 05, 03, 0a, 02, 06, 00, 02, 05, 00, 06, 01, 01, 01, 00, 02]
+Raw bytes (24): 0x[01, 01, 00, 04, 01, 0f, 17, 03, 09, 01, 03, 0a, 02, 06, 00, 02, 05, 00, 06, 01, 01, 01, 00, 02]
 Number of files: 1
 - file 0 => global file 1
 Number of expressions: 0
 Number of file 0 mappings: 4
 - Code(Counter(0)) at (prev + 15, 23) to (start + 3, 9)
-- Code(Counter(1)) at (prev + 3, 10) to (start + 2, 6)
+- Code(Counter(0)) at (prev + 3, 10) to (start + 2, 6)
 - Code(Zero) at (prev + 2, 5) to (start + 0, 6)
 - Code(Counter(0)) at (prev + 1, 1) to (start + 0, 2)
-Highest counter ID seen: c1
+Highest counter ID seen: c0
 
 Function name: async2::async_func_just_println
 Raw bytes (9): 0x[01, 01, 00, 01, 01, 17, 01, 00, 24]
@@ -47,14 +47,14 @@ Number of file 0 mappings: 1
 Highest counter ID seen: c0
 
 Function name: async2::non_async_func
-Raw bytes (24): 0x[01, 01, 00, 04, 01, 07, 01, 03, 09, 05, 03, 0a, 02, 06, 00, 02, 05, 00, 06, 01, 01, 01, 00, 02]
+Raw bytes (24): 0x[01, 01, 00, 04, 01, 07, 01, 03, 09, 01, 03, 0a, 02, 06, 00, 02, 05, 00, 06, 01, 01, 01, 00, 02]
 Number of files: 1
 - file 0 => global file 1
 Number of expressions: 0
 Number of file 0 mappings: 4
 - Code(Counter(0)) at (prev + 7, 1) to (start + 3, 9)
-- Code(Counter(1)) at (prev + 3, 10) to (start + 2, 6)
+- Code(Counter(0)) at (prev + 3, 10) to (start + 2, 6)
 - Code(Zero) at (prev + 2, 5) to (start + 0, 6)
 - Code(Counter(0)) at (prev + 1, 1) to (start + 0, 2)
-Highest counter ID seen: c1
+Highest counter ID seen: c0
 
diff --git a/tests/coverage/bad_counter_ids.cov-map b/tests/coverage/bad_counter_ids.cov-map
index ba306278449..baac0073fcb 100644
--- a/tests/coverage/bad_counter_ids.cov-map
+++ b/tests/coverage/bad_counter_ids.cov-map
@@ -20,25 +20,25 @@ Number of file 0 mappings: 3
 Highest counter ID seen: c0
 
 Function name: bad_counter_ids::eq_good
-Raw bytes (14): 0x[01, 01, 00, 02, 01, 10, 01, 02, 1f, 05, 03, 01, 00, 02]
+Raw bytes (14): 0x[01, 01, 00, 02, 01, 10, 01, 02, 1f, 01, 03, 01, 00, 02]
 Number of files: 1
 - file 0 => global file 1
 Number of expressions: 0
 Number of file 0 mappings: 2
 - Code(Counter(0)) at (prev + 16, 1) to (start + 2, 31)
-- Code(Counter(1)) at (prev + 3, 1) to (start + 0, 2)
-Highest counter ID seen: c1
+- Code(Counter(0)) at (prev + 3, 1) to (start + 0, 2)
+Highest counter ID seen: c0
 
 Function name: bad_counter_ids::eq_good_message
-Raw bytes (19): 0x[01, 01, 00, 03, 01, 15, 01, 02, 0f, 00, 02, 20, 00, 2b, 05, 01, 01, 00, 02]
+Raw bytes (19): 0x[01, 01, 00, 03, 01, 15, 01, 02, 0f, 00, 02, 20, 00, 2b, 01, 01, 01, 00, 02]
 Number of files: 1
 - file 0 => global file 1
 Number of expressions: 0
 Number of file 0 mappings: 3
 - Code(Counter(0)) at (prev + 21, 1) to (start + 2, 15)
 - Code(Zero) at (prev + 2, 32) to (start + 0, 43)
-- Code(Counter(1)) at (prev + 1, 1) to (start + 0, 2)
-Highest counter ID seen: c1
+- Code(Counter(0)) at (prev + 1, 1) to (start + 0, 2)
+Highest counter ID seen: c0
 
 Function name: bad_counter_ids::ne_bad
 Raw bytes (14): 0x[01, 01, 00, 02, 01, 2e, 01, 02, 1f, 00, 03, 01, 00, 02]
@@ -51,15 +51,15 @@ Number of file 0 mappings: 2
 Highest counter ID seen: c0
 
 Function name: bad_counter_ids::ne_bad_message
-Raw bytes (19): 0x[01, 01, 00, 03, 01, 33, 01, 02, 0f, 05, 02, 20, 00, 2b, 00, 01, 01, 00, 02]
+Raw bytes (19): 0x[01, 01, 00, 03, 01, 33, 01, 02, 0f, 01, 02, 20, 00, 2b, 00, 01, 01, 00, 02]
 Number of files: 1
 - file 0 => global file 1
 Number of expressions: 0
 Number of file 0 mappings: 3
 - Code(Counter(0)) at (prev + 51, 1) to (start + 2, 15)
-- Code(Counter(1)) at (prev + 2, 32) to (start + 0, 43)
+- Code(Counter(0)) at (prev + 2, 32) to (start + 0, 43)
 - Code(Zero) at (prev + 1, 1) to (start + 0, 2)
-Highest counter ID seen: c1
+Highest counter ID seen: c0
 
 Function name: bad_counter_ids::ne_good
 Raw bytes (14): 0x[01, 01, 00, 02, 01, 1a, 01, 02, 1f, 01, 03, 01, 00, 02]
diff --git a/tests/coverage/conditions.cov-map b/tests/coverage/conditions.cov-map
index 549b8bb0a20..2d12f4bf774 100644
--- a/tests/coverage/conditions.cov-map
+++ b/tests/coverage/conditions.cov-map
@@ -1,192 +1,191 @@
 Function name: conditions::main
-Raw bytes (545): 0x[01, 01, 4d, 09, 0d, 01, 09, 0d, 71, 0d, 27, 71, 75, 27, 79, 71, 75, 0d, 23, 27, 79, 71, 75, 01, 03, 03, 15, 19, 65, 19, 4f, 65, 69, 4f, 6d, 65, 69, 19, 4b, 4f, 6d, 65, 69, 03, ef, 01, 15, 19, 15, 19, 1d, 25, 29, 59, 29, 7f, 59, 5d, 7f, 61, 59, 5d, 29, 7b, 7f, 61, 59, 5d, 1d, 87, 01, 25, 29, e7, 01, 1d, eb, 01, 29, ef, 01, 25, 15, 19, 31, 35, e7, 01, 1d, eb, 01, 29, ef, 01, 25, 15, 19, e7, 01, f7, 01, eb, 01, 29, ef, 01, 25, 15, 19, 1d, 31, 35, 4d, 35, df, 01, 4d, 51, df, 01, 55, 4d, 51, 35, db, 01, df, 01, 55, 4d, 51, e7, 01, f3, 01, eb, 01, 29, ef, 01, 25, 15, 19, f7, 01, 35, 1d, 31, 39, 3d, 31, 35, af, 02, 39, 31, 35, 3d, 41, 3d, a7, 02, 41, 45, a7, 02, 49, 41, 45, 3d, a3, 02, a7, 02, 49, 41, 45, af, 02, b3, 02, 31, 35, 39, 3d, 44, 01, 03, 01, 02, 0c, 05, 02, 0d, 02, 06, 00, 02, 05, 00, 06, 03, 03, 09, 00, 0a, 01, 00, 10, 00, 1d, 09, 01, 09, 01, 0a, 06, 02, 0f, 00, 1c, 0d, 01, 0c, 00, 19, 0a, 00, 1d, 00, 2a, 0e, 00, 2e, 00, 3c, 23, 00, 3d, 02, 0a, 1e, 02, 09, 00, 0a, 0d, 01, 09, 01, 12, 2a, 03, 09, 00, 0f, 03, 03, 09, 01, 0c, 11, 01, 0d, 02, 06, 00, 02, 05, 00, 06, 03, 02, 08, 00, 15, 15, 00, 16, 02, 06, 2e, 02, 0f, 00, 1c, 19, 01, 0c, 00, 19, 32, 00, 1d, 00, 2a, 36, 00, 2e, 00, 3c, 4b, 00, 3d, 02, 0a, 46, 02, 09, 00, 0a, 19, 01, 09, 00, 17, 52, 02, 09, 00, 0f, ef, 01, 03, 08, 00, 0c, 1d, 01, 0d, 01, 10, 21, 01, 11, 02, 0a, 00, 02, 09, 00, 0a, 1d, 02, 0c, 00, 19, 25, 00, 1a, 02, 0a, 5e, 04, 11, 00, 1e, 29, 01, 10, 00, 1d, 62, 00, 21, 00, 2e, 66, 00, 32, 00, 40, 7b, 00, 41, 02, 0e, 76, 02, 0d, 00, 0e, 29, 01, 0d, 00, 1b, 82, 01, 02, 0d, 00, 13, 00, 02, 05, 00, 06, 9e, 01, 02, 09, 01, 0c, 2d, 01, 0d, 02, 06, 00, 02, 05, 00, 06, af, 02, 02, 09, 00, 0a, 9e, 01, 00, 10, 00, 1d, 31, 00, 1e, 02, 06, ae, 01, 02, 0f, 00, 1c, 35, 01, 0c, 00, 19, c2, 01, 00, 1d, 00, 2a, c6, 01, 00, 2e, 00, 3c, db, 01, 00, 3d, 02, 0a, d6, 01, 02, 09, 00, 0a, 35, 01, 09, 00, 17, e2, 01, 02, 0d, 02, 0f, b3, 02, 05, 09, 00, 0a, af, 02, 00, 10, 00, 1d, 39, 00, 1e, 02, 06, 82, 02, 02, 0f, 00, 1c, 3d, 01, 0c, 00, 19, 8a, 02, 00, 1d, 00, 2a, 8e, 02, 00, 2e, 00, 3c, a3, 02, 00, 3d, 02, 0a, 9e, 02, 02, 09, 00, 0a, 3d, 01, 09, 00, 17, aa, 02, 02, 09, 00, 0f, 01, 02, 01, 00, 02]
+Raw bytes (533): 0x[01, 01, 47, 05, 09, 01, 05, 09, 5d, 09, 27, 5d, 61, 27, 65, 5d, 61, 09, 23, 27, 65, 5d, 61, 01, 03, 03, 0d, 11, 51, 11, 4f, 51, 55, 4f, 59, 51, 55, 11, 4b, 4f, 59, 51, 55, 03, 97, 01, 0d, 11, 0d, 11, 0d, 11, 0d, 11, 0d, 11, 97, 01, 15, 0d, 11, 19, 45, 19, 8f, 01, 45, 49, 8f, 01, 4d, 45, 49, 19, 8b, 01, 8f, 01, 4d, 45, 49, 97, 01, db, 01, 0d, 11, 15, 19, 15, 19, 15, 19, 1d, 21, 15, 19, db, 01, 1d, 15, 19, 21, 39, 21, d3, 01, 39, 3d, d3, 01, 41, 39, 3d, 21, cf, 01, d3, 01, 41, 39, 3d, db, 01, 97, 02, 15, 19, 1d, 21, 25, 29, 1d, 21, 97, 02, 25, 1d, 21, 29, 2d, 29, 8f, 02, 2d, 31, 8f, 02, 35, 2d, 31, 29, 8b, 02, 8f, 02, 35, 2d, 31, 97, 02, 9b, 02, 1d, 21, 25, 29, 44, 01, 03, 01, 02, 0c, 01, 02, 0d, 02, 06, 00, 02, 05, 00, 06, 03, 03, 09, 00, 0a, 01, 00, 10, 00, 1d, 05, 01, 09, 01, 0a, 06, 02, 0f, 00, 1c, 09, 01, 0c, 00, 19, 0a, 00, 1d, 00, 2a, 0e, 00, 2e, 00, 3c, 23, 00, 3d, 02, 0a, 1e, 02, 09, 00, 0a, 09, 01, 09, 01, 12, 2a, 03, 09, 00, 0f, 03, 03, 09, 01, 0c, 03, 01, 0d, 02, 06, 00, 02, 05, 00, 06, 03, 02, 08, 00, 15, 0d, 00, 16, 02, 06, 2e, 02, 0f, 00, 1c, 11, 01, 0c, 00, 19, 32, 00, 1d, 00, 2a, 36, 00, 2e, 00, 3c, 4b, 00, 3d, 02, 0a, 46, 02, 09, 00, 0a, 11, 01, 09, 00, 17, 52, 02, 09, 00, 0f, 97, 01, 03, 08, 00, 0c, 97, 01, 01, 0d, 01, 10, 97, 01, 01, 11, 02, 0a, 00, 02, 09, 00, 0a, 97, 01, 02, 0c, 00, 19, 15, 00, 1a, 02, 0a, 6a, 04, 11, 00, 1e, 19, 01, 10, 00, 1d, 72, 00, 21, 00, 2e, 76, 00, 32, 00, 40, 8b, 01, 00, 41, 02, 0e, 86, 01, 02, 0d, 00, 0e, 19, 01, 0d, 00, 1b, 92, 01, 02, 0d, 00, 13, 00, 02, 05, 00, 06, db, 01, 02, 09, 01, 0c, db, 01, 01, 0d, 02, 06, 00, 02, 05, 00, 06, 97, 02, 02, 09, 00, 0a, db, 01, 00, 10, 00, 1d, 1d, 00, 1e, 02, 06, ae, 01, 02, 0f, 00, 1c, 21, 01, 0c, 00, 19, b6, 01, 00, 1d, 00, 2a, ba, 01, 00, 2e, 00, 3c, cf, 01, 00, 3d, 02, 0a, ca, 01, 02, 09, 00, 0a, 21, 01, 09, 00, 17, d6, 01, 02, 0d, 02, 0f, 9b, 02, 05, 09, 00, 0a, 97, 02, 00, 10, 00, 1d, 25, 00, 1e, 02, 06, ea, 01, 02, 0f, 00, 1c, 29, 01, 0c, 00, 19, f2, 01, 00, 1d, 00, 2a, f6, 01, 00, 2e, 00, 3c, 8b, 02, 00, 3d, 02, 0a, 86, 02, 02, 09, 00, 0a, 29, 01, 09, 00, 17, 92, 02, 02, 09, 00, 0f, 01, 02, 01, 00, 02]
 Number of files: 1
 - file 0 => global file 1
-Number of expressions: 77
-- expression 0 operands: lhs = Counter(2), rhs = Counter(3)
-- expression 1 operands: lhs = Counter(0), rhs = Counter(2)
-- expression 2 operands: lhs = Counter(3), rhs = Counter(28)
-- expression 3 operands: lhs = Counter(3), rhs = Expression(9, Add)
-- expression 4 operands: lhs = Counter(28), rhs = Counter(29)
-- expression 5 operands: lhs = Expression(9, Add), rhs = Counter(30)
-- expression 6 operands: lhs = Counter(28), rhs = Counter(29)
-- expression 7 operands: lhs = Counter(3), rhs = Expression(8, Add)
-- expression 8 operands: lhs = Expression(9, Add), rhs = Counter(30)
-- expression 9 operands: lhs = Counter(28), rhs = Counter(29)
+Number of expressions: 71
+- expression 0 operands: lhs = Counter(1), rhs = Counter(2)
+- expression 1 operands: lhs = Counter(0), rhs = Counter(1)
+- expression 2 operands: lhs = Counter(2), rhs = Counter(23)
+- expression 3 operands: lhs = Counter(2), rhs = Expression(9, Add)
+- expression 4 operands: lhs = Counter(23), rhs = Counter(24)
+- expression 5 operands: lhs = Expression(9, Add), rhs = Counter(25)
+- expression 6 operands: lhs = Counter(23), rhs = Counter(24)
+- expression 7 operands: lhs = Counter(2), rhs = Expression(8, Add)
+- expression 8 operands: lhs = Expression(9, Add), rhs = Counter(25)
+- expression 9 operands: lhs = Counter(23), rhs = Counter(24)
 - expression 10 operands: lhs = Counter(0), rhs = Expression(0, Add)
-- expression 11 operands: lhs = Expression(0, Add), rhs = Counter(5)
-- expression 12 operands: lhs = Counter(6), rhs = Counter(25)
-- expression 13 operands: lhs = Counter(6), rhs = Expression(19, Add)
-- expression 14 operands: lhs = Counter(25), rhs = Counter(26)
-- expression 15 operands: lhs = Expression(19, Add), rhs = Counter(27)
-- expression 16 operands: lhs = Counter(25), rhs = Counter(26)
-- expression 17 operands: lhs = Counter(6), rhs = Expression(18, Add)
-- expression 18 operands: lhs = Expression(19, Add), rhs = Counter(27)
-- expression 19 operands: lhs = Counter(25), rhs = Counter(26)
-- expression 20 operands: lhs = Expression(0, Add), rhs = Expression(59, Add)
-- expression 21 operands: lhs = Counter(5), rhs = Counter(6)
-- expression 22 operands: lhs = Counter(5), rhs = Counter(6)
-- expression 23 operands: lhs = Counter(7), rhs = Counter(9)
-- expression 24 operands: lhs = Counter(10), rhs = Counter(22)
-- expression 25 operands: lhs = Counter(10), rhs = Expression(31, Add)
-- expression 26 operands: lhs = Counter(22), rhs = Counter(23)
-- expression 27 operands: lhs = Expression(31, Add), rhs = Counter(24)
-- expression 28 operands: lhs = Counter(22), rhs = Counter(23)
-- expression 29 operands: lhs = Counter(10), rhs = Expression(30, Add)
-- expression 30 operands: lhs = Expression(31, Add), rhs = Counter(24)
-- expression 31 operands: lhs = Counter(22), rhs = Counter(23)
-- expression 32 operands: lhs = Counter(7), rhs = Expression(33, Add)
-- expression 33 operands: lhs = Counter(9), rhs = Counter(10)
-- expression 34 operands: lhs = Expression(57, Add), rhs = Counter(7)
-- expression 35 operands: lhs = Expression(58, Add), rhs = Counter(10)
-- expression 36 operands: lhs = Expression(59, Add), rhs = Counter(9)
-- expression 37 operands: lhs = Counter(5), rhs = Counter(6)
-- expression 38 operands: lhs = Counter(12), rhs = Counter(13)
-- expression 39 operands: lhs = Expression(57, Add), rhs = Counter(7)
-- expression 40 operands: lhs = Expression(58, Add), rhs = Counter(10)
-- expression 41 operands: lhs = Expression(59, Add), rhs = Counter(9)
+- expression 11 operands: lhs = Expression(0, Add), rhs = Counter(3)
+- expression 12 operands: lhs = Counter(4), rhs = Counter(20)
+- expression 13 operands: lhs = Counter(4), rhs = Expression(19, Add)
+- expression 14 operands: lhs = Counter(20), rhs = Counter(21)
+- expression 15 operands: lhs = Expression(19, Add), rhs = Counter(22)
+- expression 16 operands: lhs = Counter(20), rhs = Counter(21)
+- expression 17 operands: lhs = Counter(4), rhs = Expression(18, Add)
+- expression 18 operands: lhs = Expression(19, Add), rhs = Counter(22)
+- expression 19 operands: lhs = Counter(20), rhs = Counter(21)
+- expression 20 operands: lhs = Expression(0, Add), rhs = Expression(37, Add)
+- expression 21 operands: lhs = Counter(3), rhs = Counter(4)
+- expression 22 operands: lhs = Counter(3), rhs = Counter(4)
+- expression 23 operands: lhs = Counter(3), rhs = Counter(4)
+- expression 24 operands: lhs = Counter(3), rhs = Counter(4)
+- expression 25 operands: lhs = Counter(3), rhs = Counter(4)
+- expression 26 operands: lhs = Expression(37, Add), rhs = Counter(5)
+- expression 27 operands: lhs = Counter(3), rhs = Counter(4)
+- expression 28 operands: lhs = Counter(6), rhs = Counter(17)
+- expression 29 operands: lhs = Counter(6), rhs = Expression(35, Add)
+- expression 30 operands: lhs = Counter(17), rhs = Counter(18)
+- expression 31 operands: lhs = Expression(35, Add), rhs = Counter(19)
+- expression 32 operands: lhs = Counter(17), rhs = Counter(18)
+- expression 33 operands: lhs = Counter(6), rhs = Expression(34, Add)
+- expression 34 operands: lhs = Expression(35, Add), rhs = Counter(19)
+- expression 35 operands: lhs = Counter(17), rhs = Counter(18)
+- expression 36 operands: lhs = Expression(37, Add), rhs = Expression(54, Add)
+- expression 37 operands: lhs = Counter(3), rhs = Counter(4)
+- expression 38 operands: lhs = Counter(5), rhs = Counter(6)
+- expression 39 operands: lhs = Counter(5), rhs = Counter(6)
+- expression 40 operands: lhs = Counter(5), rhs = Counter(6)
+- expression 41 operands: lhs = Counter(7), rhs = Counter(8)
 - expression 42 operands: lhs = Counter(5), rhs = Counter(6)
-- expression 43 operands: lhs = Expression(57, Add), rhs = Expression(61, Add)
-- expression 44 operands: lhs = Expression(58, Add), rhs = Counter(10)
-- expression 45 operands: lhs = Expression(59, Add), rhs = Counter(9)
-- expression 46 operands: lhs = Counter(5), rhs = Counter(6)
-- expression 47 operands: lhs = Counter(7), rhs = Counter(12)
-- expression 48 operands: lhs = Counter(13), rhs = Counter(19)
-- expression 49 operands: lhs = Counter(13), rhs = Expression(55, Add)
-- expression 50 operands: lhs = Counter(19), rhs = Counter(20)
-- expression 51 operands: lhs = Expression(55, Add), rhs = Counter(21)
-- expression 52 operands: lhs = Counter(19), rhs = Counter(20)
-- expression 53 operands: lhs = Counter(13), rhs = Expression(54, Add)
-- expression 54 operands: lhs = Expression(55, Add), rhs = Counter(21)
-- expression 55 operands: lhs = Counter(19), rhs = Counter(20)
-- expression 56 operands: lhs = Expression(57, Add), rhs = Expression(60, Add)
-- expression 57 operands: lhs = Expression(58, Add), rhs = Counter(10)
-- expression 58 operands: lhs = Expression(59, Add), rhs = Counter(9)
-- expression 59 operands: lhs = Counter(5), rhs = Counter(6)
-- expression 60 operands: lhs = Expression(61, Add), rhs = Counter(13)
-- expression 61 operands: lhs = Counter(7), rhs = Counter(12)
-- expression 62 operands: lhs = Counter(14), rhs = Counter(15)
-- expression 63 operands: lhs = Counter(12), rhs = Counter(13)
-- expression 64 operands: lhs = Expression(75, Add), rhs = Counter(14)
-- expression 65 operands: lhs = Counter(12), rhs = Counter(13)
-- expression 66 operands: lhs = Counter(15), rhs = Counter(16)
-- expression 67 operands: lhs = Counter(15), rhs = Expression(73, Add)
-- expression 68 operands: lhs = Counter(16), rhs = Counter(17)
-- expression 69 operands: lhs = Expression(73, Add), rhs = Counter(18)
-- expression 70 operands: lhs = Counter(16), rhs = Counter(17)
-- expression 71 operands: lhs = Counter(15), rhs = Expression(72, Add)
-- expression 72 operands: lhs = Expression(73, Add), rhs = Counter(18)
-- expression 73 operands: lhs = Counter(16), rhs = Counter(17)
-- expression 74 operands: lhs = Expression(75, Add), rhs = Expression(76, Add)
-- expression 75 operands: lhs = Counter(12), rhs = Counter(13)
-- expression 76 operands: lhs = Counter(14), rhs = Counter(15)
+- expression 43 operands: lhs = Expression(54, Add), rhs = Counter(7)
+- expression 44 operands: lhs = Counter(5), rhs = Counter(6)
+- expression 45 operands: lhs = Counter(8), rhs = Counter(14)
+- expression 46 operands: lhs = Counter(8), rhs = Expression(52, Add)
+- expression 47 operands: lhs = Counter(14), rhs = Counter(15)
+- expression 48 operands: lhs = Expression(52, Add), rhs = Counter(16)
+- expression 49 operands: lhs = Counter(14), rhs = Counter(15)
+- expression 50 operands: lhs = Counter(8), rhs = Expression(51, Add)
+- expression 51 operands: lhs = Expression(52, Add), rhs = Counter(16)
+- expression 52 operands: lhs = Counter(14), rhs = Counter(15)
+- expression 53 operands: lhs = Expression(54, Add), rhs = Expression(69, Add)
+- expression 54 operands: lhs = Counter(5), rhs = Counter(6)
+- expression 55 operands: lhs = Counter(7), rhs = Counter(8)
+- expression 56 operands: lhs = Counter(9), rhs = Counter(10)
+- expression 57 operands: lhs = Counter(7), rhs = Counter(8)
+- expression 58 operands: lhs = Expression(69, Add), rhs = Counter(9)
+- expression 59 operands: lhs = Counter(7), rhs = Counter(8)
+- expression 60 operands: lhs = Counter(10), rhs = Counter(11)
+- expression 61 operands: lhs = Counter(10), rhs = Expression(67, Add)
+- expression 62 operands: lhs = Counter(11), rhs = Counter(12)
+- expression 63 operands: lhs = Expression(67, Add), rhs = Counter(13)
+- expression 64 operands: lhs = Counter(11), rhs = Counter(12)
+- expression 65 operands: lhs = Counter(10), rhs = Expression(66, Add)
+- expression 66 operands: lhs = Expression(67, Add), rhs = Counter(13)
+- expression 67 operands: lhs = Counter(11), rhs = Counter(12)
+- expression 68 operands: lhs = Expression(69, Add), rhs = Expression(70, Add)
+- expression 69 operands: lhs = Counter(7), rhs = Counter(8)
+- expression 70 operands: lhs = Counter(9), rhs = Counter(10)
 Number of file 0 mappings: 68
 - Code(Counter(0)) at (prev + 3, 1) to (start + 2, 12)
-- Code(Counter(1)) at (prev + 2, 13) to (start + 2, 6)
+- Code(Counter(0)) at (prev + 2, 13) to (start + 2, 6)
 - Code(Zero) at (prev + 2, 5) to (start + 0, 6)
 - Code(Expression(0, Add)) at (prev + 3, 9) to (start + 0, 10)
-    = (c2 + c3)
+    = (c1 + c2)
 - Code(Counter(0)) at (prev + 0, 16) to (start + 0, 29)
-- Code(Counter(2)) at (prev + 1, 9) to (start + 1, 10)
+- Code(Counter(1)) at (prev + 1, 9) to (start + 1, 10)
 - Code(Expression(1, Sub)) at (prev + 2, 15) to (start + 0, 28)
-    = (c0 - c2)
-- Code(Counter(3)) at (prev + 1, 12) to (start + 0, 25)
+    = (c0 - c1)
+- Code(Counter(2)) at (prev + 1, 12) to (start + 0, 25)
 - Code(Expression(2, Sub)) at (prev + 0, 29) to (start + 0, 42)
-    = (c3 - c28)
+    = (c2 - c23)
 - Code(Expression(3, Sub)) at (prev + 0, 46) to (start + 0, 60)
-    = (c3 - (c28 + c29))
+    = (c2 - (c23 + c24))
 - Code(Expression(8, Add)) at (prev + 0, 61) to (start + 2, 10)
-    = ((c28 + c29) + c30)
+    = ((c23 + c24) + c25)
 - Code(Expression(7, Sub)) at (prev + 2, 9) to (start + 0, 10)
-    = (c3 - ((c28 + c29) + c30))
-- Code(Counter(3)) at (prev + 1, 9) to (start + 1, 18)
+    = (c2 - ((c23 + c24) + c25))
+- Code(Counter(2)) at (prev + 1, 9) to (start + 1, 18)
 - Code(Expression(10, Sub)) at (prev + 3, 9) to (start + 0, 15)
-    = (c0 - (c2 + c3))
+    = (c0 - (c1 + c2))
 - Code(Expression(0, Add)) at (prev + 3, 9) to (start + 1, 12)
-    = (c2 + c3)
-- Code(Counter(4)) at (prev + 1, 13) to (start + 2, 6)
+    = (c1 + c2)
+- Code(Expression(0, Add)) at (prev + 1, 13) to (start + 2, 6)
+    = (c1 + c2)
 - Code(Zero) at (prev + 2, 5) to (start + 0, 6)
 - Code(Expression(0, Add)) at (prev + 2, 8) to (start + 0, 21)
-    = (c2 + c3)
-- Code(Counter(5)) at (prev + 0, 22) to (start + 2, 6)
+    = (c1 + c2)
+- Code(Counter(3)) at (prev + 0, 22) to (start + 2, 6)
 - Code(Expression(11, Sub)) at (prev + 2, 15) to (start + 0, 28)
-    = ((c2 + c3) - c5)
-- Code(Counter(6)) at (prev + 1, 12) to (start + 0, 25)
+    = ((c1 + c2) - c3)
+- Code(Counter(4)) at (prev + 1, 12) to (start + 0, 25)
 - Code(Expression(12, Sub)) at (prev + 0, 29) to (start + 0, 42)
-    = (c6 - c25)
+    = (c4 - c20)
 - Code(Expression(13, Sub)) at (prev + 0, 46) to (start + 0, 60)
-    = (c6 - (c25 + c26))
+    = (c4 - (c20 + c21))
 - Code(Expression(18, Add)) at (prev + 0, 61) to (start + 2, 10)
-    = ((c25 + c26) + c27)
+    = ((c20 + c21) + c22)
 - Code(Expression(17, Sub)) at (prev + 2, 9) to (start + 0, 10)
-    = (c6 - ((c25 + c26) + c27))
-- Code(Counter(6)) at (prev + 1, 9) to (start + 0, 23)
+    = (c4 - ((c20 + c21) + c22))
+- Code(Counter(4)) at (prev + 1, 9) to (start + 0, 23)
 - Code(Expression(20, Sub)) at (prev + 2, 9) to (start + 0, 15)
-    = ((c2 + c3) - (c5 + c6))
-- Code(Expression(59, Add)) at (prev + 3, 8) to (start + 0, 12)
-    = (c5 + c6)
-- Code(Counter(7)) at (prev + 1, 13) to (start + 1, 16)
-- Code(Counter(8)) at (prev + 1, 17) to (start + 2, 10)
+    = ((c1 + c2) - (c3 + c4))
+- Code(Expression(37, Add)) at (prev + 3, 8) to (start + 0, 12)
+    = (c3 + c4)
+- Code(Expression(37, Add)) at (prev + 1, 13) to (start + 1, 16)
+    = (c3 + c4)
+- Code(Expression(37, Add)) at (prev + 1, 17) to (start + 2, 10)
+    = (c3 + c4)
 - Code(Zero) at (prev + 2, 9) to (start + 0, 10)
-- Code(Counter(7)) at (prev + 2, 12) to (start + 0, 25)
-- Code(Counter(9)) at (prev + 0, 26) to (start + 2, 10)
-- Code(Expression(23, Sub)) at (prev + 4, 17) to (start + 0, 30)
-    = (c7 - c9)
-- Code(Counter(10)) at (prev + 1, 16) to (start + 0, 29)
-- Code(Expression(24, Sub)) at (prev + 0, 33) to (start + 0, 46)
-    = (c10 - c22)
-- Code(Expression(25, Sub)) at (prev + 0, 50) to (start + 0, 64)
-    = (c10 - (c22 + c23))
-- Code(Expression(30, Add)) at (prev + 0, 65) to (start + 2, 14)
-    = ((c22 + c23) + c24)
-- Code(Expression(29, Sub)) at (prev + 2, 13) to (start + 0, 14)
-    = (c10 - ((c22 + c23) + c24))
-- Code(Counter(10)) at (prev + 1, 13) to (start + 0, 27)
-- Code(Expression(32, Sub)) at (prev + 2, 13) to (start + 0, 19)
-    = (c7 - (c9 + c10))
+- Code(Expression(37, Add)) at (prev + 2, 12) to (start + 0, 25)
+    = (c3 + c4)
+- Code(Counter(5)) at (prev + 0, 26) to (start + 2, 10)
+- Code(Expression(26, Sub)) at (prev + 4, 17) to (start + 0, 30)
+    = ((c3 + c4) - c5)
+- Code(Counter(6)) at (prev + 1, 16) to (start + 0, 29)
+- Code(Expression(28, Sub)) at (prev + 0, 33) to (start + 0, 46)
+    = (c6 - c17)
+- Code(Expression(29, Sub)) at (prev + 0, 50) to (start + 0, 64)
+    = (c6 - (c17 + c18))
+- Code(Expression(34, Add)) at (prev + 0, 65) to (start + 2, 14)
+    = ((c17 + c18) + c19)
+- Code(Expression(33, Sub)) at (prev + 2, 13) to (start + 0, 14)
+    = (c6 - ((c17 + c18) + c19))
+- Code(Counter(6)) at (prev + 1, 13) to (start + 0, 27)
+- Code(Expression(36, Sub)) at (prev + 2, 13) to (start + 0, 19)
+    = ((c3 + c4) - (c5 + c6))
 - Code(Zero) at (prev + 2, 5) to (start + 0, 6)
-- Code(Expression(39, Sub)) at (prev + 2, 9) to (start + 1, 12)
-    = ((((c5 + c6) + c9) + c10) - c7)
-- Code(Counter(11)) at (prev + 1, 13) to (start + 2, 6)
+- Code(Expression(54, Add)) at (prev + 2, 9) to (start + 1, 12)
+    = (c5 + c6)
+- Code(Expression(54, Add)) at (prev + 1, 13) to (start + 2, 6)
+    = (c5 + c6)
 - Code(Zero) at (prev + 2, 5) to (start + 0, 6)
-- Code(Expression(75, Add)) at (prev + 2, 9) to (start + 0, 10)
-    = (c12 + c13)
-- Code(Expression(39, Sub)) at (prev + 0, 16) to (start + 0, 29)
-    = ((((c5 + c6) + c9) + c10) - c7)
-- Code(Counter(12)) at (prev + 0, 30) to (start + 2, 6)
+- Code(Expression(69, Add)) at (prev + 2, 9) to (start + 0, 10)
+    = (c7 + c8)
+- Code(Expression(54, Add)) at (prev + 0, 16) to (start + 0, 29)
+    = (c5 + c6)
+- Code(Counter(7)) at (prev + 0, 30) to (start + 2, 6)
 - Code(Expression(43, Sub)) at (prev + 2, 15) to (start + 0, 28)
-    = ((((c5 + c6) + c9) + c10) - (c7 + c12))
-- Code(Counter(13)) at (prev + 1, 12) to (start + 0, 25)
-- Code(Expression(48, Sub)) at (prev + 0, 29) to (start + 0, 42)
-    = (c13 - c19)
-- Code(Expression(49, Sub)) at (prev + 0, 46) to (start + 0, 60)
-    = (c13 - (c19 + c20))
-- Code(Expression(54, Add)) at (prev + 0, 61) to (start + 2, 10)
-    = ((c19 + c20) + c21)
-- Code(Expression(53, Sub)) at (prev + 2, 9) to (start + 0, 10)
-    = (c13 - ((c19 + c20) + c21))
-- Code(Counter(13)) at (prev + 1, 9) to (start + 0, 23)
-- Code(Expression(56, Sub)) at (prev + 2, 13) to (start + 2, 15)
-    = ((((c5 + c6) + c9) + c10) - ((c7 + c12) + c13))
-- Code(Expression(76, Add)) at (prev + 5, 9) to (start + 0, 10)
-    = (c14 + c15)
-- Code(Expression(75, Add)) at (prev + 0, 16) to (start + 0, 29)
-    = (c12 + c13)
-- Code(Counter(14)) at (prev + 0, 30) to (start + 2, 6)
-- Code(Expression(64, Sub)) at (prev + 2, 15) to (start + 0, 28)
-    = ((c12 + c13) - c14)
-- Code(Counter(15)) at (prev + 1, 12) to (start + 0, 25)
-- Code(Expression(66, Sub)) at (prev + 0, 29) to (start + 0, 42)
-    = (c15 - c16)
-- Code(Expression(67, Sub)) at (prev + 0, 46) to (start + 0, 60)
-    = (c15 - (c16 + c17))
-- Code(Expression(72, Add)) at (prev + 0, 61) to (start + 2, 10)
-    = ((c16 + c17) + c18)
-- Code(Expression(71, Sub)) at (prev + 2, 9) to (start + 0, 10)
-    = (c15 - ((c16 + c17) + c18))
-- Code(Counter(15)) at (prev + 1, 9) to (start + 0, 23)
-- Code(Expression(74, Sub)) at (prev + 2, 9) to (start + 0, 15)
-    = ((c12 + c13) - (c14 + c15))
+    = ((c5 + c6) - c7)
+- Code(Counter(8)) at (prev + 1, 12) to (start + 0, 25)
+- Code(Expression(45, Sub)) at (prev + 0, 29) to (start + 0, 42)
+    = (c8 - c14)
+- Code(Expression(46, Sub)) at (prev + 0, 46) to (start + 0, 60)
+    = (c8 - (c14 + c15))
+- Code(Expression(51, Add)) at (prev + 0, 61) to (start + 2, 10)
+    = ((c14 + c15) + c16)
+- Code(Expression(50, Sub)) at (prev + 2, 9) to (start + 0, 10)
+    = (c8 - ((c14 + c15) + c16))
+- Code(Counter(8)) at (prev + 1, 9) to (start + 0, 23)
+- Code(Expression(53, Sub)) at (prev + 2, 13) to (start + 2, 15)
+    = ((c5 + c6) - (c7 + c8))
+- Code(Expression(70, Add)) at (prev + 5, 9) to (start + 0, 10)
+    = (c9 + c10)
+- Code(Expression(69, Add)) at (prev + 0, 16) to (start + 0, 29)
+    = (c7 + c8)
+- Code(Counter(9)) at (prev + 0, 30) to (start + 2, 6)
+- Code(Expression(58, Sub)) at (prev + 2, 15) to (start + 0, 28)
+    = ((c7 + c8) - c9)
+- Code(Counter(10)) at (prev + 1, 12) to (start + 0, 25)
+- Code(Expression(60, Sub)) at (prev + 0, 29) to (start + 0, 42)
+    = (c10 - c11)
+- Code(Expression(61, Sub)) at (prev + 0, 46) to (start + 0, 60)
+    = (c10 - (c11 + c12))
+- Code(Expression(66, Add)) at (prev + 0, 61) to (start + 2, 10)
+    = ((c11 + c12) + c13)
+- Code(Expression(65, Sub)) at (prev + 2, 9) to (start + 0, 10)
+    = (c10 - ((c11 + c12) + c13))
+- Code(Counter(10)) at (prev + 1, 9) to (start + 0, 23)
+- Code(Expression(68, Sub)) at (prev + 2, 9) to (start + 0, 15)
+    = ((c7 + c8) - (c9 + c10))
 - Code(Counter(0)) at (prev + 2, 1) to (start + 0, 2)
-Highest counter ID seen: c15
+Highest counter ID seen: c10
 
diff --git a/tests/coverage/drop_trait.cov-map b/tests/coverage/drop_trait.cov-map
index a97c0f8794c..16facf2eddf 100644
--- a/tests/coverage/drop_trait.cov-map
+++ b/tests/coverage/drop_trait.cov-map
@@ -8,14 +8,14 @@ Number of file 0 mappings: 1
 Highest counter ID seen: c0
 
 Function name: drop_trait::main
-Raw bytes (24): 0x[01, 01, 00, 04, 01, 0e, 01, 05, 0c, 05, 06, 09, 01, 16, 00, 02, 06, 04, 0b, 01, 05, 01, 00, 02]
+Raw bytes (24): 0x[01, 01, 00, 04, 01, 0e, 01, 05, 0c, 01, 06, 09, 01, 16, 00, 02, 06, 04, 0b, 01, 05, 01, 00, 02]
 Number of files: 1
 - file 0 => global file 1
 Number of expressions: 0
 Number of file 0 mappings: 4
 - Code(Counter(0)) at (prev + 14, 1) to (start + 5, 12)
-- Code(Counter(1)) at (prev + 6, 9) to (start + 1, 22)
+- Code(Counter(0)) at (prev + 6, 9) to (start + 1, 22)
 - Code(Zero) at (prev + 2, 6) to (start + 4, 11)
 - Code(Counter(0)) at (prev + 5, 1) to (start + 0, 2)
-Highest counter ID seen: c1
+Highest counter ID seen: c0
 
diff --git a/tests/coverage/generics.cov-map b/tests/coverage/generics.cov-map
index d082bd54493..bc5661afdc1 100644
--- a/tests/coverage/generics.cov-map
+++ b/tests/coverage/generics.cov-map
@@ -35,14 +35,14 @@ Number of file 0 mappings: 1
 Highest counter ID seen: c0
 
 Function name: generics::main
-Raw bytes (24): 0x[01, 01, 00, 04, 01, 16, 01, 08, 0c, 05, 09, 09, 01, 16, 00, 02, 06, 04, 0b, 01, 05, 01, 00, 02]
+Raw bytes (24): 0x[01, 01, 00, 04, 01, 16, 01, 08, 0c, 01, 09, 09, 01, 16, 00, 02, 06, 04, 0b, 01, 05, 01, 00, 02]
 Number of files: 1
 - file 0 => global file 1
 Number of expressions: 0
 Number of file 0 mappings: 4
 - Code(Counter(0)) at (prev + 22, 1) to (start + 8, 12)
-- Code(Counter(1)) at (prev + 9, 9) to (start + 1, 22)
+- Code(Counter(0)) at (prev + 9, 9) to (start + 1, 22)
 - Code(Zero) at (prev + 2, 6) to (start + 4, 11)
 - Code(Counter(0)) at (prev + 5, 1) to (start + 0, 2)
-Highest counter ID seen: c1
+Highest counter ID seen: c0
 
diff --git a/tests/coverage/loops_branches.cov-map b/tests/coverage/loops_branches.cov-map
index 640d5f15be0..2cb0f948b3e 100644
--- a/tests/coverage/loops_branches.cov-map
+++ b/tests/coverage/loops_branches.cov-map
@@ -1,36 +1,36 @@
 Function name: <loops_branches::DebugTest as core::fmt::Debug>::fmt
-Raw bytes (112): 0x[01, 01, 04, 07, 0b, 01, 11, 09, 0d, 0d, 11, 14, 01, 09, 05, 01, 10, 05, 02, 10, 00, 15, 00, 01, 17, 00, 1b, 00, 00, 1c, 00, 1e, 05, 01, 0d, 00, 0e, 05, 01, 0d, 00, 1e, 09, 00, 1e, 00, 1f, 00, 01, 10, 01, 0a, 11, 03, 0d, 00, 0e, 0d, 00, 12, 00, 17, 11, 01, 10, 00, 14, 15, 01, 14, 00, 19, 00, 01, 1b, 00, 1f, 00, 00, 20, 00, 22, 15, 01, 11, 00, 12, 15, 01, 11, 00, 22, 02, 00, 22, 00, 23, 00, 01, 14, 01, 0e, 0e, 03, 09, 00, 0f, 01, 01, 05, 00, 06]
+Raw bytes (112): 0x[01, 01, 04, 07, 0b, 01, 0d, 05, 09, 09, 0d, 14, 01, 09, 05, 01, 10, 01, 02, 10, 00, 15, 00, 01, 17, 00, 1b, 00, 00, 1c, 00, 1e, 01, 01, 0d, 00, 0e, 01, 01, 0d, 00, 1e, 05, 00, 1e, 00, 1f, 00, 01, 10, 01, 0a, 0d, 03, 0d, 00, 0e, 09, 00, 12, 00, 17, 0d, 01, 10, 00, 14, 0d, 01, 14, 00, 19, 00, 01, 1b, 00, 1f, 00, 00, 20, 00, 22, 0d, 01, 11, 00, 12, 0d, 01, 11, 00, 22, 02, 00, 22, 00, 23, 00, 01, 14, 01, 0e, 0e, 03, 09, 00, 0f, 01, 01, 05, 00, 06]
 Number of files: 1
 - file 0 => global file 1
 Number of expressions: 4
 - expression 0 operands: lhs = Expression(1, Add), rhs = Expression(2, Add)
-- expression 1 operands: lhs = Counter(0), rhs = Counter(4)
-- expression 2 operands: lhs = Counter(2), rhs = Counter(3)
-- expression 3 operands: lhs = Counter(3), rhs = Counter(4)
+- expression 1 operands: lhs = Counter(0), rhs = Counter(3)
+- expression 2 operands: lhs = Counter(1), rhs = Counter(2)
+- expression 3 operands: lhs = Counter(2), rhs = Counter(3)
 Number of file 0 mappings: 20
 - Code(Counter(0)) at (prev + 9, 5) to (start + 1, 16)
-- Code(Counter(1)) at (prev + 2, 16) to (start + 0, 21)
+- Code(Counter(0)) at (prev + 2, 16) to (start + 0, 21)
 - Code(Zero) at (prev + 1, 23) to (start + 0, 27)
 - Code(Zero) at (prev + 0, 28) to (start + 0, 30)
-- Code(Counter(1)) at (prev + 1, 13) to (start + 0, 14)
-- Code(Counter(1)) at (prev + 1, 13) to (start + 0, 30)
-- Code(Counter(2)) at (prev + 0, 30) to (start + 0, 31)
+- Code(Counter(0)) at (prev + 1, 13) to (start + 0, 14)
+- Code(Counter(0)) at (prev + 1, 13) to (start + 0, 30)
+- Code(Counter(1)) at (prev + 0, 30) to (start + 0, 31)
 - Code(Zero) at (prev + 1, 16) to (start + 1, 10)
-- Code(Counter(4)) at (prev + 3, 13) to (start + 0, 14)
-- Code(Counter(3)) at (prev + 0, 18) to (start + 0, 23)
-- Code(Counter(4)) at (prev + 1, 16) to (start + 0, 20)
-- Code(Counter(5)) at (prev + 1, 20) to (start + 0, 25)
+- Code(Counter(3)) at (prev + 3, 13) to (start + 0, 14)
+- Code(Counter(2)) at (prev + 0, 18) to (start + 0, 23)
+- Code(Counter(3)) at (prev + 1, 16) to (start + 0, 20)
+- Code(Counter(3)) at (prev + 1, 20) to (start + 0, 25)
 - Code(Zero) at (prev + 1, 27) to (start + 0, 31)
 - Code(Zero) at (prev + 0, 32) to (start + 0, 34)
-- Code(Counter(5)) at (prev + 1, 17) to (start + 0, 18)
-- Code(Counter(5)) at (prev + 1, 17) to (start + 0, 34)
+- Code(Counter(3)) at (prev + 1, 17) to (start + 0, 18)
+- Code(Counter(3)) at (prev + 1, 17) to (start + 0, 34)
 - Code(Expression(0, Sub)) at (prev + 0, 34) to (start + 0, 35)
-    = ((c0 + c4) - (c2 + c3))
+    = ((c0 + c3) - (c1 + c2))
 - Code(Zero) at (prev + 1, 20) to (start + 1, 14)
 - Code(Expression(3, Sub)) at (prev + 3, 9) to (start + 0, 15)
-    = (c3 - c4)
+    = (c2 - c3)
 - Code(Counter(0)) at (prev + 1, 5) to (start + 0, 6)
-Highest counter ID seen: c5
+Highest counter ID seen: c3
 
 Function name: <loops_branches::DisplayTest as core::fmt::Display>::fmt
 Raw bytes (112): 0x[01, 01, 04, 07, 0b, 01, 09, 05, 0d, 05, 09, 14, 01, 22, 05, 01, 11, 00, 01, 12, 01, 0a, 01, 02, 10, 00, 15, 00, 01, 17, 00, 1b, 00, 00, 1c, 00, 1e, 01, 01, 0d, 00, 0e, 01, 01, 0d, 00, 1e, 0d, 00, 1e, 00, 1f, 09, 02, 0d, 00, 0e, 05, 00, 12, 00, 17, 09, 01, 10, 00, 15, 00, 00, 16, 01, 0e, 09, 02, 14, 00, 19, 00, 01, 1b, 00, 1f, 00, 00, 20, 00, 22, 09, 01, 11, 00, 12, 09, 01, 11, 00, 22, 02, 00, 22, 00, 23, 0e, 03, 09, 00, 0f, 01, 01, 05, 00, 06]
diff --git a/tests/coverage/try_error_result.cov-map b/tests/coverage/try_error_result.cov-map
index 03012f744c1..35b2c36a575 100644
--- a/tests/coverage/try_error_result.cov-map
+++ b/tests/coverage/try_error_result.cov-map
@@ -55,27 +55,31 @@ Number of file 0 mappings: 4
 Highest counter ID seen: c1
 
 Function name: try_error_result::test1
-Raw bytes (63): 0x[01, 01, 02, 09, 0d, 05, 09, 0b, 01, 0d, 01, 02, 17, 05, 07, 09, 00, 0e, 09, 02, 09, 04, 1a, 0d, 06, 0d, 00, 29, 11, 00, 29, 00, 2a, 00, 01, 0d, 00, 2a, 00, 00, 2a, 00, 2b, 02, 04, 0d, 00, 2a, 00, 00, 2a, 00, 2b, 06, 03, 05, 00, 0b, 01, 01, 01, 00, 02]
+Raw bytes (67): 0x[01, 01, 04, 07, 05, 01, 09, 05, 01, 05, 09, 0b, 01, 0d, 01, 02, 17, 05, 07, 09, 00, 0e, 09, 02, 09, 04, 1a, 02, 06, 0d, 00, 29, 02, 00, 29, 00, 2a, 00, 01, 0d, 00, 2a, 00, 00, 2a, 00, 2b, 0a, 04, 0d, 00, 2a, 00, 00, 2a, 00, 2b, 0e, 03, 05, 00, 0b, 01, 01, 01, 00, 02]
 Number of files: 1
 - file 0 => global file 1
-Number of expressions: 2
-- expression 0 operands: lhs = Counter(2), rhs = Counter(3)
-- expression 1 operands: lhs = Counter(1), rhs = Counter(2)
+Number of expressions: 4
+- expression 0 operands: lhs = Expression(1, Add), rhs = Counter(1)
+- expression 1 operands: lhs = Counter(0), rhs = Counter(2)
+- expression 2 operands: lhs = Counter(1), rhs = Counter(0)
+- expression 3 operands: lhs = Counter(1), rhs = Counter(2)
 Number of file 0 mappings: 11
 - Code(Counter(0)) at (prev + 13, 1) to (start + 2, 23)
 - Code(Counter(1)) at (prev + 7, 9) to (start + 0, 14)
 - Code(Counter(2)) at (prev + 2, 9) to (start + 4, 26)
-- Code(Counter(3)) at (prev + 6, 13) to (start + 0, 41)
-- Code(Counter(4)) at (prev + 0, 41) to (start + 0, 42)
+- Code(Expression(0, Sub)) at (prev + 6, 13) to (start + 0, 41)
+    = ((c0 + c2) - c1)
+- Code(Expression(0, Sub)) at (prev + 0, 41) to (start + 0, 42)
+    = ((c0 + c2) - c1)
 - Code(Zero) at (prev + 1, 13) to (start + 0, 42)
 - Code(Zero) at (prev + 0, 42) to (start + 0, 43)
-- Code(Expression(0, Sub)) at (prev + 4, 13) to (start + 0, 42)
-    = (c2 - c3)
+- Code(Expression(2, Sub)) at (prev + 4, 13) to (start + 0, 42)
+    = (c1 - c0)
 - Code(Zero) at (prev + 0, 42) to (start + 0, 43)
-- Code(Expression(1, Sub)) at (prev + 3, 5) to (start + 0, 11)
+- Code(Expression(3, Sub)) at (prev + 3, 5) to (start + 0, 11)
     = (c1 - c2)
 - Code(Counter(0)) at (prev + 1, 1) to (start + 0, 2)
-Highest counter ID seen: c4
+Highest counter ID seen: c2
 
 Function name: try_error_result::test2
 Raw bytes (336): 0x[01, 01, 36, 0d, 11, 0d, 3f, 11, 15, 0d, 37, 3b, 1d, 3f, 19, 11, 15, 0d, 3f, 11, 15, 0d, 3b, 3f, 19, 11, 15, 0d, 37, 3b, 1d, 3f, 19, 11, 15, 41, 53, 21, 25, 41, 21, 41, 53, 21, 25, 09, 73, 77, 2d, 0d, 29, 09, 0d, 09, 77, 0d, 29, 09, 73, 77, 2d, 0d, 29, 45, 8b, 01, 31, 35, 45, 31, 45, 8b, 01, 31, 35, 49, 9f, 01, 39, 3d, 49, 39, 49, 9f, 01, 39, 3d, 05, 09, ab, 01, 09, af, 01, 3d, b3, 01, 39, b7, 01, 35, bb, 01, 31, bf, 01, 2d, c3, 01, 29, c7, 01, 25, cb, 01, 21, cf, 01, 1d, d3, 01, 19, d7, 01, 15, 05, 11, 28, 01, 3d, 01, 03, 17, 05, 08, 09, 00, 0e, 09, 02, 09, 04, 1a, 0d, 06, 0d, 00, 2f, 11, 00, 2f, 00, 30, 02, 00, 31, 03, 35, 15, 04, 11, 00, 12, 1e, 02, 11, 04, 12, 32, 05, 11, 00, 14, 1e, 00, 17, 00, 41, 19, 00, 41, 00, 42, 26, 00, 43, 00, 5f, 1d, 00, 5f, 00, 60, 32, 01, 0d, 00, 20, 4e, 01, 11, 00, 14, 41, 00, 17, 00, 41, 21, 00, 41, 00, 42, 4a, 00, 43, 00, 60, 25, 00, 60, 00, 61, 4e, 01, 0d, 00, 20, 6e, 04, 11, 00, 14, 62, 00, 17, 00, 42, 29, 00, 42, 00, 43, 66, 00, 44, 00, 61, 2d, 00, 61, 00, 62, 6e, 01, 0d, 00, 20, 86, 01, 01, 11, 00, 14, 45, 00, 17, 01, 36, 31, 01, 36, 00, 37, 82, 01, 01, 12, 00, 2f, 35, 00, 2f, 00, 30, 86, 01, 01, 0d, 00, 20, 9a, 01, 01, 11, 00, 14, 49, 00, 17, 01, 36, 39, 02, 11, 00, 12, 96, 01, 01, 12, 00, 2f, 3d, 01, 11, 00, 12, 9a, 01, 02, 0d, 00, 20, a2, 01, 03, 05, 00, 0b, a6, 01, 01, 01, 00, 02]
diff --git a/tests/coverage/while.cov-map b/tests/coverage/while.cov-map
index d42aa8a7b84..5a6698128cb 100644
--- a/tests/coverage/while.cov-map
+++ b/tests/coverage/while.cov-map
@@ -1,12 +1,12 @@
 Function name: while::main
-Raw bytes (24): 0x[01, 01, 00, 04, 01, 01, 01, 01, 10, 05, 02, 0b, 00, 14, 00, 00, 15, 02, 06, 01, 03, 01, 00, 02]
+Raw bytes (24): 0x[01, 01, 00, 04, 01, 01, 01, 01, 10, 01, 02, 0b, 00, 14, 00, 00, 15, 02, 06, 01, 03, 01, 00, 02]
 Number of files: 1
 - file 0 => global file 1
 Number of expressions: 0
 Number of file 0 mappings: 4
 - Code(Counter(0)) at (prev + 1, 1) to (start + 1, 16)
-- Code(Counter(1)) at (prev + 2, 11) to (start + 0, 20)
+- Code(Counter(0)) at (prev + 2, 11) to (start + 0, 20)
 - Code(Zero) at (prev + 0, 21) to (start + 2, 6)
 - Code(Counter(0)) at (prev + 3, 1) to (start + 0, 2)
-Highest counter ID seen: c1
+Highest counter ID seen: c0