@@ -193,13 +193,21 @@ class FindAccessVisitorImpl : public AccessUseDefChainVisitor<Impl, SILValue> {
193
193
194
194
// Override AccessUseDefChainVisitor to ignore access markers and find the
195
195
// outer access base.
196
- SILValue visitNestedAccess (BeginAccessInst *access) {
196
+ SILValue visitNestedAccessImpl (BeginAccessInst *access) {
197
197
if (nestedAccessTy == NestedAccessType::IgnoreAccessBegin)
198
198
return access ->getSource ();
199
199
200
200
return SuperTy::visitNestedAccess (access );
201
201
}
202
202
203
+ SILValue visitNestedAccess (BeginAccessInst *access) {
204
+ auto value = visitNestedAccessImpl (access );
205
+ if (value) {
206
+ reenterUseDef (value);
207
+ }
208
+ return SILValue ();
209
+ }
210
+
203
211
SILValue visitPhi (SILPhiArgument *phiArg) {
204
212
// Cycles involving phis are only handled within AccessPhiVisitor.
205
213
// Path components are not allowed in phi cycles.
@@ -362,6 +370,18 @@ SILValue swift::getTypedAccessAddress(SILValue address) {
362
370
return accessAddress;
363
371
}
364
372
373
+ namespace swift ::test {
374
+ static FunctionTest
375
+ GetTypedAccessAddress (" get_typed_access_address" ,
376
+ [](auto &function, auto &arguments, auto &test) {
377
+ auto address = arguments.takeValue ();
378
+ function.dump ();
379
+ llvm::dbgs () << " Address: " << address;
380
+ auto access = getTypedAccessAddress (address);
381
+ llvm::dbgs () << " Access: " << access ;
382
+ });
383
+ } // end namespace swift::test
384
+
365
385
// TODO: When the optimizer stops stripping begin_access markers and SILGen
366
386
// protects all memory operations with at least an "unsafe" access scope, then
367
387
// we should be able to assert that this returns a BeginAccessInst.
@@ -379,6 +399,18 @@ SILValue swift::getAccessBase(SILValue address) {
379
399
.findPossibleBaseAddress (address);
380
400
}
381
401
402
+ namespace swift ::test {
403
+ static FunctionTest GetAccessBaseTest (" get_access_base" ,
404
+ [](auto &function, auto &arguments,
405
+ auto &test) {
406
+ auto address = arguments.takeValue ();
407
+ function.dump ();
408
+ llvm::dbgs () << " Address: " << address;
409
+ auto base = getAccessBase (address);
410
+ llvm::dbgs () << " Base: " << base;
411
+ });
412
+ } // end namespace swift::test
413
+
382
414
static bool isLetForBase (SILValue base) {
383
415
// Is this an address of a "let" class member?
384
416
if (auto *rea = dyn_cast<RefElementAddrInst>(base))
@@ -1156,6 +1188,18 @@ AccessStorage AccessStorage::compute(SILValue sourceAddress) {
1156
1188
return AccessStorageWithBase::compute (sourceAddress).storage ;
1157
1189
}
1158
1190
1191
+ namespace swift ::test {
1192
+ static FunctionTest ComputeAccessStorage (" compute_access_storage" ,
1193
+ [](auto &function, auto &arguments,
1194
+ auto &test) {
1195
+ auto address = arguments.takeValue ();
1196
+ function.dump ();
1197
+ llvm::dbgs () << " Address: " << address;
1198
+ auto accessStorage = AccessStorage::compute (address);
1199
+ accessStorage.dump ();
1200
+ });
1201
+ } // end namespace swift::test
1202
+
1159
1203
AccessStorage AccessStorage::computeInScope (SILValue sourceAddress) {
1160
1204
return AccessStorageWithBase::computeInScope (sourceAddress).storage ;
1161
1205
}
0 commit comments