[−][src]Struct rustc_mir::transform::coverage::query::CoverageVisitor

pub(in transform::coverage::query) struct CoverageVisitor {
    info: CoverageInfo,
    add_missing_operands: bool,
}

The num_counters argument to llvm.instrprof.increment is the max counter_id + 1, or in other words, the number of counter value references injected into the MIR (plus 1 for the reserved ZERO counter, which uses counter ID 0 when included in an expression). Injected counters have a counter ID from 1..num_counters-1.

num_expressions is the number of counter expressions added to the MIR body.

Both num_counters and num_expressions are used to initialize new vectors, during backend code generate, to lookup counters and expressions by simple u32 indexes.

MIR optimization may split and duplicate some BasicBlock sequences, or optimize out some code including injected counters. (It is OK if some counters are optimized out, but those counters are still included in the total num_counters or num_expressions.) Simply counting the calls may not work; but computing the number of counters or expressions by adding 1 to the highest ID (for a given instrumented function) is valid.

This visitor runs twice, first with add_missing_operands set to false, to find the maximum counter ID and maximum expression ID based on their enum variant id fields; then, as a safeguard, with add_missing_operands set to true, to find any other counter or expression IDs referenced by expression operands, if not already seen.

Ideally, each operand ID in a MIR CoverageKind::Expression will have a separate MIR Coverage statement for the Counter or Expression with the referenced ID. but since current or future MIR optimizations can theoretically optimize out segments of a MIR, it may not be possible to guarantee this, so the second pass ensures the CoverageInfo counts include all referenced IDs.

Fields

info: CoverageInfoadd_missing_operands: bool

Implementations

impl CoverageVisitor[src]

pub(in transform::coverage::query) fn update_num_counters(
    &mut self,
    counter_id: u32
)
[src]

Updates num_counters to the maximum encountered zero-based counter_id plus 1. Note the final computed number of counters should be the number of all CoverageKind::Counter statements in the MIR plus one for the implicit ZERO counter.

pub(in transform::coverage::query) fn update_num_expressions(
    &mut self,
    expression_id: u32
)
[src]

Computes an expression index for each expression ID, and updates num_expressions to the maximum encountered index plus 1.

pub(in transform::coverage::query) fn update_from_expression_operand(
    &mut self,
    operand_id: u32
)
[src]

Trait Implementations

impl<'_> Visitor<'_> for CoverageVisitor[src]

Auto Trait Implementations

impl RefUnwindSafe for CoverageVisitor

impl Send for CoverageVisitor

impl Sync for CoverageVisitor

impl Unpin for CoverageVisitor

impl UnwindSafe for CoverageVisitor

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized, 
[src]

impl<T> Borrow<T> for T where
    T: ?Sized, 
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized, 
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> WithConstness for T[src]