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 {
96
96
97
97
extension BorrowedFromInst : VerifiableInstruction {
98
98
func verify( _ context: FunctionPassContext ) {
99
+
100
+ for ev in enclosingValues {
101
+ require ( ev. isValidEnclosingValueInBorrowedFrom, " invalid enclosing value in borrowed-from: \( ev) " )
102
+ }
103
+
99
104
var computedEVs = Stack < Value > ( context)
100
105
defer { computedEVs. deinitialize ( ) }
101
106
@@ -114,6 +119,21 @@ extension BorrowedFromInst : VerifiableInstruction {
114
119
}
115
120
}
116
121
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
+
117
137
extension LoadBorrowInst : VerifiableInstruction {
118
138
func verify( _ context: FunctionPassContext ) {
119
139
if isUnchecked {
You can’t perform that action at this time.
0 commit comments