-
Notifications
You must be signed in to change notification settings - Fork 12.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
coverage: Move most per-function coverage info into mir::Body
#116046
Conversation
646abfa
to
adce72b
Compare
When I moved expression data into To my surprise, I found that this can't be done without regressing the mappings: even though an expression statement no longer carries op/operand data, it still witnesses the fact that its enclosing BB/BCB wasn't removed by later MIR transforms. ( So when coverage codegen generates the final mappings to embed in the binary, it can zero out any mappings whose BB/BCB was removed by MIR transforms, while leaving all other mappings intact. (This zeroing is also currently load-bearing for unused functions: instead of explicitly zeroing out all of the mappings, we rely on the normal-case zeroing code to observe that no counters/expressions were ever seen for an unused function's mappings.) |
4b27f9d
to
d990af0
Compare
I've also renamed the remaining variants of EDIT: Also updated the docs for |
a3befaf
to
3e0a088
Compare
3e0a088
to
7899bc3
Compare
When coverage instrumentation and MIR opts are both enabled, coverage relies on two assumptions: - MIR opts that would delete `StatementKind::Coverage` statements instead move them into bb0 and change them to `CoverageKind::Unreachable`. - MIR opts won't delete all `CoverageKind::Counter` statements from an instrumented function. Most MIR opts naturally satisfy the second assumption, because they won't remove coverage statements from bb0, but `UnreachablePropagation` can do so if it finds that bb0 is unreachable. If this happens, LLVM thinks the function is uncovered, and it vanishes from coverage reports. A proper solution won't be possible until after per-function coverage info lands in rust-lang#116046, but for now we can avoid the problem by turning off this particular pass when coverage instrumentation is enabled.
When coverage instrumentation and MIR opts are both enabled, coverage relies on two assumptions: - MIR opts that would delete `StatementKind::Coverage` statements instead move them into bb0 and change them to `CoverageKind::Unreachable`. - MIR opts won't delete all `CoverageKind::Counter` statements from an instrumented function. Most MIR opts naturally satisfy the second assumption, because they won't remove coverage statements from bb0, but `UnreachablePropagation` can do so if it finds that bb0 is unreachable. If this happens, LLVM thinks the function isn't instrumented, and it vanishes from coverage reports. A proper solution won't be possible until after per-function coverage info lands in rust-lang#116046, but for now we can avoid the problem by turning off this particular pass when coverage instrumentation is enabled.
When coverage instrumentation and MIR opts are both enabled, coverage relies on two assumptions: - MIR opts that would delete `StatementKind::Coverage` statements instead move them into bb0 and change them to `CoverageKind::Unreachable`. - MIR opts won't delete all `CoverageKind::Counter` statements from an instrumented function. Most MIR opts naturally satisfy the second assumption, because they won't remove coverage statements from bb0, but `UnreachablePropagation` can do so if it finds that bb0 is unreachable. If this happens, LLVM thinks the function isn't instrumented, and it vanishes from coverage reports. A proper solution won't be possible until after per-function coverage info lands in rust-lang#116046, but for now we can avoid the problem by turning off this particular pass when coverage instrumentation is enabled.
When coverage instrumentation and MIR opts are both enabled, coverage relies on two assumptions: - MIR opts that would delete `StatementKind::Coverage` statements instead move them into bb0 and change them to `CoverageKind::Unreachable`. - MIR opts won't delete all `CoverageKind::Counter` statements from an instrumented function. Most MIR opts naturally satisfy the second assumption, because they won't remove coverage statements from bb0, but `UnreachablePropagation` can do so if it finds that bb0 is unreachable. If this happens, LLVM thinks the function isn't instrumented, and it vanishes from coverage reports. A proper solution won't be possible until after per-function coverage info lands in rust-lang#116046, but for now we can avoid the problem by turning off this particular pass when coverage instrumentation is enabled.
☔ The latest upstream changes (presumably #116154) made this pull request unmergeable. Please resolve the merge conflicts. |
7899bc3
to
2d3a240
Compare
Skip MIR pass `UnreachablePropagation` when coverage is enabled When coverage instrumentation and MIR opts are both enabled, coverage relies on two assumptions: - MIR opts that would delete `StatementKind::Coverage` statements instead move them into bb0 and change them to `CoverageKind::Unreachable`. - MIR opts won't delete all `CoverageKind::Counter` statements from an instrumented function. Most MIR opts naturally satisfy the second assumption, because they won't remove coverage statements from bb0, but `UnreachablePropagation` can do so if it finds that bb0 is unreachable. If this happens, LLVM thinks the function isn't instrumented, and it vanishes from coverage reports. A proper solution won't be possible until after per-function coverage info lands in rust-lang#116046, but for now we can avoid the problem by turning off this particular pass when coverage instrumentation is enabled. --- cc `@cjgillot` since I found this while investigating coverage problems encountered by rust-lang#113970 `@rustbot` label +A-code-coverage +A-mir-opt
ed54edf
to
d3933ed
Compare
coverage: Move most per-function coverage info into `mir::Body` Currently, all of the coverage information collected by the `InstrumentCoverage` pass is smuggled through MIR in the form of individual `StatementKind::Coverage` statements, which must then be reassembled by coverage codegen. That's awkward for a number of reasons: - While some of the coverage statements do care about their specific position in the MIR control-flow graph, many of them don't, and are just tacked onto the function's first BB as metadata carriers. - MIR inlining can result in coverage statements being duplicated, so coverage codegen has to jump through hoops to avoid emitting duplicate mappings. - MIR optimizations that would delete coverage statements need to carefully copy them into the function's first BB so as not to omit them from coverage reports. - The order in which coverage codegen sees coverage statements is dependent on MIR optimizations/inlining, which can cause unnecessary churn in the emitted coverage mappings. - We don't have a good way to annotate MIR-level functions with extra coverage info that doesn't belong in a statement. --- This PR therefore takes most of the per-function coverage info and stores it in a field in `mir::Body` as `Option<Box<FunctionCoverageInfo>>`. (This adds one pointer to the size of `mir::Body`, even when coverage is not enabled.) Coverage statements still need to be injected into MIR in some cases, but only when they actually affect codegen (counters) or are needed to detect code that has been optimized away as unreachable (counters/expressions). --- By the end of this PR, the information stored in `FunctionCoverageInfo` is: - A hash of the function's source code (needed by LLVM's coverage map format) - The number of coverage counters added by coverage instrumentation - A table of coverage expressions, associating each expression ID with its operator (add or subtract) and its two operands - The list of mappings, associating each covered code region with a counter/expression/zero value --- ~~This is built on top of rust-lang#115301, so I'll rebase and roll a reviewer once that lands.~~ r? `@ghost` `@rustbot` label +A-code-coverage
💔 Test failed - checks-actions |
@bors retry failed to download from |
☀️ Test successful - checks-actions |
Finished benchmarking commit (cc705b8): comparison URL. Overall result: no relevant changes - no action needed@rustbot label: -perf-regression Instruction countThis benchmark run did not return any relevant results for this metric. Max RSS (memory usage)ResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
CyclesResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
Binary sizeResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
Bootstrap: 628.593s -> 628.235s (-0.06%) |
coverage: Simplify the injection of coverage statements This is a follow-up to rust-lang#116046 that I left out of that PR because I didn't want to make it any larger. After the various changes we've made to how coverage data is stored and transferred, the old code structure for injecting coverage statements into MIR is built around a lot of constraints that don't exist any more. We can simplify it by replacing it with a handful of loops over the BCB node/edge counters and the BCB spans. --- `@rustbot` label +A-code-coverage
Rollup merge of rust-lang#116917 - Zalathar:injection, r=cjgillot coverage: Simplify the injection of coverage statements This is a follow-up to rust-lang#116046 that I left out of that PR because I didn't want to make it any larger. After the various changes we've made to how coverage data is stored and transferred, the old code structure for injecting coverage statements into MIR is built around a lot of constraints that don't exist any more. We can simplify it by replacing it with a handful of loops over the BCB node/edge counters and the BCB spans. --- `@rustbot` label +A-code-coverage
74: Automated pull from upstream `master` r=tshepang a=github-actions[bot] This PR pulls the following changes from the upstream repository: * rust-lang/rust#117363 * rust-lang/rust#116405 * rust-lang/rust#117415 * rust-lang/rust#117414 * rust-lang/rust#117411 * rust-lang/rust#117403 * rust-lang/rust#117398 * rust-lang/rust#117396 * rust-lang/rust#117389 * rust-lang/rust#116862 * rust-lang/rust#117405 * rust-lang/rust#117395 * rust-lang/rust#117390 * rust-lang/rust#117383 * rust-lang/rust#117376 * rust-lang/rust#117370 * rust-lang/rust#117357 * rust-lang/rust#117356 * rust-lang/rust#117317 * rust-lang/rust#117132 * rust-lang/rust#117068 * rust-lang/rust#112463 * rust-lang/rust#117267 * rust-lang/rust#116939 * rust-lang/rust#117387 * rust-lang/rust#117385 * rust-lang/rust#117382 * rust-lang/rust#117371 * rust-lang/rust#117365 * rust-lang/rust#117350 * rust-lang/rust#117205 * rust-lang/rust#117177 * rust-lang/rust#117147 * rust-lang/rust#116485 * rust-lang/rust#117328 * rust-lang/rust#117332 * rust-lang/rust#117089 * rust-lang/rust#116733 * rust-lang/rust#116889 * rust-lang/rust#116270 * rust-lang/rust#117354 * rust-lang/rust#117337 * rust-lang/rust#117312 * rust-lang/rust#117082 * rust-lang/rust#117043 * rust-lang/rust#115968 * rust-lang/rust#117336 * rust-lang/rust#117325 * rust-lang/rust#117322 * rust-lang/rust#117259 * rust-lang/rust#117170 * rust-lang/rust#117335 * rust-lang/rust#117319 * rust-lang/rust#117316 * rust-lang/rust#117311 * rust-lang/rust#117162 * rust-lang/rust#115773 * rust-lang/rust#116447 * rust-lang/rust#117149 * rust-lang/rust#116240 * rust-lang/rust#117123 * rust-lang/rust#81746 * rust-lang/rust#117038 * rust-lang/rust#116609 * rust-lang/rust#117309 * rust-lang/rust#117277 * rust-lang/rust#117268 * rust-lang/rust#117256 * rust-lang/rust#117025 * rust-lang/rust#116945 * rust-lang/rust#116816 * rust-lang/rust#116739 * rust-lang/rust#116534 * rust-lang/rust#117253 * rust-lang/rust#117302 * rust-lang/rust#117197 * rust-lang/rust#116471 * rust-lang/rust#117294 * rust-lang/rust#117287 * rust-lang/rust#117281 * rust-lang/rust#117270 * rust-lang/rust#117247 * rust-lang/rust#117246 * rust-lang/rust#117212 * rust-lang/rust#116834 * rust-lang/rust#103208 * rust-lang/rust#117166 * rust-lang/rust#116751 * rust-lang/rust#116858 * rust-lang/rust#117272 * rust-lang/rust#117266 * rust-lang/rust#117262 * rust-lang/rust#117241 * rust-lang/rust#117240 * rust-lang/rust#116868 * rust-lang/rust#114998 * rust-lang/rust#116205 * rust-lang/rust#117260 * rust-lang/rust#116035 * rust-lang/rust#113183 * rust-lang/rust#117249 * rust-lang/rust#117243 * rust-lang/rust#117188 * rust-lang/rust#117114 * rust-lang/rust#117106 * rust-lang/rust#117032 * rust-lang/rust#116968 * rust-lang/rust#116581 * rust-lang/rust#117228 * rust-lang/rust#117221 * rust-lang/rust#117214 * rust-lang/rust#117207 * rust-lang/rust#117202 * rust-lang/rust#117194 * rust-lang/rust#117143 * rust-lang/rust#117095 * rust-lang/rust#116905 * rust-lang/rust#117171 * rust-lang/rust#113262 * rust-lang/rust#112875 * rust-lang/rust#116983 * rust-lang/rust#117148 * rust-lang/rust#117115 * rust-lang/rust#116818 * rust-lang/rust#115872 * rust-lang/rust#117193 * rust-lang/rust#117175 * rust-lang/rust#117009 * rust-lang/rust#117008 * rust-lang/rust#116931 * rust-lang/rust#116553 * rust-lang/rust#116401 * rust-lang/rust#117180 * rust-lang/rust#117173 * rust-lang/rust#117163 * rust-lang/rust#117159 * rust-lang/rust#117154 * rust-lang/rust#117152 * rust-lang/rust#117141 * rust-lang/rust#117111 * rust-lang/rust#117172 * rust-lang/rust#117168 * rust-lang/rust#117160 * rust-lang/rust#117158 * rust-lang/rust#117150 * rust-lang/rust#117136 * rust-lang/rust#117133 * rust-lang/rust#116801 * rust-lang/rust#117165 * rust-lang/rust#117113 * rust-lang/rust#117102 * rust-lang/rust#117076 * rust-lang/rust#116236 * rust-lang/rust#116993 * rust-lang/rust#117139 * rust-lang/rust#116482 * rust-lang/rust#115796 * rust-lang/rust#117135 * rust-lang/rust#117127 * rust-lang/rust#117010 * rust-lang/rust#116943 * rust-lang/rust#116841 * rust-lang/rust#116792 * rust-lang/rust#116714 * rust-lang/rust#116396 * rust-lang/rust#116094 * rust-lang/rust#117126 * rust-lang/rust#117105 * rust-lang/rust#117093 * rust-lang/rust#117092 * rust-lang/rust#117091 * rust-lang/rust#117081 * rust-lang/rust#116773 * rust-lang/rust#117124 * rust-lang/rust#116461 * rust-lang/rust#116435 * rust-lang/rust#116319 * rust-lang/rust#116238 * rust-lang/rust#116998 * rust-lang/rust#116300 * rust-lang/rust#117103 * rust-lang/rust#117086 * rust-lang/rust#117074 * rust-lang/rust#117070 * rust-lang/rust#117046 * rust-lang/rust#116859 * rust-lang/rust#107159 * rust-lang/rust#116033 * rust-lang/rust#107009 * rust-lang/rust#117087 * rust-lang/rust#117073 * rust-lang/rust#117064 * rust-lang/rust#117040 * rust-lang/rust#116978 * rust-lang/rust#116960 * rust-lang/rust#116837 * rust-lang/rust#116835 * rust-lang/rust#116849 * rust-lang/rust#117071 * rust-lang/rust#117069 * rust-lang/rust#117051 * rust-lang/rust#117049 * rust-lang/rust#117044 * rust-lang/rust#117042 * rust-lang/rust#105666 * rust-lang/rust#116606 * rust-lang/rust#117066 * rust-lang/rust#115324 * rust-lang/rust#117062 * rust-lang/rust#117000 * rust-lang/rust#117007 * rust-lang/rust#117018 * rust-lang/rust#116256 * rust-lang/rust#117041 * rust-lang/rust#117037 * rust-lang/rust#117034 * rust-lang/rust#116989 * rust-lang/rust#116985 * rust-lang/rust#116950 * rust-lang/rust#116956 * rust-lang/rust#116932 * rust-lang/rust#117031 * rust-lang/rust#117030 * rust-lang/rust#117028 * rust-lang/rust#117026 * rust-lang/rust#116992 * rust-lang/rust#116981 * rust-lang/rust#116955 * rust-lang/rust#116928 * rust-lang/rust#116312 * rust-lang/rust#116368 * rust-lang/rust#116922 * rust-lang/rust#117021 * rust-lang/rust#117020 * rust-lang/rust#117019 * rust-lang/rust#116975 * rust-lang/rust#106601 * rust-lang/rust#116734 * rust-lang/rust#117013 * rust-lang/rust#116995 * rust-lang/rust#116990 * rust-lang/rust#116974 * rust-lang/rust#116964 * rust-lang/rust#116961 * rust-lang/rust#116917 * rust-lang/rust#116911 * rust-lang/rust#114521 * rust-lang/rust#117011 * rust-lang/rust#116958 * rust-lang/rust#116951 * rust-lang/rust#116966 * rust-lang/rust#116965 * rust-lang/rust#116962 * rust-lang/rust#116946 * rust-lang/rust#116899 * rust-lang/rust#116785 * rust-lang/rust#116838 * rust-lang/rust#116875 * rust-lang/rust#116874 * rust-lang/rust#115214 * rust-lang/rust#116810 * rust-lang/rust#116940 * rust-lang/rust#116921 * rust-lang/rust#116906 * rust-lang/rust#116896 * rust-lang/rust#116650 * rust-lang/rust#116132 * rust-lang/rust#116037 * rust-lang/rust#116923 * rust-lang/rust#116912 * rust-lang/rust#116908 * rust-lang/rust#116883 * rust-lang/rust#116829 * rust-lang/rust#116795 * rust-lang/rust#116761 * rust-lang/rust#116663 * rust-lang/rust#114534 * rust-lang/rust#116402 * rust-lang/rust#116493 * rust-lang/rust#116046 * rust-lang/rust#116887 * rust-lang/rust#116885 * rust-lang/rust#116879 * rust-lang/rust#116870 * rust-lang/rust#116865 * rust-lang/rust#116856 * rust-lang/rust#116812 * rust-lang/rust#116815 * rust-lang/rust#116814 * rust-lang/rust#116713 * rust-lang/rust#116830 Co-authored-by: Matthias Krüger <[email protected]> Co-authored-by: antoyo <[email protected]> Co-authored-by: Antoni Boucher <[email protected]> Co-authored-by: bors <[email protected]> Co-authored-by: Esteban Küber <[email protected]> Co-authored-by: Kjetil Kjeka <[email protected]> Co-authored-by: clubby789 <[email protected]> Co-authored-by: okaneco <[email protected]> Co-authored-by: David Tolnay <[email protected]> Co-authored-by: Nadrieril <[email protected]> Co-authored-by: Celina G. Val <[email protected]> Co-authored-by: Ralf Jung <[email protected]> Co-authored-by: Zalathar <[email protected]> Co-authored-by: Havard Eidnes <[email protected]> Co-authored-by: Jacob Pratt <[email protected]> Co-authored-by: Kjetil Kjeka <[email protected]>
74: Automated pull from upstream `master` r=tshepang a=github-actions[bot] This PR pulls the following changes from the upstream repository: * rust-lang/rust#117363 * rust-lang/rust#116405 * rust-lang/rust#117415 * rust-lang/rust#117414 * rust-lang/rust#117411 * rust-lang/rust#117403 * rust-lang/rust#117398 * rust-lang/rust#117396 * rust-lang/rust#117389 * rust-lang/rust#116862 * rust-lang/rust#117405 * rust-lang/rust#117395 * rust-lang/rust#117390 * rust-lang/rust#117383 * rust-lang/rust#117376 * rust-lang/rust#117370 * rust-lang/rust#117357 * rust-lang/rust#117356 * rust-lang/rust#117317 * rust-lang/rust#117132 * rust-lang/rust#117068 * rust-lang/rust#112463 * rust-lang/rust#117267 * rust-lang/rust#116939 * rust-lang/rust#117387 * rust-lang/rust#117385 * rust-lang/rust#117382 * rust-lang/rust#117371 * rust-lang/rust#117365 * rust-lang/rust#117350 * rust-lang/rust#117205 * rust-lang/rust#117177 * rust-lang/rust#117147 * rust-lang/rust#116485 * rust-lang/rust#117328 * rust-lang/rust#117332 * rust-lang/rust#117089 * rust-lang/rust#116733 * rust-lang/rust#116889 * rust-lang/rust#116270 * rust-lang/rust#117354 * rust-lang/rust#117337 * rust-lang/rust#117312 * rust-lang/rust#117082 * rust-lang/rust#117043 * rust-lang/rust#115968 * rust-lang/rust#117336 * rust-lang/rust#117325 * rust-lang/rust#117322 * rust-lang/rust#117259 * rust-lang/rust#117170 * rust-lang/rust#117335 * rust-lang/rust#117319 * rust-lang/rust#117316 * rust-lang/rust#117311 * rust-lang/rust#117162 * rust-lang/rust#115773 * rust-lang/rust#116447 * rust-lang/rust#117149 * rust-lang/rust#116240 * rust-lang/rust#117123 * rust-lang/rust#81746 * rust-lang/rust#117038 * rust-lang/rust#116609 * rust-lang/rust#117309 * rust-lang/rust#117277 * rust-lang/rust#117268 * rust-lang/rust#117256 * rust-lang/rust#117025 * rust-lang/rust#116945 * rust-lang/rust#116816 * rust-lang/rust#116739 * rust-lang/rust#116534 * rust-lang/rust#117253 * rust-lang/rust#117302 * rust-lang/rust#117197 * rust-lang/rust#116471 * rust-lang/rust#117294 * rust-lang/rust#117287 * rust-lang/rust#117281 * rust-lang/rust#117270 * rust-lang/rust#117247 * rust-lang/rust#117246 * rust-lang/rust#117212 * rust-lang/rust#116834 * rust-lang/rust#103208 * rust-lang/rust#117166 * rust-lang/rust#116751 * rust-lang/rust#116858 * rust-lang/rust#117272 * rust-lang/rust#117266 * rust-lang/rust#117262 * rust-lang/rust#117241 * rust-lang/rust#117240 * rust-lang/rust#116868 * rust-lang/rust#114998 * rust-lang/rust#116205 * rust-lang/rust#117260 * rust-lang/rust#116035 * rust-lang/rust#113183 * rust-lang/rust#117249 * rust-lang/rust#117243 * rust-lang/rust#117188 * rust-lang/rust#117114 * rust-lang/rust#117106 * rust-lang/rust#117032 * rust-lang/rust#116968 * rust-lang/rust#116581 * rust-lang/rust#117228 * rust-lang/rust#117221 * rust-lang/rust#117214 * rust-lang/rust#117207 * rust-lang/rust#117202 * rust-lang/rust#117194 * rust-lang/rust#117143 * rust-lang/rust#117095 * rust-lang/rust#116905 * rust-lang/rust#117171 * rust-lang/rust#113262 * rust-lang/rust#112875 * rust-lang/rust#116983 * rust-lang/rust#117148 * rust-lang/rust#117115 * rust-lang/rust#116818 * rust-lang/rust#115872 * rust-lang/rust#117193 * rust-lang/rust#117175 * rust-lang/rust#117009 * rust-lang/rust#117008 * rust-lang/rust#116931 * rust-lang/rust#116553 * rust-lang/rust#116401 * rust-lang/rust#117180 * rust-lang/rust#117173 * rust-lang/rust#117163 * rust-lang/rust#117159 * rust-lang/rust#117154 * rust-lang/rust#117152 * rust-lang/rust#117141 * rust-lang/rust#117111 * rust-lang/rust#117172 * rust-lang/rust#117168 * rust-lang/rust#117160 * rust-lang/rust#117158 * rust-lang/rust#117150 * rust-lang/rust#117136 * rust-lang/rust#117133 * rust-lang/rust#116801 * rust-lang/rust#117165 * rust-lang/rust#117113 * rust-lang/rust#117102 * rust-lang/rust#117076 * rust-lang/rust#116236 * rust-lang/rust#116993 * rust-lang/rust#117139 * rust-lang/rust#116482 * rust-lang/rust#115796 * rust-lang/rust#117135 * rust-lang/rust#117127 * rust-lang/rust#117010 * rust-lang/rust#116943 * rust-lang/rust#116841 * rust-lang/rust#116792 * rust-lang/rust#116714 * rust-lang/rust#116396 * rust-lang/rust#116094 * rust-lang/rust#117126 * rust-lang/rust#117105 * rust-lang/rust#117093 * rust-lang/rust#117092 * rust-lang/rust#117091 * rust-lang/rust#117081 * rust-lang/rust#116773 * rust-lang/rust#117124 * rust-lang/rust#116461 * rust-lang/rust#116435 * rust-lang/rust#116319 * rust-lang/rust#116238 * rust-lang/rust#116998 * rust-lang/rust#116300 * rust-lang/rust#117103 * rust-lang/rust#117086 * rust-lang/rust#117074 * rust-lang/rust#117070 * rust-lang/rust#117046 * rust-lang/rust#116859 * rust-lang/rust#107159 * rust-lang/rust#116033 * rust-lang/rust#107009 * rust-lang/rust#117087 * rust-lang/rust#117073 * rust-lang/rust#117064 * rust-lang/rust#117040 * rust-lang/rust#116978 * rust-lang/rust#116960 * rust-lang/rust#116837 * rust-lang/rust#116835 * rust-lang/rust#116849 * rust-lang/rust#117071 * rust-lang/rust#117069 * rust-lang/rust#117051 * rust-lang/rust#117049 * rust-lang/rust#117044 * rust-lang/rust#117042 * rust-lang/rust#105666 * rust-lang/rust#116606 * rust-lang/rust#117066 * rust-lang/rust#115324 * rust-lang/rust#117062 * rust-lang/rust#117000 * rust-lang/rust#117007 * rust-lang/rust#117018 * rust-lang/rust#116256 * rust-lang/rust#117041 * rust-lang/rust#117037 * rust-lang/rust#117034 * rust-lang/rust#116989 * rust-lang/rust#116985 * rust-lang/rust#116950 * rust-lang/rust#116956 * rust-lang/rust#116932 * rust-lang/rust#117031 * rust-lang/rust#117030 * rust-lang/rust#117028 * rust-lang/rust#117026 * rust-lang/rust#116992 * rust-lang/rust#116981 * rust-lang/rust#116955 * rust-lang/rust#116928 * rust-lang/rust#116312 * rust-lang/rust#116368 * rust-lang/rust#116922 * rust-lang/rust#117021 * rust-lang/rust#117020 * rust-lang/rust#117019 * rust-lang/rust#116975 * rust-lang/rust#106601 * rust-lang/rust#116734 * rust-lang/rust#117013 * rust-lang/rust#116995 * rust-lang/rust#116990 * rust-lang/rust#116974 * rust-lang/rust#116964 * rust-lang/rust#116961 * rust-lang/rust#116917 * rust-lang/rust#116911 * rust-lang/rust#114521 * rust-lang/rust#117011 * rust-lang/rust#116958 * rust-lang/rust#116951 * rust-lang/rust#116966 * rust-lang/rust#116965 * rust-lang/rust#116962 * rust-lang/rust#116946 * rust-lang/rust#116899 * rust-lang/rust#116785 * rust-lang/rust#116838 * rust-lang/rust#116875 * rust-lang/rust#116874 * rust-lang/rust#115214 * rust-lang/rust#116810 * rust-lang/rust#116940 * rust-lang/rust#116921 * rust-lang/rust#116906 * rust-lang/rust#116896 * rust-lang/rust#116650 * rust-lang/rust#116132 * rust-lang/rust#116037 * rust-lang/rust#116923 * rust-lang/rust#116912 * rust-lang/rust#116908 * rust-lang/rust#116883 * rust-lang/rust#116829 * rust-lang/rust#116795 * rust-lang/rust#116761 * rust-lang/rust#116663 * rust-lang/rust#114534 * rust-lang/rust#116402 * rust-lang/rust#116493 * rust-lang/rust#116046 * rust-lang/rust#116887 * rust-lang/rust#116885 * rust-lang/rust#116879 * rust-lang/rust#116870 * rust-lang/rust#116865 * rust-lang/rust#116856 * rust-lang/rust#116812 * rust-lang/rust#116815 * rust-lang/rust#116814 * rust-lang/rust#116713 * rust-lang/rust#116830 Co-authored-by: antoyo <[email protected]> Co-authored-by: Antoni Boucher <[email protected]> Co-authored-by: bors <[email protected]> Co-authored-by: Esteban Küber <[email protected]> Co-authored-by: Kjetil Kjeka <[email protected]> Co-authored-by: clubby789 <[email protected]> Co-authored-by: okaneco <[email protected]> Co-authored-by: David Tolnay <[email protected]> Co-authored-by: Nadrieril <[email protected]> Co-authored-by: Celina G. Val <[email protected]> Co-authored-by: Ralf Jung <[email protected]> Co-authored-by: Zalathar <[email protected]> Co-authored-by: Havard Eidnes <[email protected]> Co-authored-by: Jacob Pratt <[email protected]> Co-authored-by: Kjetil Kjeka <[email protected]> Co-authored-by: Matthias Krüger <[email protected]>
These two tasks historically needed to be interleaved, but after various recent changes (including rust-lang#116046 and rust-lang#116917) they can now be fully separated.
coverage: Prepare mappings separately from injecting statements These two tasks historically needed to be interleaved, but after various recent changes (including rust-lang#116046 and rust-lang#116917) they can now be fully separated. --- `@rustbot` label +A-code-coverage
These two tasks historically needed to be interleaved, but after various recent changes (including rust-lang#116046 and rust-lang#116917) they can now be fully separated.
Currently, all of the coverage information collected by the
InstrumentCoverage
pass is smuggled through MIR in the form of individualStatementKind::Coverage
statements, which must then be reassembled by coverage codegen.That's awkward for a number of reasons:
This PR therefore takes most of the per-function coverage info and stores it in a field in
mir::Body
asOption<Box<FunctionCoverageInfo>>
.(This adds one pointer to the size of
mir::Body
, even when coverage is not enabled.)Coverage statements still need to be injected into MIR in some cases, but only when they actually affect codegen (counters) or are needed to detect code that has been optimized away as unreachable (counters/expressions).
By the end of this PR, the information stored in
FunctionCoverageInfo
is:This is built on top of #115301, so I'll rebase and roll a reviewer once that lands.r? @ghost
@rustbot label +A-code-coverage