Skip to content

Commit

Permalink
Rollup merge of #114354 - Zalathar:external-counters, r=jackh726
Browse files Browse the repository at this point in the history
coverage: Store BCB counter info externally, not directly in the BCB graph

When deciding how to instrument the underlying MIR for coverage, the `InstrumentCoverage` pass builds a simplified “Basic Counter Block” graph, and then allocates coverage counters/expressions to various nodes/edges in the BCB graph as necessary. Those counters/expressions are then injected into the function's MIR.

The awkward thing here is that the code for doing this needs `&mut` access to the graph, in order to associate coverage info with individual nodes, even though it isn't making any structural changes to the graph itself. That makes it harder to understand and modify the instrumentation code.

In addition, the graph alone can't hold all the information that is needed. There ends up being an extra vector of “intermediate expressions” that needs to be passed around separately anyway.

---

This PR simplifies things by instead storing all of that temporary coverage information in a number of side-tables inside `CoverageCounters`.

This makes it easier to see all of the information produced by the make-counters step, and how it is used by the inject-into-mir step.

---

Looking at the combined changes is possible, but I recommend reviewing the commits individually, because the big changes are mostly independent of each other (despite being conceptually related).
  • Loading branch information
GuillaumeGomez committed Aug 13, 2023
2 parents 99144c3 + 5ca30c4 commit 2442c9b
Show file tree
Hide file tree
Showing 5 changed files with 223 additions and 257 deletions.

0 comments on commit 2442c9b

Please sign in to comment.