Reapply optimization of ConditionalTransferResult out of method invocation with fix #1398
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.
In #1099, the optimization (applied in #259) is reverted because it causes test failure in #1097. This PR reapply this optimization and fix the problem that causes the test failure.
Problem Description:
The test failure happens when the
TransferResultis regular when visiting a boolean expression. This is because the visit methods of equality and inequality checks assume that the transfer result they get is conditional. They do refinement on both stores and return the same result. However, the refinement on the else store is not recorded to the given regular transfer result, which raised the false positive.Solution:
This PR fix this problem by adding a check in visit methods of boolean expressions. If
resultis regular, then turn it into conditional with sameThenStoreandElseStore.Evaluation:
No test failure with this fix. Also looks into the same test case as in 2e14088. The store number also drops to 484. Additionally, compared the number of stores. It drops from 2227 on master branch to 1676 after this fix, which is around 25% reduction.
Possible Future Work
Currently, we only fix the problem for this specific Nonemtpy checker. However, there could be a way to prevent this from happening. The idea is described in #1401. Also, there is a abandoned PR #1378 that made a little attempt. Maybe worth coming back in the future if the need grows.