C++: Support reasoning about whether a phi node overwrites the entire buffer#21836
Draft
MathiasVP wants to merge 7 commits into
Draft
C++: Support reasoning about whether a phi node overwrites the entire buffer#21836MathiasVP wants to merge 7 commits into
MathiasVP wants to merge 7 commits into
Conversation
…ntire buffer is overwritten).
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.
There isn't a super great motivation for this work other than the fact that had most of it lying around in a local branch.
These changes are most likely necessary if we ever want to switch the instantiation of the shared range analysis library over from the sound IR-based SSA to dataflow-based SSA.
In order to model flow through something like:
(without knowing the concrete values for
i,j, andk) we model the write top[i]andp[j]as "uncertain" writes. That is, the write to the underlying SSA variable isn't overwritten. So whatever value was previously tracked by SSA is not killed by the SSA definition.For this PR it's not super important how we conclude which definitions overwrite the entire buffer.
On
mainwe currently consider any definition from aPhiNodeto be an uncertain definition. This PR changes this so that we consider aPhiNodeto be a certain definition whenever its inputs are all certain definitions.There are some technical things that make this slightly more complicated than what you would expect: Since a
PhNodecan be its own input we need recursion over a graph with cycles, and because of QL's least fixed-point semantics we don't get the right result when doing recursion over a graph with cycles. So we instead recurse over a graph whose nodes are the the recursivePhiNodes.As always, recursion through
forallis also dangerous and should ideally be rewritten using explicit recursion over integers to reduce the risk of performance problems. However, I'll delay that until we actually see a performance problem on a database.(I expect this work to be necessary for switching the instantiation of the shared range analysis library over to dataflow-based SSA because I expect the relevant SSA variables for range analysis to be those for which any SSA definition is a certain SSA definition.)