Skip to content

Commit dfc2d47

Browse files
committed
Redo the data flow part of AccessEnforcementOpts.
Directly implement the data flow. Eliminate the extraneous work. Remove cubic behavior. Do a single iteration of the data flow state at each program point only performing the necessary set operations. At unidentified access, clear the sets for simplicity and efficiency. This cleanup results in significant functional changes: - Allowing scopes to merge even if they are enclosed. - Handling unidentified access conservatively. Note that most of the added lines of code are comments. Somehow this cleanup incidentally fixes: <rdar://problem/48514339> swift compiler hangs building project (I expected the subsequent loop summary cleanup to fix that problem.)
1 parent c516a1c commit dfc2d47

File tree

3 files changed

+224
-265
lines changed

3 files changed

+224
-265
lines changed

include/swift/SILOptimizer/Analysis/AccessedStorageAnalysis.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,8 @@ template <> struct DenseMapInfo<swift::StorageAccessInfo> {
122122
}
123123

124124
namespace swift {
125+
using AccessedStorageSet = llvm::SmallDenseSet<StorageAccessInfo, 8>;
126+
125127
/// Records each unique AccessedStorage in a set of StorageAccessInfo
126128
/// objects. Hashing and equality only sees the AccesedStorage data. The
127129
/// additional StorageAccessInfo bits are recorded as results of this analysis.
@@ -132,17 +134,17 @@ namespace swift {
132134
/// large. It does not imply that all accesses have Unidentified
133135
/// AccessedStorage, which is never allowed for class or global access.
134136
class AccessedStorageResult {
135-
136-
using AccessedStorageSet = llvm::SmallDenseSet<StorageAccessInfo, 8>;
137-
138137
AccessedStorageSet storageAccessSet;
139138
Optional<SILAccessKind> unidentifiedAccess;
139+
140140
public:
141141
AccessedStorageResult() {}
142142

143143
// ---------------------------------------------------------------------------
144144
// Accessing the results.
145145

146+
const AccessedStorageSet &getStorageSet() const { return storageAccessSet; }
147+
146148
bool isEmpty() const {
147149
return storageAccessSet.empty() && !unidentifiedAccess;
148150
}

0 commit comments

Comments
 (0)