Skip to content

Commit a8bc9a6

Browse files
committed
Add BeginAccessInst.unsafeAddressorSelf.
1 parent effae4d commit a8bc9a6

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

SwiftCompilerSources/Sources/SIL/Utilities/AccessUtils.swift

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -518,6 +518,32 @@ public struct AccessBaseAndScopes {
518518
}
519519
}
520520

521+
extension BeginAccessInst {
522+
// Recognize an access scope for a unsafe addressor:
523+
// %adr = pointer_to_address
524+
// %md = mark_dependence %adr
525+
// begin_access [unsafe] %md
526+
public var unsafeAddressorSelf: Value? {
527+
guard self.isUnsafe else {
528+
return nil
529+
}
530+
switch self.address.enclosingAccessScope {
531+
case .access, .base:
532+
return nil
533+
case let .dependence(markDep):
534+
switch markDep.value.enclosingAccessScope {
535+
case .access, .dependence:
536+
return nil
537+
case let .base(accessBase):
538+
guard case .pointer = accessBase else {
539+
return nil
540+
}
541+
return markDep.base
542+
}
543+
}
544+
}
545+
}
546+
521547
private struct EnclosingAccessWalker : AddressUseDefWalker {
522548
var enclosingScope: EnclosingAccessScope?
523549

0 commit comments

Comments
 (0)