mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Merge pull request #68389 from nate-chandler/rdar115033825
[AccessBase] FindAccessBaseVisitor visits nested accesses.
This commit is contained in:
@@ -193,13 +193,21 @@ public:
|
||||
|
||||
// Override AccessUseDefChainVisitor to ignore access markers and find the
|
||||
// outer access base.
|
||||
SILValue visitNestedAccess(BeginAccessInst *access) {
|
||||
SILValue visitNestedAccessImpl(BeginAccessInst *access) {
|
||||
if (nestedAccessTy == NestedAccessType::IgnoreAccessBegin)
|
||||
return access->getSource();
|
||||
|
||||
return SuperTy::visitNestedAccess(access);
|
||||
}
|
||||
|
||||
SILValue visitNestedAccess(BeginAccessInst *access) {
|
||||
auto value = visitNestedAccessImpl(access);
|
||||
if (value) {
|
||||
reenterUseDef(value);
|
||||
}
|
||||
return SILValue();
|
||||
}
|
||||
|
||||
SILValue visitPhi(SILPhiArgument *phiArg) {
|
||||
// Cycles involving phis are only handled within AccessPhiVisitor.
|
||||
// Path components are not allowed in phi cycles.
|
||||
@@ -362,6 +370,18 @@ SILValue swift::getTypedAccessAddress(SILValue address) {
|
||||
return accessAddress;
|
||||
}
|
||||
|
||||
namespace swift::test {
|
||||
static FunctionTest
|
||||
GetTypedAccessAddress("get_typed_access_address",
|
||||
[](auto &function, auto &arguments, auto &test) {
|
||||
auto address = arguments.takeValue();
|
||||
function.dump();
|
||||
llvm::dbgs() << "Address: " << address;
|
||||
auto access = getTypedAccessAddress(address);
|
||||
llvm::dbgs() << "Access: " << access;
|
||||
});
|
||||
} // end namespace swift::test
|
||||
|
||||
// TODO: When the optimizer stops stripping begin_access markers and SILGen
|
||||
// protects all memory operations with at least an "unsafe" access scope, then
|
||||
// we should be able to assert that this returns a BeginAccessInst.
|
||||
@@ -379,6 +399,18 @@ SILValue swift::getAccessBase(SILValue address) {
|
||||
.findPossibleBaseAddress(address);
|
||||
}
|
||||
|
||||
namespace swift::test {
|
||||
static FunctionTest GetAccessBaseTest("get_access_base",
|
||||
[](auto &function, auto &arguments,
|
||||
auto &test) {
|
||||
auto address = arguments.takeValue();
|
||||
function.dump();
|
||||
llvm::dbgs() << "Address: " << address;
|
||||
auto base = getAccessBase(address);
|
||||
llvm::dbgs() << "Base: " << base;
|
||||
});
|
||||
} // end namespace swift::test
|
||||
|
||||
static bool isLetForBase(SILValue base) {
|
||||
// Is this an address of a "let" class member?
|
||||
if (auto *rea = dyn_cast<RefElementAddrInst>(base))
|
||||
@@ -1156,6 +1188,18 @@ AccessStorage AccessStorage::compute(SILValue sourceAddress) {
|
||||
return AccessStorageWithBase::compute(sourceAddress).storage;
|
||||
}
|
||||
|
||||
namespace swift::test {
|
||||
static FunctionTest ComputeAccessStorage("compute_access_storage",
|
||||
[](auto &function, auto &arguments,
|
||||
auto &test) {
|
||||
auto address = arguments.takeValue();
|
||||
function.dump();
|
||||
llvm::dbgs() << "Address: " << address;
|
||||
auto accessStorage = AccessStorage::compute(address);
|
||||
accessStorage.dump();
|
||||
});
|
||||
} // end namespace swift::test
|
||||
|
||||
AccessStorage AccessStorage::computeInScope(SILValue sourceAddress) {
|
||||
return AccessStorageWithBase::computeInScope(sourceAddress).storage;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user