diff --git a/src/librustc_codegen_ssa/coverageinfo/map.rs b/src/librustc_codegen_ssa/coverageinfo/map.rs
index c72ee57ad6ff..1fe8b9f5ab7d 100644
--- a/src/librustc_codegen_ssa/coverageinfo/map.rs
+++ b/src/librustc_codegen_ssa/coverageinfo/map.rs
@@ -1,3 +1,4 @@
+use rustc_index::vec::IndexVec;
use rustc_middle::ty::Instance;
use rustc_middle::ty::TyCtxt;
use rustc_span::source_map::{Pos, SourceMap};
@@ -7,6 +8,34 @@
use std::fmt;
use std::path::PathBuf;
+rustc_index::newtype_index! {
+ pub struct ExpressionOperandId {
+ DEBUG_FORMAT = "ExpressionOperandId({})",
+ MAX = 0xFFFF_FFFF,
+ }
+}
+
+rustc_index::newtype_index! {
+ pub struct CounterValueReference {
+ DEBUG_FORMAT = "CounterValueReference({})",
+ MAX = 0xFFFF_FFFF,
+ }
+}
+
+rustc_index::newtype_index! {
+ pub struct InjectedExpressionIndex {
+ DEBUG_FORMAT = "InjectedExpressionIndex({})",
+ MAX = 0xFFFF_FFFF,
+ }
+}
+
+rustc_index::newtype_index! {
+ pub struct MappedExpressionIndex {
+ DEBUG_FORMAT = "MappedExpressionIndex({})",
+ MAX = 0xFFFF_FFFF,
+ }
+}
+
/// Aligns with [llvm::coverage::Counter::CounterKind](https://github.com/rust-lang/llvm-project/blob/rustc/10.0-2020-05-05/llvm/include/llvm/ProfileData/Coverage/CoverageMapping.h#L91)
#[derive(Copy, Clone, Debug)]
#[repr(C)]
@@ -38,12 +67,12 @@ pub fn zero() -> Self {
Self { kind: CounterKind::Zero, id: 0 }
}
- pub fn counter_value_reference(counter_id: u32) -> Self {
- Self { kind: CounterKind::CounterValueReference, id: counter_id }
+ pub fn counter_value_reference(counter_id: CounterValueReference) -> Self {
+ Self { kind: CounterKind::CounterValueReference, id: counter_id.into() }
}
- pub fn expression(final_expression_index: u32) -> Self {
- Self { kind: CounterKind::Expression, id: final_expression_index }
+ pub fn expression(mapped_expression_index: MappedExpressionIndex) -> Self {
+ Self { kind: CounterKind::Expression, id: mapped_expression_index.into() }
}
}
@@ -143,9 +172,9 @@ pub fn file_start_and_end<'a>(&'a self) -> (&'a PathBuf, u32, u32, u32, u32) {
#[derive(Clone, Debug)]
pub struct ExpressionRegion {
- lhs: u32,
+ lhs: ExpressionOperandId,
op: ExprKind,
- rhs: u32,
+ rhs: ExpressionOperandId,
region: Region,
}
@@ -203,8 +232,8 @@ pub struct ExpressionRegion {
pub struct FunctionCoverage<'a> {
source_map: &'a SourceMap,
source_hash: u64,
- counters: Vec