diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2023-08-01 17:39:10 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-08-01 17:39:10 +0200 |
| commit | 52bfceb8f93e2b7ad217f5dba89344e8743417f9 (patch) | |
| tree | 8ad4cefd4353f9812e638a605329e875b0de460b /compiler/rustc_codegen_llvm/src/builder.rs | |
| parent | c97af34de1fc1b92a5b600d831cad48e742ed4c3 (diff) | |
| parent | 3920e07f0bd97d9815a037eaeea197266424cd56 (diff) | |
| download | rust-52bfceb8f93e2b7ad217f5dba89344e8743417f9.tar.gz rust-52bfceb8f93e2b7ad217f5dba89344e8743417f9.zip | |
Rollup merge of #113428 - Zalathar:operand, r=davidtwco
coverage: Replace `ExpressionOperandId` with enum `Operand` *This is one step in my larger coverage refactoring ambitions described at <https://github.com/rust-lang/compiler-team/issues/645>.* LLVM coverage has a concept of “mapping expressions” that allow a span's execution count to be computed as a simple arithmetic expression over other counters/expressions, instead of requiring a dedicated physical counter for every control-flow branch. These expressions have an operator (`+` or `-`) and two operands. Operands are currently represented as `ExpressionOperandId`, which wraps a `u32` with the following semantics: - 0 represents a special counter that always has a value of zero - Values ascending from 1 represent counter IDs - Values descending from `u32::MAX` represent the IDs of other expressions --- This change replaces that whole `ExpressionOperandId` scheme with a simple enum that explicitly distinguishes between the three cases. This lets us remove a lot of fiddly code for dealing with the different operand kinds: - Previously it was only possible to distinguish between counter-ID operands and expression-ID operands by comparing the operand ID with the total number of counters in a function. This is unnecessary now that the enum distinguishes them explicitly. - There's no need for expression IDs to descend from `u32::MAX` and then get translated into zero-based indices in certain places. Now that they ascend from zero, they can be used as indices directly. - There's no need to reserve ID number 0 for the special zero operand, since it can just have its own variant in the enum, so counter IDs can count up from 0. (Making counter IDs ascend from 0 also lets us fix an off-by-one error in the query for counting the total number of counters, which would cause LLVM to emit an extra unused counter for every instrumented function.) --- This PR may be easiest to review as individual patches, since that breaks it up into clearly distinct parts: - Replace a `u32` wrapper with an explicit enum, without changing the semantics of the underlying IDs being stored. - Change the numbering scheme used by `Operand::Expression` to make expression IDs ascend from 0 (instead of descending from `u32::MAX`). - Change the numbering scheme used by `Operand::Counter` to make counter IDs ascend from 0 (instead of ascending from 1).
Diffstat (limited to 'compiler/rustc_codegen_llvm/src/builder.rs')
0 files changed, 0 insertions, 0 deletions
