@@ -160,6 +160,11 @@ class AccessedStorage {
160
160
64 - NumAccessedStorageBits,
161
161
seenNestedConflict : 1 ,
162
162
beginAccessIndex : 63 - NumAccessedStorageBits);
163
+
164
+ // Define data flow bits for use in the AccessEnforcementDom pass. Each
165
+ // begin_access in the function is mapped to one instance of this subclass.
166
+ SWIFT_INLINE_BITFIELD (DomAccessedStorage, AccessedStorage, 1 + 1 ,
167
+ isInner : 1 , containsRead : 1 );
163
168
} Bits;
164
169
165
170
private:
@@ -190,6 +195,10 @@ class AccessedStorage {
190
195
191
196
Kind getKind () const { return static_cast <Kind>(Bits.AccessedStorage .Kind ); }
192
197
198
+ // Clear any bits reserved for subclass data. Useful for up-casting back to
199
+ // the base class.
200
+ void resetSubclassData () { initKind (getKind ()); }
201
+
193
202
SILValue getValue () const {
194
203
assert (getKind () != Argument && getKind () != Global && getKind () != Class);
195
204
return value;
@@ -215,6 +224,10 @@ class AccessedStorage {
215
224
return objProj;
216
225
}
217
226
227
+ // / Return true if the given storage objects have identical storage locations.
228
+ // /
229
+ // / This compares only the AccessedStorage base class bits, ignoring the
230
+ // / subclass bits. It is used for hash lookup equality.
218
231
bool hasIdenticalBase (const AccessedStorage &other) const {
219
232
if (getKind () != other.getKind ())
220
233
return false ;
@@ -233,7 +246,6 @@ class AccessedStorage {
233
246
case Class:
234
247
return objProj == other.objProj ;
235
248
}
236
- llvm_unreachable (" unhandled kind" );
237
249
}
238
250
239
251
// / Return true if the storage is guaranteed local.
@@ -311,31 +323,6 @@ class AccessedStorage {
311
323
bool operator !=(const AccessedStorage &) const = delete ;
312
324
};
313
325
314
- // / Return true if the given storage objects have identical storage locations.
315
- // /
316
- // / This compares only the AccessedStorage base class bits, ignoring the
317
- // / subclass bits.
318
- inline bool accessingIdenticalLocations (AccessedStorage LHS,
319
- AccessedStorage RHS) {
320
- if (LHS.getKind () != RHS.getKind ())
321
- return false ;
322
-
323
- switch (LHS.getKind ()) {
324
- case swift::AccessedStorage::Box:
325
- case swift::AccessedStorage::Stack:
326
- case swift::AccessedStorage::Nested:
327
- case swift::AccessedStorage::Yield:
328
- case swift::AccessedStorage::Unidentified:
329
- return LHS.getValue () == RHS.getValue ();
330
- case swift::AccessedStorage::Argument:
331
- return LHS.getParamIndex () == RHS.getParamIndex ();
332
- case swift::AccessedStorage::Global:
333
- return LHS.getGlobal () == RHS.getGlobal ();
334
- case swift::AccessedStorage::Class:
335
- return LHS.getObjectProjection () == RHS.getObjectProjection ();
336
- }
337
- }
338
-
339
326
template <class ImplTy , class ResultTy = void , typename ... ArgTys>
340
327
class AccessedStorageVisitor {
341
328
ImplTy &asImpl () { return static_cast <ImplTy &>(*this ); }
@@ -396,7 +383,7 @@ template <> struct DenseMapInfo<swift::AccessedStorage> {
396
383
}
397
384
398
385
static bool isEqual (swift::AccessedStorage LHS, swift::AccessedStorage RHS) {
399
- return swift::accessingIdenticalLocations ( LHS, RHS);
386
+ return LHS. hasIdenticalBase ( RHS);
400
387
}
401
388
};
402
389
0 commit comments