1 use rustc_middle
::mir
::coverage
::{CounterValueReference, MappedExpressionIndex}
;
3 /// 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)
4 #[derive(Copy, Clone, Debug)]
8 CounterValueReference
= 1,
12 /// A reference to an instance of an abstract "counter" that will yield a value in a coverage
13 /// report. Note that `id` has different interpretations, depending on the `kind`:
14 /// * For `CounterKind::Zero`, `id` is assumed to be `0`
15 /// * For `CounterKind::CounterValueReference`, `id` matches the `counter_id` of the injected
16 /// instrumentation counter (the `index` argument to the LLVM intrinsic
17 /// `instrprof.increment()`)
18 /// * For `CounterKind::Expression`, `id` is the index into the coverage map's array of
19 /// counter expressions.
20 /// Aligns with [llvm::coverage::Counter](https://github.com/rust-lang/llvm-project/blob/rustc/10.0-2020-05-05/llvm/include/llvm/ProfileData/Coverage/CoverageMapping.h#L98-L99)
21 /// Important: The Rust struct layout (order and types of fields) must match its C++ counterpart.
22 #[derive(Copy, Clone, Debug)]
25 // Important: The layout (order and types of fields) must match its C++ counterpart.
31 pub fn zero() -> Self {
32 Self { kind: CounterKind::Zero, id: 0 }
35 pub fn counter_value_reference(counter_id
: CounterValueReference
) -> Self {
36 Self { kind: CounterKind::CounterValueReference, id: counter_id.into() }
39 pub fn expression(mapped_expression_index
: MappedExpressionIndex
) -> Self {
40 Self { kind: CounterKind::Expression, id: mapped_expression_index.into() }
44 /// Aligns with [llvm::coverage::CounterExpression::ExprKind](https://github.com/rust-lang/llvm-project/blob/rustc/10.0-2020-05-05/llvm/include/llvm/ProfileData/Coverage/CoverageMapping.h#L146)
45 #[derive(Copy, Clone, Debug)]
52 /// Aligns with [llvm::coverage::CounterExpression](https://github.com/rust-lang/llvm-project/blob/rustc/10.0-2020-05-05/llvm/include/llvm/ProfileData/Coverage/CoverageMapping.h#L147-L148)
53 /// Important: The Rust struct layout (order and types of fields) must match its C++
55 #[derive(Copy, Clone, Debug)]
57 pub struct CounterExpression
{
63 impl CounterExpression
{
64 pub fn new(lhs
: Counter
, kind
: ExprKind
, rhs
: Counter
) -> Self {
65 Self { kind, lhs, rhs }