Skip to content

Commit 0e2dc7a

Browse files
committed
[arc] Once we have finished an iteration of ARC, clear the ImmutablePointerSetFactory.
Previously due to the way that ARC works, it was impossible to trigger any memory safety issues. That being said the fact that the memory safety here is non-obvious suggests that the right thing to do is just bite the bullet and clear the ImmutablePointerSetFactory.
1 parent ae1dd18 commit 0e2dc7a

File tree

3 files changed

+8
-0
lines changed

3 files changed

+8
-0
lines changed

include/swift/Basic/ImmutablePointerSet.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,8 @@ template <typename T> class ImmutablePointerSetFactory {
199199
// statically.
200200
static PtrSet *getEmptySet() { return &EmptyPtrSet; }
201201

202+
void clear() { Set.clear(); }
203+
202204
/// Given a sorted and uniqued list \p Array, return the ImmutablePointerSet
203205
/// containing Array. Asserts if \p Array is not sorted and uniqued.
204206
PtrSet *get(ArrayRef<PtrTy> Array) {

lib/SILOptimizer/ARC/ARCSequenceOpts.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,7 @@ bool LoopARCPairingContext::processRegion(const LoopRegion *Region,
241241
Evaluator.clearLoopState(Region);
242242
Context.DecToIncStateMap.clear();
243243
Context.IncToDecStateMap.clear();
244+
Evaluator.clearSetFactory();
244245

245246
// This ensures we only ever recompute post dominating releases on the first
246247
// iteration.

lib/SILOptimizer/ARC/GlobalLoopARCSequenceDataflow.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,11 @@ class LoopARCSequenceDataflowEvaluator {
110110
/// Remove \p I from the interesting instruction list of its parent block.
111111
void removeInterestingInst(SILInstruction *I);
112112

113+
/// Clear the folding node set of the set factory we have stored internally.
114+
void clearSetFactory() {
115+
SetFactory.clear();
116+
}
117+
113118
private:
114119
/// Merge in the BottomUp state of any successors of DataHandle.getBB() into
115120
/// DataHandle.getState().

0 commit comments

Comments
 (0)