Skip to content

Commit aee5a37

Browse files
committed
[region-isolation] Add isolation history support but do not wire it up to the checker.
This means that I added an IsolationHistory field to Partition. Just upstreaming the beginning part of this work. I added some unittests to exercise the code as well. NOTE: This means that I did need to begin tracking an IsolationHistoryFactory and propagating IsolationHistory in the pass itself... but we do not use it for anything. A quick overview of the design. IsolationHistory is the head of an immutable directed acyclic graph. It is actually represented as an immutable linked list with a special node that ties in extra children nodes. The users of the information are expected to get a SmallVectorImpl and process those sibling nodes afterwards. The reason why we use an immutable approach is that it fits well with the problem and saves space since different partitions could be pointing at the same linked list node. Operations occur on an isolation history by pushing/popping nodes. It is assumed that the user will push nodes in batches with a sequence boundary at the bottom of the addition which signals to stop processing nodes. Tieing this together, each Partition within it contains an IsolationHistory. As the PartitionOpEvaluator applies PartitionOps to Partition in PartitionOpEvaluator::apply, the evaluator also updates the isolation history in the partition by first pushing a SequenceBoundary node and then pushing nodes that will undo the operation that it is performing. This information is used by the method Partition::popHistory. This pops linked list nodes from its history, performing the operation in reverse until it hits a SequenceBoundary node. This allows for one to rewind Partition history. And if one stashes an isolation history as a target, one can even unwind a partition to what its state was at a specific transfer point or earlier. Once we are at that point, we can begin going one node back at a time and see when two values that we are searching for no longer are apart of the same region. That is a place where we want to emit a diagnostic. We then process until we find for both of our values history points where they were the immediate reason why the two regions merge. rdar://123479934
1 parent 70afeef commit aee5a37

File tree

5 files changed

+1043
-159
lines changed

5 files changed

+1043
-159
lines changed

include/swift/SILOptimizer/Analysis/RegionAnalysis.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,8 @@ class BlockPartitionState {
9090

9191
BlockPartitionState(SILBasicBlock *basicBlock,
9292
PartitionOpTranslator &translator,
93-
TransferringOperandSetFactory &ptrSetFactory);
93+
TransferringOperandSetFactory &ptrSetFactory,
94+
IsolationHistory::Factory &isolationHistoryFactory);
9495

9596
public:
9697
bool getLiveness() const { return isLive; }
@@ -394,6 +395,8 @@ class RegionAnalysisFunctionInfo {
394395

395396
TransferringOperandSetFactory ptrSetFactory;
396397

398+
IsolationHistory::Factory isolationHistoryFactory;
399+
397400
// We make this optional to prevent an issue that we have seen on windows when
398401
// capturing a field in a closure that is used to initialize a different
399402
// field.

0 commit comments

Comments
 (0)