os-rust/compiler
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
..
rustc Clean up rustc_*/Cargo.toml. 2023-10-30 08:46:02 +11:00
rustc_abi Auto merge of #121668 - erikdesjardins:commonprim, r=scottmcm,oli-obk 2024-03-13 15:25:35 +00:00
rustc_arena rename ptr::invalid -> ptr::without_provenance 2024-02-21 20:15:52 +01:00
rustc_ast Rollup merge of #119365 - nbdd0121:asm-goto, r=Amanieu 2024-03-08 08:19:17 +01:00
rustc_ast_ir Fix typo in VisitorResult 2024-03-08 23:20:29 -05:00
rustc_ast_lowering Create some minimal HIR for associated opaque types 2024-03-13 17:33:09 +03:00
rustc_ast_passes Rename AddToDiagnostic as Subdiagnostic. 2024-03-11 10:04:49 +11:00
rustc_ast_pretty Rollup merge of #121584 - klensy:itertools-up, r=Mark-Simulacrum 2024-03-09 21:40:08 +01:00
rustc_attr Rename IntoDiagnostic as Diagnostic. 2024-03-11 09:15:09 +11:00
rustc_baked_icu_data Bump cfg(bootstrap)s 2023-11-15 19:41:28 -05:00
rustc_borrowck Eliminate DefiningAnchor::Error, it is indistinguishable from DefiningAnchor::Bind with an empty list 2024-03-11 17:19:37 +00:00
rustc_builtin_macros delay expand macro bang when there has indeterminate path 2024-03-13 16:11:16 +08:00
rustc_codegen_cranelift Rollup merge of #122287 - RalfJung:simd-static-assert, r=pnkfelix 2024-03-14 15:44:33 +01:00
rustc_codegen_gcc Some comment nits 2024-03-12 08:51:20 +00:00
rustc_codegen_llvm Rollup merge of #122322 - Zalathar:branch, r=oli-obk 2024-03-14 20:00:19 +01:00
rustc_codegen_ssa Rollup merge of #122212 - erikdesjardins:byval-align2, r=wesleywiser 2024-03-14 20:00:18 +01:00
rustc_const_eval Rename some things around validation error reporting to signal that it is in fact about validation failures 2024-03-14 12:21:35 +00:00
rustc_data_structures Rollup merge of #120976 - matthiaskrgr:constify_TL_statics, r=lcnr 2024-03-04 22:16:30 +01:00
rustc_driver Bump cfg(bootstrap)s 2023-11-15 19:41:28 -05:00
rustc_driver_impl Rollup merge of #121764 - Zoxc:incr-sess-no-source, r=oli-obk 2024-03-14 20:00:18 +01:00
rustc_error_codes Improve error message for opaque captures 2024-03-08 19:08:13 +00:00
rustc_error_messages Rename SubdiagnosticMessage as SubdiagMessage. 2024-03-05 12:14:49 +11:00
rustc_errors Rollup merge of #120699 - nnethercote:rm-useless-TRACK_DIAGNOSTIC-calls, r=oli-obk 2024-03-14 11:09:57 +01:00
rustc_expand delay expand macro bang when there has indeterminate path 2024-03-13 16:11:16 +08:00
rustc_feature change some attribute to only_local 2024-03-14 17:12:39 +08:00
rustc_fluent_macro Rename SubdiagnosticMessage as SubdiagMessage. 2024-03-05 12:14:49 +11:00
rustc_fs_util Invert diagnostic lints. 2024-02-06 13:12:33 +11:00
rustc_graphviz Invert diagnostic lints. 2024-02-06 13:12:33 +11:00
rustc_hir Auto merge of #120943 - petrochenkov:somehir3, r=oli-obk 2024-03-14 14:28:58 +00:00
rustc_hir_analysis Auto merge of #120943 - petrochenkov:somehir3, r=oli-obk 2024-03-14 14:28:58 +00:00
rustc_hir_pretty Create some minimal HIR for associated opaque types 2024-03-13 17:33:09 +03:00
rustc_hir_typeck Create some minimal HIR for associated opaque types 2024-03-13 17:33:09 +03:00
rustc_incremental Make incremental sessions identity no longer depend on the crate names provided by source code 2024-03-13 16:40:02 +01:00
rustc_index doc: Add better explanation 2024-03-06 16:54:42 +01:00
rustc_index_macros Step all bootstrap cfgs forward 2024-02-08 07:44:34 -05:00
rustc_infer Create some minimal HIR for associated opaque types 2024-03-13 17:33:09 +03:00
rustc_interface Rollup merge of #121764 - Zoxc:incr-sess-no-source, r=oli-obk 2024-03-14 20:00:18 +01:00
rustc_lexer Invert diagnostic lints. 2024-02-06 13:12:33 +11:00
rustc_lint Auto merge of #120943 - petrochenkov:somehir3, r=oli-obk 2024-03-14 14:28:58 +00:00
rustc_lint_defs Rollup merge of #122482 - weiznich:fix/122446, r=compiler-errors 2024-03-14 15:44:36 +01:00
rustc_llvm llvm-wrapper: adapt for LLVM API changes 2024-03-12 12:39:25 +00:00
rustc_log rustc_log: expose tracing-tree "wraparound" in an env var 2024-03-03 12:33:26 +01:00
rustc_macros Rename diagnostic derive things. 2024-03-11 10:06:34 +11:00
rustc_metadata s/mt/mutability/ 2024-03-12 05:53:46 +00:00
rustc_middle Rollup merge of #122322 - Zalathar:branch, r=oli-obk 2024-03-14 20:00:19 +01:00
rustc_mir_build Rollup merge of #122322 - Zalathar:branch, r=oli-obk 2024-03-14 20:00:19 +01:00
rustc_mir_dataflow Distinguish between library and lang UB in assert_unsafe_precondition 2024-03-08 18:53:58 -05:00
rustc_mir_transform Rollup merge of #122322 - Zalathar:branch, r=oli-obk 2024-03-14 20:00:19 +01:00
rustc_monomorphize Rollup merge of #122287 - RalfJung:simd-static-assert, r=pnkfelix 2024-03-14 15:44:33 +01:00
rustc_next_trait_solver Allow a way to add constructors for rustc_type_ir types 2024-03-04 15:39:59 +00:00
rustc_parse Fix ICE in diagnostics for parenthesized type arguments 2024-03-12 21:32:21 +01:00
rustc_parse_format remove a couple of redundant clones 2024-02-17 12:46:18 +01:00
rustc_passes Create some minimal HIR for associated opaque types 2024-03-13 17:33:09 +03:00
rustc_pattern_analysis Rollup merge of #122437 - Nadrieril:no-after-max, r=compiler-errors 2024-03-13 20:01:57 +01:00
rustc_privacy Change DefKind::Static to a struct variant 2024-03-12 05:53:46 +00:00
rustc_query_impl Verify that query keys result in unique dep nodes 2024-03-12 05:31:41 +01:00
rustc_query_system Rollup merge of #122245 - saethlin:check-dep-graph-size, r=petrochenkov 2024-03-12 09:04:00 -07:00
rustc_resolve delay expand macro bang when there has indeterminate path 2024-03-13 16:11:16 +08:00
rustc_serialize Replace NonZero::<_>::new with NonZero::new. 2024-02-15 08:09:42 +01:00
rustc_session Rollup merge of #122322 - Zalathar:branch, r=oli-obk 2024-03-14 20:00:19 +01:00
rustc_smir Rollup merge of #122405 - celinval:smir-new-const, r=oli-obk 2024-03-14 11:09:58 +01:00
rustc_span Ensure nested allocations in statics do not get deduplicated 2024-03-12 05:53:46 +00:00
rustc_symbol_mangling Rename IntoDiagnostic as Diagnostic. 2024-03-11 09:15:09 +11:00
rustc_target Rollup merge of #122212 - erikdesjardins:byval-align2, r=wesleywiser 2024-03-14 20:00:18 +01:00
rustc_trait_selection Rollup merge of #122238 - fee1-dead-contrib:builtin-impl-next-solver-dox, r=lcnr 2024-03-14 15:44:32 +01:00
rustc_traits Merge check_mod_impl_wf and check_mod_type_wf 2024-03-07 06:27:09 +00:00
rustc_transmute safe transmute: require that src referent is smaller than dst 2024-03-13 15:53:48 +00:00
rustc_ty_utils Create some minimal HIR for associated opaque types 2024-03-13 17:33:09 +03:00
rustc_type_ir Remove Ord from ClosureKind 2024-03-09 21:16:43 +08:00
stable_mir Rollup merge of #122405 - celinval:smir-new-const, r=oli-obk 2024-03-14 11:09:58 +01:00