File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed
SwiftCompilerSources/Sources/Optimizer/Utilities Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -96,6 +96,11 @@ private extension Phi {
9696
9797extension BorrowedFromInst : VerifiableInstruction {
9898 func verify( _ context: FunctionPassContext ) {
99+
100+ for ev in enclosingValues {
101+ require ( ev. isValidEnclosingValueInBorrowedFrom, " invalid enclosing value in borrowed-from: \( ev) " )
102+ }
103+
99104 var computedEVs = Stack < Value > ( context)
100105 defer { computedEVs. deinitialize ( ) }
101106
@@ -114,6 +119,21 @@ extension BorrowedFromInst : VerifiableInstruction {
114119 }
115120}
116121
122+ private extension Value {
123+ var isValidEnclosingValueInBorrowedFrom : Bool {
124+ switch ownership {
125+ case . owned:
126+ return true
127+ case . guaranteed:
128+ return BeginBorrowValue ( self ) != nil ||
129+ self is BorrowedFromInst ||
130+ forwardingInstruction != nil
131+ case . none, . unowned:
132+ return false
133+ }
134+ }
135+ }
136+
117137extension LoadBorrowInst : VerifiableInstruction {
118138 func verify( _ context: FunctionPassContext ) {
119139 if isUnchecked {
You can’t perform that action at this time.
0 commit comments