Skip to main content

Module covfun

Module covfun 

Source
Expand description

For each function that was instrumented for coverage, we need to embed its corresponding coverage mapping metadata inside the __llvm_covfun1 linker section of the final binary.


  1. On Windows the section name is .lcovfun. β†©

Re-exportsΒ§

use std::ffi::CString; πŸ”’
use std::iter; πŸ”’
use std::sync::Arc; πŸ”’
use rustc_abi::Align; πŸ”’
use rustc_codegen_ssa::traits::BaseTypeCodegenMethods as _; πŸ”’
use rustc_codegen_ssa::traits::ConstCodegenMethods; πŸ”’
use rustc_index::IndexVec; πŸ”’
use rustc_middle::mir::coverage::BasicCoverageBlock; πŸ”’
use rustc_middle::mir::coverage::CounterId; πŸ”’
use rustc_middle::mir::coverage::CovTerm; πŸ”’
use rustc_middle::mir::coverage::CoverageCodegenInfo; πŸ”’
use rustc_middle::mir::coverage::Expression; πŸ”’
use rustc_middle::mir::coverage::ExpressionId; πŸ”’
use rustc_middle::mir::coverage::Mapping; πŸ”’
use rustc_middle::mir::coverage::MappingKind; πŸ”’
use rustc_middle::mir::coverage::Op; πŸ”’
use rustc_middle::ty::Instance; πŸ”’
use rustc_middle::ty::TyCtxt; πŸ”’
use rustc_span::SourceFile; πŸ”’
use rustc_span::Span; πŸ”’
use rustc_target::spec::HasTargetSpec; πŸ”’
use tracing::debug; πŸ”’
use crate::common::CodegenCx; πŸ”’
use crate::coverageinfo::mapgen::GlobalFileTable; πŸ”’
use crate::coverageinfo::mapgen::LocalFileId; πŸ”’
use crate::coverageinfo::mapgen::spans; πŸ”’
use crate::coverageinfo::ffi; πŸ”’
use crate::coverageinfo::llvm_cov; πŸ”’
use crate::llvm; πŸ”’

StructsΒ§

BranchMapping πŸ”’
Resolved from MappingKind::Branch, and the precursor to ffi::BranchRegion.
CodeMapping πŸ”’
Resolved from MappingKind::Code, and the precursor to ffi::CodeRegion.
CovfunRecord πŸ”’
Intermediate coverage metadata for a single function, used to help build the final record that will be embedded in the __llvm_covfun section.
ResolvedMappings πŸ”’
Intermediate representation of coverage mappings, after all mapping spans have been resolved to file coordinates (or discarded), but before producing a final llvm_cov::Regions.

FunctionsΒ§

counter_for_term πŸ”’
emit_covfun_record πŸ”’
Generates and emits the covfun record for this function, which contains the function’s coverage mapping data. The record is emitted as a global variable in the __llvm_covfun section.
fill_region_tables πŸ”’
Populates the mapping region tables for the current function’s covfun record.
prepare_covfun_record πŸ”’
prepare_expressions πŸ”’
Convert the function’s coverage-counter expressions into a form suitable for FFI.
prepare_resolved_mappings πŸ”’