Uh oh!
There was an error while loading. Please reload this page.
coverage: Collect HIR info during MIR building - #118237
Conversation
rustbot
commented
Nov 24, 2023
r? @wesleywiser (rustbot has picked a reviewer for you, use r? to override) |
rustbot
commented
Nov 24, 2023
Some changes occurred to MIR optimizations cc @rust-lang/wg-mir-opt |
| } | ||
| fn hash_mir_source<'tcx>(tcx: TyCtxt<'tcx>, hir_body: &'tcx rustc_hir::Body<'tcx>) -> u64 { | ||
| // FIXME(cjgillot) Stop hashing HIR manually here. |
There was a problem hiding this comment.
Zalathar
commented
Nov 24, 2023
@rustbot label +A-code-coverage |
7f3f9d3 to
e8381deCompare
cjgillot
left a comment
There was a problem hiding this comment.
In addition to general MIR-pass cleanliness, part of the motivation here is to make it easier to collect additional coverage information from HIR/THIR in the future, because much of the plumbing has been established by this PR.
There is a premise here that I can't quite agree with. Looking at HIR from a MIR pass is not an issue. What kind of information would you need to channel in the future?
Uh oh!
There was an error while loading. Please reload this page.
Zalathar
commented
Dec 4, 2023
The concrete motivation is branch coverage instrumentation (#118305). I want to have an accurate association between the span of an So the approach I've taken in my branch coverage draft is to add code to the lowering of |
Zalathar
commented
Dec 4, 2023
So the two main things I care about from this PR are:
Putting the signature/body span in that field is kind of secondary. I've done it so that this PR doesn't end up looking kind of pointless (in isolation), and also because the comments on that code gave me the impression that looking backwards at HIR from a MIR pass was gently discouraged. But in truth it's not really the central focus of this PR. |
da6f75e to
1bc26f4CompareIf the function signature span comes after the body span (due to macro expansion), expanding it towards the start of the body span would produce nonsense.
The coverage instrumentor pass operates on MIR, but it needs access to some source-related information that is normally not present in MIR. Historically, that information was obtained by looking back at HIR during MIR transformation. This patch arranges for the necessary information to be collected ahead of time during MIR building instead.
Zalathar
commented
Dec 11, 2023
Another thing I could do with this PR is remove the part that actually moves code into Then I could integrate the MIR building changes into #118305, where they would be easier to justify. |
bors
commented
Dec 13, 2023
☔ The latest upstream changes (presumably #118500) made this pull request unmergeable. Please resolve the merge conflicts. |
Zalathar
commented
Dec 14, 2023
This needed some intensive manual rebasing, so I've instead reworked it into #118929. |
coverage: Tidy up early parts of the instrumentor pass This is extracted from rust-lang#118237, which needed to be manually rebased anyway. Unlike that PR, this one only affects the coverage instrumentor, and doesn't attempt to move any code into the MIR builder. That can be left to a future version of rust-lang#118305, which can still benefit from these improvements. So this is now mostly a refactoring of some internal parts of the instrumentor.
Rollup merge of rust-lang#118929 - Zalathar:look-hir, r=cjgillot coverage: Tidy up early parts of the instrumentor pass This is extracted from rust-lang#118237, which needed to be manually rebased anyway. Unlike that PR, this one only affects the coverage instrumentor, and doesn't attempt to move any code into the MIR builder. That can be left to a future version of rust-lang#118305, which can still benefit from these improvements. So this is now mostly a refactoring of some internal parts of the instrumentor.
The coverage instrumentor pass operates on MIR, but it needs access to some source-related information that is normally not present in MIR.
Historically, that information was obtained by looking back at HIR during MIR transformation. This PR arranges for the necessary information to be collected ahead of time during MIR building instead.
Fixes#79625.
In addition to general MIR-pass cleanliness, part of the motivation here is to make it easier to collect additional coverage information from HIR/THIR in the future, because much of the plumbing has been established by this PR.