rust/compiler
bors 36aab8df0a Auto merge of #115301 - Zalathar:regions-vec, r=davidtwco
coverage: Allow each coverage statement to have multiple code regions

The original implementation of coverage instrumentation was built around the assumption that a coverage counter/expression would be associated with *up to one* code region. When it was discovered that *multiple* regions would sometimes need to share a counter, a workaround was found: for the remaining regions, the instrumentor would create a fresh expression that adds zero  to the existing counter/expression.

That got the job done, but resulted in some awkward code, and produces unnecessarily complicated coverage maps in the final binary.

---

This PR removes that tension by changing `StatementKind::Coverage`'s code region field from `Option<CodeRegion>` to `Vec<CodeRegion>`.

The changes on the codegen side are fairly straightforward. As long as each `CoverageKind::Counter` only injects one `llvm.instrprof.increment`, the rest of coverage codegen is happy to handle multiple regions mapped to the same counter/expression, with only minor option-to-vec adjustments.

On the instrumentor/mir-transform side, we can get rid of the code that creates extra (x + 0) expressions. Instead we gather all of the code regions associated with a single BCB, and inject them all into one coverage statement.

---

There are several patches here but they can be divided in to three phases:
- Preparatory work
- Actually switching over to multiple regions per coverage statement
- Cleaning up

So viewing the patches individually may be easier.
2023-10-03 18:36:21 +00:00
..
rustc Split out the stable part of smir into its own crate to prevent accidental usage of forever unstable things 2023-09-25 14:38:27 +00:00
rustc_abi Name some local variables more consistently. 2023-10-02 09:12:47 +11:00
rustc_arena Inline and remove DroplessArena::alloc_raw_without_grow. 2023-09-28 17:58:56 +10:00
rustc_ast Factor out the two entry_point_type functions. 2023-10-01 20:45:09 +11:00
rustc_ast_lowering subst -> instantiate 2023-09-26 09:37:55 +02:00
rustc_ast_passes Validate ~const trait bounds on associated fns. 2023-09-30 19:00:45 -04:00
rustc_ast_pretty
rustc_attr
rustc_baked_icu_data
rustc_borrowck have better explanation for relate_types 2023-10-02 23:39:45 +03:00
rustc_builtin_macros Factor out the two entry_point_type functions. 2023-10-01 20:45:09 +11:00
rustc_codegen_cranelift Auto merge of #115025 - ouz-a:ouz_testing, r=lcnr 2023-10-03 10:02:52 +00:00
rustc_codegen_gcc Auto merge of #102099 - InnovativeInventor:re-cold-land, r=nikic 2023-10-02 22:02:12 +00:00
rustc_codegen_llvm coverage: Let each coverage statement hold a vector of code regions 2023-10-03 13:03:39 +11:00
rustc_codegen_ssa Auto merge of #115025 - ouz-a:ouz_testing, r=lcnr 2023-10-03 10:02:52 +00:00
rustc_const_eval Auto merge of #116376 - matthiaskrgr:rollup-b3d14gq, r=matthiaskrgr 2023-10-03 11:49:06 +00:00
rustc_data_structures Rename cold_path to outline 2023-09-25 22:54:07 +02:00
rustc_driver
rustc_driver_impl Auto merge of #115627 - compiler-errors:icedump-no-std, r=m-ou-se 2023-09-19 16:56:25 +00:00
rustc_error_codes Auto merge of #115659 - compiler-errors:itp, r=cjgillot 2023-09-28 21:35:18 +00:00
rustc_error_messages
rustc_errors Auto merge of #115690 - ShE3py:Z-treat-err-as-bug, r=petrochenkov 2023-09-22 13:01:30 +00:00
rustc_expand
rustc_feature Auto merge of #115670 - Zoxc:outline-panic-macro-1, r=Mark-Simulacrum 2023-10-01 05:56:47 +00:00
rustc_fluent_macro Factor out common token generation in fluent_messages. 2023-10-02 16:47:10 +11:00
rustc_fs_util
rustc_graphviz
rustc_hir Auto merge of #115670 - Zoxc:outline-panic-macro-1, r=Mark-Simulacrum 2023-10-01 05:56:47 +00:00
rustc_hir_analysis Rollup merge of #116261 - lcnr:wf-only-clause, r=davidtwco 2023-10-03 16:24:15 +02:00
rustc_hir_pretty Record asyncness span in HIR 2023-09-21 19:18:14 +00:00
rustc_hir_typeck Rollup merge of #114654 - estebank:suggest-pin-macro, r=davidtwco 2023-10-03 16:24:15 +02:00
rustc_incremental Don't use a thread to load the dep graph 2023-09-24 00:30:43 +02:00
rustc_index
rustc_infer Rollup merge of #116358 - compiler-errors:match, r=lcnr 2023-10-03 12:24:12 +02:00
rustc_interface Don't use a thread to load the dep graph 2023-09-24 00:30:43 +02:00
rustc_lexer
rustc_lint Rollup merge of #116379 - fmease:opaq-hid-inf-bnds-non-lt-bndrs, r=compiler-errors 2023-10-03 16:24:17 +02:00
rustc_lint_defs Remove rustc_lint_defs::lint_array 2023-09-28 23:01:25 +02:00
rustc_llvm Remove unused features from rustc_llvm. 2023-10-03 15:54:44 +11:00
rustc_log Fix a comment. 2023-10-02 16:47:11 +11:00
rustc_macros
rustc_metadata Don't store lazyness in DefKind 2023-09-26 02:53:59 +00:00
rustc_middle Auto merge of #115301 - Zalathar:regions-vec, r=davidtwco 2023-10-03 18:36:21 +00:00
rustc_mir_build Auto merge of #115025 - ouz-a:ouz_testing, r=lcnr 2023-10-03 10:02:52 +00:00
rustc_mir_dataflow have better explanation for relate_types 2023-10-02 23:39:45 +03:00
rustc_mir_transform Auto merge of #115301 - Zalathar:regions-vec, r=davidtwco 2023-10-03 18:36:21 +00:00
rustc_monomorphize Rollup merge of #115863 - chenyukang:yukang-add-message-tidy-check, r=davidtwco 2023-10-03 12:24:11 +02:00
rustc_parse Rollup merge of #115863 - chenyukang:yukang-add-message-tidy-check, r=davidtwco 2023-10-03 12:24:11 +02:00
rustc_parse_format Rollup merge of #115611 - lukas-code:format!("{r#ident}"), r=compiler-errors 2023-09-17 11:23:25 +00:00
rustc_passes Factor out the two entry_point_type functions. 2023-10-01 20:45:09 +11:00
rustc_plugin_impl
rustc_privacy Don't store lazyness in DefKind 2023-09-26 02:53:59 +00:00
rustc_query_impl Move DepKind to rustc_query_system and define it as u16 2023-09-21 17:06:14 +02:00
rustc_query_system Rollup merge of #115863 - chenyukang:yukang-add-message-tidy-check, r=davidtwco 2023-10-03 12:24:11 +02:00
rustc_resolve Rollup merge of #115863 - chenyukang:yukang-add-message-tidy-check, r=davidtwco 2023-10-03 12:24:11 +02:00
rustc_serialize Open the FileEncoder file for reading and writing 2023-09-22 16:13:25 -04:00
rustc_session Rollup merge of #115863 - chenyukang:yukang-add-message-tidy-check, r=davidtwco 2023-10-03 12:24:11 +02:00
rustc_smir remove unimplemented 2023-09-28 19:52:41 +03:00
rustc_span Auto merge of #115670 - Zoxc:outline-panic-macro-1, r=Mark-Simulacrum 2023-10-01 05:56:47 +00:00
rustc_symbol_mangling Remove span from BrAnon. 2023-09-24 09:46:55 +00:00
rustc_target Fix broken links 2023-09-30 10:26:04 +08:00
rustc_trait_selection Rollup merge of #116261 - lcnr:wf-only-clause, r=davidtwco 2023-10-03 16:24:15 +02:00
rustc_traits Detect cycle errors hidden by opaques during monomorphization 2023-09-13 17:35:44 +00:00
rustc_transmute make the eval() functions on our const types return the resulting value 2023-09-13 07:29:34 +02:00
rustc_ty_utils a small wf and clause cleanup 2023-09-29 11:34:50 +02:00
rustc_type_ir Auto merge of #116069 - compiler-errors:debug-tuple, r=Nilstrieb 2023-09-24 15:16:18 +00:00
stable_mir Rollup merge of #116024 - ouz-a:smir_region, r=oli-obk 2023-09-29 22:27:50 +02:00