1
Fork 0
rust/compiler/rustc_session/src
Matthias Krüger 54a5a49af0
Rollup merge of #122322 - Zalathar:branch, r=oli-obk
coverage: Initial support for branch coverage instrumentation

(This is a review-ready version of the changes that were drafted in #118305.)

This PR adds support for branch coverage instrumentation, gated behind the unstable flag value `-Zcoverage-options=branch`. (Coverage instrumentation must also be enabled with `-Cinstrument-coverage`.)

During THIR-to-MIR lowering (MIR building), if branch coverage is enabled, we collect additional information about branch conditions and their corresponding then/else blocks. We inject special marker statements into those blocks, so that the `InstrumentCoverage` MIR pass can reliably identify them even after the initially-built MIR has been simplified and renumbered.

The rest of the changes are mostly just plumbing needed to gather up the information that was collected during MIR building, and include it in the coverage metadata that we embed in the final binary.

Note that `llvm-cov show` doesn't print branch coverage information in its source views by default; that needs to be explicitly enabled with `--show-branches=count` or similar.

---

The current implementation doesn't have any support for instrumenting `if let` or let-chains. I think it's still useful without that, and adding it would be non-trivial, so I'm happy to leave that for future work.
2024-03-14 20:00:19 +01:00
..
config update paths in comments 2024-01-12 00:11:33 +01:00
code_stats.rs rustc_session: Address all rustc::potential_query_instability lints 2023-12-03 15:05:39 +01:00
config.rs coverage: -Zcoverage-options=branch is no longer a placeholder 2024-03-14 17:19:06 +11:00
cstore.rs Move MetadataLoader{,Dyn} to rustc_metadata. 2023-11-30 17:05:54 +11:00
errors.rs Make incremental sessions identity no longer depend on the crate names provided by source code 2024-03-13 16:40:02 +01:00
filesearch.rs Rollup merge of #116793 - WaffleLapkin:target_rules_the_backend, r=cjgillot 2024-03-11 09:29:32 -07:00
lib.rs Use generic NonZero internally. 2024-02-15 08:09:42 +01:00
options.rs extend docs of -Zprint-mono-items 2024-03-13 16:11:48 +01:00
output.rs Make incremental sessions identity no longer depend on the crate names provided by source code 2024-03-13 16:40:02 +01:00
parse.rs Rollup merge of #121382 - nnethercote:rework-untranslatable_diagnostic-lint, r=davidtwco 2024-03-06 22:02:46 +01:00
search_paths.rs Rewrite the untranslatable_diagnostic lint. 2024-03-06 14:19:01 +11:00
session.rs coverage: Add -Zcoverage-options for fine control of coverage 2024-03-13 11:14:10 +11:00
utils.rs Use better heuristic for printing Cargo specific diagnostics 2024-02-17 16:49:01 +01:00
version.rs Simplify the current_rustc_version macro. 2023-11-10 10:54:21 +11:00