mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[MemAccessUtils] Add to strip access storage casts
The new function stripAccessAndAccessStorageCasts is analogous to the existing function stripAccessAndIdentityCasts but differs in that the latter uses isAccessStorageIdentityCast whereas the new function uses isAccessStorageCast.
This commit is contained in:
@@ -1688,6 +1688,22 @@ inline bool isAccessStorageCast(SingleValueInstruction *svi) {
|
||||
return isAccessStorageTypeCast(svi) || isAccessStorageIdentityCast(svi);
|
||||
}
|
||||
|
||||
// Strip access markers and casts that preserve the access storage.
|
||||
//
|
||||
// Compare to stripAccessAndIdentityCasts. This function strips cast that
|
||||
// change the type.
|
||||
inline SILValue stripAccessAndAccessStorageCasts(SILValue v) {
|
||||
if (auto *bai = dyn_cast<BeginAccessInst>(v)) {
|
||||
return stripAccessAndAccessStorageCasts(bai->getOperand());
|
||||
}
|
||||
if (auto *svi = dyn_cast<SingleValueInstruction>(v)) {
|
||||
if (isAccessStorageCast(svi)) {
|
||||
return stripAccessAndAccessStorageCasts(svi->getAllOperands()[0].get());
|
||||
}
|
||||
}
|
||||
return v;
|
||||
}
|
||||
|
||||
/// Abstract CRTP class for a visiting instructions that are part of the use-def
|
||||
/// chain from an accessed address up to the storage base.
|
||||
///
|
||||
|
||||
Reference in New Issue
Block a user