]> git.lizzy.rs Git - rust.git/commitdiff
Rollup merge of #70973 - ecstatic-morse:recursion-lint, r=jonas-schievink
authorMazdak Farrokhzad <twingoow@gmail.com>
Fri, 10 Apr 2020 16:15:19 +0000 (18:15 +0200)
committerGitHub <noreply@github.com>
Fri, 10 Apr 2020 16:15:19 +0000 (18:15 +0200)
Use forward traversal for unconditional recursion lint

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](https://en.wikipedia.org/wiki/Depth-first_search#Output_of_a_depth-first_search). 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


Trivial merge