[−][src]Struct rustc_codegen_ssa::coverageinfo::map::FunctionCoverage

pub struct FunctionCoverage {
    source_hash: u64,
    counters: IndexVec<CounterValueReference, Option<CodeRegion>>,
    expressions: IndexVec<InjectedExpressionIndex, Option<ExpressionRegion>>,
    unreachable_regions: Vec<CodeRegion>,
}

Collects all of the coverage regions associated with (a) injected counters, (b) counter expressions (additions or subtraction), and (c) unreachable regions (always counted as zero), for a given Function. Counters and counter expressions have non-overlapping ids because they can both be operands in an expression. This struct also stores the function_source_hash, computed during instrumentation, and forwarded with counters.

Note, it may be important to understand LLVM's definitions of unreachable regions versus "gap regions" (or "gap areas"). A gap region is a code region within a counted region (either counter or expression), but the line or lines in the gap region are not executable (such as lines with only whitespace or comments). According to LLVM Code Coverage Mapping documentation, "A count for a gap area is only used as the line execution count if there are no other regions on a line."

Fields

source_hash: u64counters: IndexVec<CounterValueReference, Option<CodeRegion>>expressions: IndexVec<InjectedExpressionIndex, Option<ExpressionRegion>>unreachable_regions: Vec<CodeRegion>

Implementations

impl FunctionCoverage[src]

pub fn new<'tcx>(tcx: TyCtxt<'tcx>, instance: Instance<'tcx>) -> Self[src]

pub fn add_counter(
    &mut self,
    source_hash: u64,
    id: CounterValueReference,
    region: CodeRegion
)
[src]

Adds a code region to be counted by an injected counter intrinsic. The source_hash (computed during coverage instrumentation) should also be provided, and should be the same for all counters in a given function.

pub fn add_counter_expression(
    &mut self,
    expression_id: InjectedExpressionIndex,
    lhs: ExpressionOperandId,
    op: Op,
    rhs: ExpressionOperandId,
    region: CodeRegion
)
[src]

Both counters and "counter expressions" (or simply, "expressions") can be operands in other expressions. Expression IDs start from u32::MAX and go down, so the range of expression IDs will not overlap with the range of counter IDs. Counters and expressions can be added in any order, and expressions can still be assigned contiguous (though descending) IDs, without knowing what the last counter ID will be.

When storing the expression data in the expressions vector in the FunctionCoverage struct, its vector index is computed, from the given expression ID, by subtracting from u32::MAX.

Since the expression operands (lhs and rhs) can reference either counters or expressions, an operand that references an expression also uses its original ID, descending from u32::MAX. Theses operands are translated only during code generation, after all counters and expressions have been added.

pub fn add_unreachable_region(&mut self, region: CodeRegion)[src]

Add a region that will be marked as "unreachable", with a constant "zero counter".

pub fn source_hash(&self) -> u64[src]

Return the source hash, generated from the HIR node structure, and used to indicate whether or not the source code structure changed between different compilations.

pub fn get_expressions_and_counter_regions<'a>(
    &'a self
) -> (Vec<CounterExpression>, impl Iterator<Item = (Counter, &'a CodeRegion)>)
[src]

Generate an array of CounterExpressions, and an iterator over all Counters and their associated Regions (from which the LLVM-specific CoverageMapGenerator will create CounterMappingRegions.

fn counter_regions<'a>(
    &'a self
) -> impl Iterator<Item = (Counter, &'a CodeRegion)>
[src]

fn expressions_with_regions<'a>(
    &'a self
) -> (Vec<CounterExpression>, impl Iterator<Item = (Counter, &'a CodeRegion)>)
[src]

fn unreachable_regions<'a>(
    &'a self
) -> impl Iterator<Item = (Counter, &'a CodeRegion)>
[src]

fn expression_index(
    &self,
    id_descending_from_max: u32
) -> InjectedExpressionIndex
[src]

Auto Trait Implementations

impl RefUnwindSafe for FunctionCoverage

impl Send for FunctionCoverage

impl Sync for FunctionCoverage

impl Unpin for FunctionCoverage

impl UnwindSafe for FunctionCoverage

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.