-
Notifications
You must be signed in to change notification settings - Fork 352
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
Introduce backward analysis to dataflow framework. #3370
Introduce backward analysis to dataflow framework. #3370
Conversation
Co-authored-by: Charles Chen <Charleszhuochen@gmail.com>
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.
Thanks for building this - I think it will be really useful going forward for implementing new kinds of analyses! I have two primary concerns (one of which is more about #3371, which I've also read):
- Why doesn't the backwards analysis have support for a widening operator? I don't think one is needed to correctly implement live-variable analysis, but many other interesting dataflow problems that one might want to express as backwards analyses will need one.
- The live-variable analysis that Add live variable analysis to dataflow framework. #3371 implements is never tested, so I don't know how you've established that it is actually working. Can you add some tests that show that the live-variable analysis gets the correct results? That will also help us establish confidence that the implementation of backwards analysis here is correct.
I also left some minor comments on documentation and style.
dataflow/src/main/java/org/checkerframework/dataflow/analysis/Analysis.java
Outdated
Show resolved
Hide resolved
dataflow/src/main/java/org/checkerframework/dataflow/analysis/Analysis.java
Outdated
Show resolved
Hide resolved
dataflow/src/main/java/org/checkerframework/dataflow/analysis/Analysis.java
Outdated
Show resolved
Hide resolved
dataflow/src/main/java/org/checkerframework/dataflow/analysis/Analysis.java
Outdated
Show resolved
Hide resolved
dataflow/src/main/java/org/checkerframework/dataflow/analysis/AnalysisResult.java
Outdated
Show resolved
Hide resolved
dataflow/src/main/java/org/checkerframework/dataflow/analysis/ForwardAnalysisImpl.java
Show resolved
Hide resolved
Reduce the differences between forward and backward analysis implementation.
@kelloggm Thanks for the review and helpful comments!
I agree with you: backward analysis can support widening. In the previous code review of this pull request in opprop, @wmdietl and I decided to support widening for backward analysis in the future: opprop#99 (comment)
Currently, I use I discussed with @wmdietl today, I will also try to create some test cases to test with live variable analysis and backward analysis. |
Thanks for the context on this. I suspect we will eventually need it, but keeping the first pull request simple is a good idea. Can you document somewhere in the code (probably in the Javadoc for
Adding automated versions of those tests will really improve these PRs. |
Hi @kelloggm, I have added a test case for live variable analysis in #3371, could you please have a look? Thanks! |
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.
Thanks for these changes and the test case in #3371. I had one minor comment on documentation, but there is no need for me to review this again once that is addressed unless my understanding is wrong.
dataflow/src/main/java/org/checkerframework/dataflow/analysis/AbstractAnalysis.java
Outdated
Show resolved
Hide resolved
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.
I have one minor comment. I also tried to push some minor tweaks, but I did not have permission. Please merge xingweitian#13.
dataflow/src/main/java/org/checkerframework/dataflow/analysis/BackwardAnalysisImpl.java
Outdated
Show resolved
Hide resolved
Use block instead of bb as parameter name.
…o typetools-backward-analysis
This PR added live variable analysis to the dataflow framework aiming to show #3370's backward analysis works properly. Co-authored-by: Charles Chen Charleszhuochen@gmail.com
BackwardAnalysis: 1. Add exception block's predecessor exception block to inputs (fix null pointer exception). 2. When running `runAnalysisFor()` with an exception block, pass a copied transfer input to `callTransferFunction()`. ForwardAnalysis: 1. When running `runAnalysisFor()` with an exception block, pass a copied transfer input to `callTransferFunction()`. In the previous dataflow framework (before #3370), we passed a non-copied transfer input (https://github.com/typetools/checker-framework/pull/3370/files#diff-d4108228a0a5407e00c090c2e97d8b6dL401-L402). This seems a bug existing in the old dataflow framework. Resolves #3447.
Refactor dataflow framework. Change
Analysis
to be an interface, and addAbstractAnalysis
,ForwardAnalysis
,ForwardTransferFunction
,ForwardAnalysisImpl
,BackwardAnalysis
,BackwardTransferFunction
, andBackwardAnalysisImpl
.Live variable analysis is also added in #3371 to show that the introduced backward analysis can work.
Co-authored-by: Charles Chen Charleszhuochen@gmail.com