rust/compiler/rustc_middle/src/mir
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
..
interpret Auto merge of #115827 - eduardosm:miri-sse-reduce-code-dup, r=RalfJung 2023-09-20 12:07:26 +00:00
basic_blocks.rs Remove deleted docs + better link together MIR traversing docs 2023-09-29 19:16:02 +00:00
consts.rs Move eval_bits optimization upstream 2023-10-01 21:12:24 +02:00
coverage.rs coverage: Remove next_id methods from counter/expression IDs 2023-10-03 13:03:40 +11:00
generic_graph.rs inline format!() args up to and including rustc_middle 2023-07-30 13:18:33 +02:00
generic_graphviz.rs inline format!() args up to and including rustc_middle 2023-07-30 13:18:33 +02:00
graphviz.rs inline format!() args up to and including rustc_middle 2023-07-30 13:18:33 +02:00
mod.rs rename mir::Constant -> mir::ConstOperand, mir::ConstKind -> mir::Const 2023-09-21 08:12:30 +02:00
mono.rs treat host effect params as erased generics in codegen 2023-09-14 07:34:35 +00:00
patch.rs cache the terminate block with the last reason that we saw 2023-08-24 13:28:26 +02:00
pretty.rs Auto merge of #115301 - Zalathar:regions-vec, r=davidtwco 2023-10-03 18:36:21 +00:00
query.rs Remove span from BrAnon. 2023-09-24 09:46:55 +00:00
spanview.rs sync printing of MIR terminators with their new names (and dedup some to-str logic) 2023-08-20 15:52:40 +02:00
statement.rs Add docs, remove code, change subtyper code 2023-10-02 23:39:44 +03:00
syntax.rs Auto merge of #115301 - Zalathar:regions-vec, r=davidtwco 2023-10-03 18:36:21 +00:00
tcx.rs have better explanation for relate_types 2023-10-02 23:39:45 +03:00
terminator.rs organize mir pretty.rs and move more things into it; move statement-related things out of mir/mod.rs 2023-09-19 11:06:32 +02:00
traversal.rs Remove deleted docs + better link together MIR traversing docs 2023-09-29 19:16:02 +00:00
type_foldable.rs Remove more unused Lift impls. 2023-09-18 09:37:10 +10:00
visit.rs Add docs, remove code, change subtyper code 2023-10-02 23:39:44 +03:00