diff options
| author | Zalathar <Zalathar@users.noreply.github.com> | 2024-12-11 15:41:02 +1100 |
|---|---|---|
| committer | Zalathar <Zalathar@users.noreply.github.com> | 2024-12-11 21:35:45 +1100 |
| commit | 3f3a9bf7f50afbfde72cd0b9479323dddc84fe6d (patch) | |
| tree | 9aeeae3bc9516d499202142127bccb1d520bb95c /compiler/rustc_codegen_llvm/src/coverageinfo/ffi.rs | |
| parent | 512f3fdebe72532a435238435f0e16eff61fbf38 (diff) | |
| download | rust-3f3a9bf7f50afbfde72cd0b9479323dddc84fe6d.tar.gz rust-3f3a9bf7f50afbfde72cd0b9479323dddc84fe6d.zip | |
coverage: Store intermediate region tables in `CovfunRecord`
This defers the call to `llvm_cov::write_function_mappings_to_buffer` until just before its enclosing global variable is created.
Diffstat (limited to 'compiler/rustc_codegen_llvm/src/coverageinfo/ffi.rs')
| -rw-r--r-- | compiler/rustc_codegen_llvm/src/coverageinfo/ffi.rs | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/compiler/rustc_codegen_llvm/src/coverageinfo/ffi.rs b/compiler/rustc_codegen_llvm/src/coverageinfo/ffi.rs index a6e07ea2a60..1f133141c18 100644 --- a/compiler/rustc_codegen_llvm/src/coverageinfo/ffi.rs +++ b/compiler/rustc_codegen_llvm/src/coverageinfo/ffi.rs @@ -152,6 +152,34 @@ impl CoverageSpan { } } +/// Holds tables of the various region types in one struct. +/// +/// Don't pass this struct across FFI; pass the individual region tables as +/// pointer/length pairs instead. +/// +/// Each field name has a `_regions` suffix for improved readability after +/// exhaustive destructing, which ensures that all region types are handled. +#[derive(Clone, Debug, Default)] +pub(crate) struct Regions { + pub(crate) code_regions: Vec<CodeRegion>, + pub(crate) branch_regions: Vec<BranchRegion>, + pub(crate) mcdc_branch_regions: Vec<MCDCBranchRegion>, + pub(crate) mcdc_decision_regions: Vec<MCDCDecisionRegion>, +} + +impl Regions { + /// Returns true if none of this structure's tables contain any regions. + pub(crate) fn has_no_regions(&self) -> bool { + let Self { code_regions, branch_regions, mcdc_branch_regions, mcdc_decision_regions } = + self; + + code_regions.is_empty() + && branch_regions.is_empty() + && mcdc_branch_regions.is_empty() + && mcdc_decision_regions.is_empty() + } +} + /// Must match the layout of `LLVMRustCoverageCodeRegion`. #[derive(Clone, Debug)] #[repr(C)] |
