Use forward traversal for unconditional recursion lint#70973
Merged
bors merged 1 commit intorust-lang:masterfrom Apr 10, 2020
Merged
Use forward traversal for unconditional recursion lint#70973bors merged 1 commit intorust-lang:masterfrom
bors merged 1 commit intorust-lang:masterfrom
Conversation
Contributor
|
Neat, that does look simpler! @bors r+ |
Collaborator
|
📌 Commit 0fc0f34 has been approved by |
bors
added a commit
to rust-lang-ci/rust
that referenced
this pull request
Apr 10, 2020
Rollup of 9 pull requests Successful merges: - rust-lang#69745 (Use `PredicateObligation`s instead of `Predicate`s) - rust-lang#70938 (Add ThreadSanitizer test case) - rust-lang#70973 (Use forward traversal for unconditional recursion lint) - rust-lang#70978 (compiletest: let config flags overwrite -A unused) - rust-lang#70979 (Follow up on BTreeMap comments) - rust-lang#70981 (Rearrange BTreeMap::into_iter to match range_mut.) - rust-lang#70985 (Clean up E0512 explanation) - rust-lang#70988 (Setup the `@rustbot prioritize` command) - rust-lang#70991 (fix rustc-dev-guide's url in src/librustc_codegen_ssa) Failed merges: r? @ghost
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
While reviewing #70822, I noted that #54444 could be solved without requiring the predecessor graph and without allocating a
Vec<Span>for every basic block. The unconditional recursion lint is not a performance bottleneck however, so I approved #70822 as it was.Nevertheless, I wanted to try implementing my idea using
TriColorDepthFirstSearch, which is a DFS that can differentiate between forward/tree edges and backward ones. I found this approach more straightforward than the existing one, so I'm opening this PR to see if it is desirable.The pass is now just a DFS across the control-flow graph. We ignore false edges and false unwinds, as well as the successors of recursive calls, just like existing pass does. If we see a back-edge (loop) or a terminator that would cause us to yield control-flow back to the caller (
Return,Resume, etc.), we know that the function does not unconditionally recurse.r? @jonas-schievink