about summary refs log tree commit diff
path: root/compiler/rustc_codegen_llvm/src/coverageinfo
AgeCommit message (Collapse)AuthorLines
2025-01-27Change `collect_and_partition_mono_items` tuple return type to a structOli Scherer-2/+4
2025-01-24coverage: Make query `coverage_ids_info` return an OptionZalathar-4/+6
This reflects the fact that we can't compute meaningful info for a function that wasn't instrumented and therefore doesn't have `function_coverage_info`.
2024-12-19coverage: Add a synthetic test for when all spans are discardedZalathar-0/+11
2024-12-19coverage: Identify source files by ID, not by interned filenameZalathar-37/+33
2024-12-19coverage: Store coverage source regions as `Span` until codegenZalathar-26/+145
2024-12-19coverage: Quietly skip functions that end up having no mappingsZalathar-7/+2
In codegen, a used function with `FunctionCoverageInfo` but no mappings has historically indicated a bug. However, that will no longer be the case after moving some fallible span-processing steps into codegen.
2024-12-19coverage: Rename some FFI fields from `span` to `cov_span`Zalathar-9/+10
This will avoid confusion with actual `Span` spans.
2024-12-17coverage: Track used functions in a set instead of a mapZalathar-90/+37
This patch dismantles what was left of `FunctionCoverage` in `map_data.rs`, replaces `function_coverage_map` with a set, and overhauls how we prepare covfun records for unused functions.
2024-12-17coverage: Pull function source hash out of `map_data.rs`Zalathar-12/+7
2024-12-17coverage: Pull region conversion out of `map_data.rs`Zalathar-37/+14
2024-12-17coverage: Pull expression conversion out of `map_data.rs`Zalathar-33/+44
2024-12-17coverage: Build the global file table on the flyZalathar-33/+29
2024-12-17coverage: Use `is_eligible_for_coverage` to filter unused functionsZalathar-8/+7
The checks in `is_eligible_for_coverage` include `is_fn_like`, but will also exclude various function-like things that cannot possibly have coverage instrumentation.
2024-12-12coverage: Tidy up creation of covfun recordsZalathar-32/+34
2024-12-12coverage: Tidy up creation of covmap recordsZalathar-33/+27
2024-12-11coverage: Store intermediate region tables in `CovfunRecord`Zalathar-55/+77
This defers the call to `llvm_cov::write_function_mappings_to_buffer` until just before its enclosing global variable is created.
2024-12-11coverage: Only generate a CGU's covmap record if it has covfun recordsZalathar-4/+14
2024-12-11coverage: Reify `CovfunRecord` as an intermediate stepZalathar-36/+45
2024-12-11coverage: Extract function metadata handling to a `covfun` submoduleZalathar-166/+206
2024-12-08coverage: Unused functions don't need to store `CoverageIdsInfo`Zalathar-13/+13
2024-12-08coverage: Remove FunctionCoverageCollectorZalathar-70/+17
The information that was being collected by this builder type is now collected by the `coverage_ids_info` query instead.
2024-12-08coverage: Use a query to find counters/expressions that must be zeroZalathar-112/+4
This query (`coverage_ids_info`) already determines which counter/expression IDs are unused, so it only takes a little extra effort to also determine which counters/expressions must have a value of zero.
2024-12-08coverage: Move `CoverageIdsInfo` into `mir::coverage`Zalathar-3/+2
2024-11-30coverage: Use a query to identify which counter/expression IDs are usedZalathar-72/+34
2024-11-30coverage: All counter terms in an unused function are zeroZalathar-4/+3
This is currently handled automatically by the fact that codegen doesn't visit coverage statements in unused functions, but that will no longer be the case when unused IDs are identified by a separate query instead.
2024-11-30coverage: Hoist and explain the check for `coverage_cx`Zalathar-11/+14
2024-11-30coverage: Rename `CrateCoverageContext` to `CguCoverageContext`Zalathar-3/+3
This context is stored in `CodegenCx`, which makes it per-CGU rather than per-crate. A single crate can have multiple CGUs.
2024-11-29Revert "Rollup merge of #133418 - Zalathar:spans, r=jieyouxu"Zalathar-207/+96
This reverts commit adf9b5fcd1de43eaf0a779e10612caee8b47bede, reversing changes made to af1ca153d4aed5ffe22445273aa388a8d3f8f4ae. Reverting due to <https://github.com/rust-lang/rust/issues/133606>.
2024-11-24coverage: Identify source files by ID, not by interned filenameZalathar-43/+42
2024-11-24coverage: Store coverage source regions as `Span` until codegenZalathar-37/+155
2024-11-24coverage: Rename some FFI fields from `span` to `cov_span`Zalathar-9/+10
This will avoid confusion with actual `Span` spans.
2024-11-24coverage: Ignore functions that end up having no mappingsZalathar-9/+2
A used function with no mappings has historically indicated a bug, but that will no longer be the case after moving some fallible span-processing steps into codegen.
2024-11-10Rollup merge of #132675 - Zalathar:empty-spans, r=jieyouxuMatthias Krüger-67/+81
coverage: Restrict empty-span expansion to only cover `{` and `}` Coverage instrumentation has some tricky code for converting a coverage-relevant `Span` into a set of start/end line/byte-column coordinates that will be embedded in the CGU's coverage metadata. A big part of this complexity is special code for handling empty spans, which are expanded into non-empty spans (if possible) because LLVM's coverage reporter does not handle empty spans well. This PR simplifies that code by restricting it to only apply in two specific situations: when the character after the empty span is `{`, or the character before the empty span is `}`. (As an added benefit, this means that the expanded spans no longer extend awkwardly beyond the end of a physical line, which was common under the previous implementation.) Along the way, this PR also removes some unhelpful code for dealing with function source code spread across multiple files. Functions currently can't have coverage spans in multiple files, and if that ever changes (e.g. to properly support expansion regions) then this code will need to be completely overhauled anyway.
2024-11-10coverage: Pass a `LocalFileId` to `CoverageSpan::from_source_region`Zalathar-3/+9
2024-11-08coverage: Remove unhelpful code for handling multiple files per functionZalathar-59/+57
Functions currently can't have mappings in multiple files, and if that ever changes (e.g. to properly support expansion regions), this code will need to be completely overhauled anyway.
2024-11-08coverage: Add `GlobalFileId` for stricter type-checking of file IDsZalathar-7/+17
We already had a dedicated `LocalFileId` index type, but previously we used a raw `u32` for global file IDs, because index types were harder to pass through FFI.
2024-11-05coverage: Tidy up coverage-specific FFI functionsZalathar-14/+12
2024-11-05coverage: Extract safe FFI wrapper functions to `llvm_cov`Zalathar-126/+132
2024-11-03compiler: Directly use rustc_abi in codegenJubilee Young-1/+1
2024-10-31coverage: Avoid ICE when `coverage_cx` is unexpectedly unavailableZalathar-2/+11
2024-10-28Use a type-safe helper to cast `&str` and `&[u8]` to `*const c_char`Zalathar-4/+4
2024-10-26Rollup merge of #132124 - Zalathar:consolidate-covstar, r=jieyouxu许杰友 Jieyou Xu (Joe)-140/+98
coverage: Consolidate creation of covmap/covfun records This code for creating covmap/covfun records during codegen was split across multiple functions and files for dubious historical reasons. Having it all in one place makes it easier to follow. This PR also includes two semi-related cleanups: - Getting the codegen context's `coverage_cx` state is made infallible, since it should always exist when running the code paths that need it. - The value of `covfun_section_name` is saved in the codegen context, since it never changes at runtime, and the code that needs it has access to the context anyway. --- Background: Coverage instrumentation generates two kinds of metadata that are embedded in the final binary. There is per-CGU information that goes in the `__llvm_covmap` linker section, and per-function information that goes in the `__llvm_covfun` section (except on Windows, where slightly different section names are used).
2024-10-26coverage: Add links to LLVM docs for the coverage mapping formatZalathar-0/+2
2024-10-25coverage: Emit MC/DC intrinsics using the normal helper methodZalathar-0/+1
2024-10-25coverage: Store `covfun_section_name` in the codegen contextZalathar-27/+24
Adding an extra `OnceCell` to `CrateCoverageContext` is much nicer than trying to thread this string through multiple layers of function calls that already have access to the context.
2024-10-25coverage: Make obtaining the codegen coverage context infallibleZalathar-29/+12
In all the situations where this context is needed, it should always be available.
2024-10-25coverage: Consolidate creation of covmap/covfun recordsZalathar-88/+64
There is no need for this code to be split across multiple functions in multiple files.
2024-10-24Rollup merge of #131956 - Zalathar:llvm-counters, r=compiler-errors,SwatinemStuart Cook-343/+113
coverage: Pass coverage mappings to LLVM as separate structs Instead of trying to cram *N* different kinds of coverage mapping data into a single list for FFI, pass *N* different lists of simpler structs. This avoids the need to fill unused fields with dummy values, and avoids the need to tag structs with their underlying kind. It also lets us call the dedicated LLVM constructors for each different mapping type, instead of having to go through the complex general-purpose constructor. Even though this adds multiple new structs to the FFI surface area, the resulting C++ code is simpler and shorter. --- I've structured this mostly as a single atomic patch, rather than a series of incremental changes, because that avoids the need to make fiddly fixes to code that is about to be deleted anyway.
2024-10-20Make `llvm::set_section` take a `&CStr`Zalathar-10/+12
2024-10-20Pass coverage mappings to LLVM as separate structsZalathar-334/+104