[region-isolation] Include the region -> transferring operand map in the dataflow convergence. #72955
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.
This PR contains a few different that add up to doing the title of the PR.
Specifically:
Changing the representation of the region -> transferring operand map from a SmallDenseMap to a SmallMapVector
The first commit changes our representation of the region -> transferring
operand map from a SmallDenseMap to a SmallMapVector. I am doing this since to
do the dataflow convergence, I need to check for equality implying I would need
to traverse the map and iterating over a hash table can lead to performance
issues.
Refactoring the region -> transferring operand map to use bare Operand * instead of TransferringOperand *.
In the second commit, I refactored the region -> transferring operand map such
that it just tracks bare operands and eliminated the transferring operand
abstraction in favor of just storing a global map from operand -> extra
transferring state.
Originally, we mapped a region number to an immutable pointer set containing
Operand * where the region was tranferred. This worked great for a time... until
I began to need to propagate other information from the transferring code in the
analysis to the actual diagnostic emitter.
To be able to do that, my thought was to make a wrapper type around Operand
called TransferringOperand that contained the operand and the other information
I needed. This seemed to provide me what I wanted but I later found that since
the immutable pointer set was tracking TransferringOperands which were always
newly wrapped with an Operand *, we actually always created new pointer
sets. This is of course wasteful from a memory perspective, but also prevents me
from tracking transferring operand sets during the dataflow since we would never
converge.
Include the region -> transferring operand map in the dataflow convergence.
The reason why I am doing this is that really we are running two different
dataflow equations at the same time... one for propagating tracking transferring
sets and the other for propagating regions. Since at the source level the two
dataflow problems are very interrelated, I was unable to come up with an example
where we fail to iterate because of this, but I would like to be sure that we do
not hit one, so I am fixing this here.
rdar://126170014