-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
Simplify the return path analysis #6541
Conversation
CodSpeed Performance ReportMerging #6541 will not alter performanceComparing Summary
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we test this to validate some previously unhandled state at least?
I haven't been able to find an example where the old algorithm gave an incorrect result. I can keep looking if you want? When I removed the That's the one I used to debug my algorithm. |
…ath_analysis_exit_fix
…Labs/sway into jjcnn/return_path_analysis_exit_fix
@IGI-111 : I managed to fix the linearization problem, and the traversal algorithm is much cleaner now. Take a look at your convenience. |
…Labs/sway into jjcnn/return_path_analysis_exit_fix
Description
The return path analysis ensures that if a method must return a value then the spine of the method returns a value. The analysis traverses a linearized version of the CFG (one which ignores branching expressions such as
if-then-else
and loops, and simply treats them as a single node) of each method from the (unique) entry point to the (unique) exit point. If there is ever a node in the graph that does not have outgoing edges, then an error is thrown.When constructing such a linearized CFG we have so far treated local
impl
s as branches, meaning that the spine was in fact not linear:This has been the case even though the edge into a local
impl
does not in fact represent legal control flow.This incorrect construction has made the traversal of the spine-CFG very convoluted and difficult to follow.
This PR fixes the incorrect construction, and simplifies the traversal of the spine so that it is clear what is going on. I have also added an additional test to show that methods inside local
impl
s are in fact analyzed separately, even though there is no longer an edge going into theimpl
from the surrounding function.Checklist
Breaking*
orNew Feature
labels where relevant.