-
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: Clarify loop-edge detection and graph traversal #116654
Conversation
This is the only BCB that `TraverseCoverageGraphWithLoops::next` works with, so calling it `next_bcb` just makes the code less clear.
The previous code was storing the worklist in a vector, and then selectively adding items to the start or end of the vector. That's a perfect use-case for a double-ended queue. This change also reveals that the existing code was a bit confused about which end of the worklist is the front or back. For now, items are always removed from the front of the queue (instead of the back), and code that adds items to the queue has been flipped, to preserve the existing behaviour.
Having to keep passing in a graph reference was a holdover from when the graph was partly mutated during traversal. As of rust-lang#114354 that is no longer necessary, so we can simplify the traversal code by storing a graph reference as a field in `TraverseCoverageGraphWithLoops`.
As long as we store the loop header BCB, we can look up its incoming loop backedges as needed.
r? @oli-obk (rustbot has picked a reviewer for you, use r? to override) |
While replacing the traversal worklists with a Trying to “fix” that ended up breaking a number of unit tests, and also churned several coverage-map tests. For now I've left the existing behaviour intact, because it's unclear whether the change would be better or worse, and figuring that out is beyond the scope of these cleanups. (I did change things so that items are now popped from the front of the worklist. To preserve existing behaviour, I swapped around around the code that adds new items to the front/back.) |
6fefad3
to
d99ab97
Compare
Some changes occurred to MIR optimizations cc @rust-lang/wg-mir-opt |
@bors r+ |
…iaskrgr Rollup of 5 pull requests Successful merges: - rust-lang#116593 (Add unstable book page for the no-jump-tables codegen option) - rust-lang#116625 (`rustc_hir_pretty` cleanups) - rust-lang#116642 (Handle several `#[diagnostic::on_unimplemented]` attributes correctly) - rust-lang#116654 (coverage: Clarify loop-edge detection and graph traversal) - rust-lang#116669 (Fix mips platform support entries.) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#116654 - Zalathar:reloop-traversal, r=oli-obk coverage: Clarify loop-edge detection and graph traversal This is a collection of improvements to two semi-related pieces of code: - The code in `counters` that detects which graph edges don't exit a loop, and would therefore be good candidates to have their coverage computed as an expression rather than having a physical counter. - The code in `graph` that traverses the coverage BCB graph in a particular order, and tracks loops and loop edges along the way (which is relevant to the above). I was originally only planning to make the `graph` changes, but there was going to be a lot of indentation churn in `counters` anyway, and once I started looking I noticed a lot of opportunities for simplification. --- `@rustbot` label +A-code-coverage
50: Automated pull from upstream `master` r=Dajamante a=github-actions[bot] This PR pulls the following changes from the upstream repository: * rust-lang/rust#116619 * rust-lang/rust#115964 * rust-lang/rust#116391 * rust-lang/rust#116510 * rust-lang/rust#116671 * rust-lang/rust#116669 * rust-lang/rust#116654 * rust-lang/rust#116642 * rust-lang/rust#116625 * rust-lang/rust#116593 * rust-lang/rust#116649 * rust-lang/rust#116600 * rust-lang/rust#116628 Co-authored-by: Nadrieril <nadrieril+git@gmail.com> Co-authored-by: Scott McMurray <scottmcm@users.noreply.github.com> Co-authored-by: bjorn3 <17426603+bjorn3@users.noreply.github.com> Co-authored-by: Nicholas Nethercote <n.nethercote@gmail.com> Co-authored-by: Trevor Gross <tmgross@umich.edu> Co-authored-by: Georg Semmler <github@weiznich.de> Co-authored-by: Guillaume Gomez <guillaume.gomez@huawei.com> Co-authored-by: Gurinder Singh <frederick.the.fool@gmail.com> Co-authored-by: bors <bors@rust-lang.org>
This is a collection of improvements to two semi-related pieces of code:
counters
that detects which graph edges don't exit a loop, and would therefore be good candidates to have their coverage computed as an expression rather than having a physical counter.graph
that traverses the coverage BCB graph in a particular order, and tracks loops and loop edges along the way (which is relevant to the above).I was originally only planning to make the
graph
changes, but there was going to be a lot of indentation churn incounters
anyway, and once I started looking I noticed a lot of opportunities for simplification.@rustbot label +A-code-coverage