@@ -1206,27 +1206,25 @@ private extension ScopedInstruction {
1206
1206
case is BeginApplyInst :
1207
1207
return true // Has already been checked with other full applies.
1208
1208
case let loadBorrowInst as LoadBorrowInst :
1209
- for case let destroyAddrInst as DestroyAddrInst in analyzedInstructions. loopSideEffects {
1210
- if context. aliasAnalysis. mayAlias ( loadBorrowInst. address, destroyAddrInst. destroyedAddress) {
1211
- if !scope. contains ( destroyAddrInst) {
1212
- return false
1213
- }
1209
+ for sideEffectInst in analyzedInstructions. loopSideEffects {
1210
+ if let endBorrow = sideEffectInst as? EndBorrowInst ,
1211
+ let begin = endBorrow. borrow as? LoadBorrowInst ,
1212
+ begin == self
1213
+ {
1214
+ continue
1214
1215
}
1215
- }
1216
-
1217
- for storeInst in analyzedInstructions. stores {
1218
- if storeInst. mayWrite ( toAddress: loadBorrowInst. address, context. aliasAnalysis) {
1219
- if !scope. contains ( storeInst) {
1220
- return false
1221
- }
1216
+ if sideEffectInst. mayWrite ( toAddress: loadBorrowInst. address, context. aliasAnalysis) ,
1217
+ !scope. contains ( sideEffectInst)
1218
+ {
1219
+ return false
1222
1220
}
1223
1221
}
1224
-
1225
- fallthrough
1226
- case is BeginAccessInst :
1222
+ return true
1223
+
1224
+ case let beginAccess as BeginAccessInst :
1227
1225
for fullApplyInst in analyzedInstructions. fullApplies {
1228
- guard mayWriteToMemory && fullApplyInst. mayReadOrWrite ( address: operands . first! . value , context. aliasAnalysis) ||
1229
- !mayWriteToMemory && fullApplyInst. mayWrite ( toAddress: operands . first! . value , context. aliasAnalysis) else {
1226
+ guard mayWriteToMemory && fullApplyInst. mayReadOrWrite ( address: beginAccess . address , context. aliasAnalysis) ||
1227
+ !mayWriteToMemory && fullApplyInst. mayWrite ( toAddress: beginAccess . address , context. aliasAnalysis) else {
1230
1228
continue
1231
1229
}
1232
1230
@@ -1236,7 +1234,7 @@ private extension ScopedInstruction {
1236
1234
}
1237
1235
}
1238
1236
1239
- switch operands . first! . value . accessPath. base {
1237
+ switch beginAccess . address . accessPath. base {
1240
1238
case . class, . global:
1241
1239
for sideEffect in analyzedInstructions. loopSideEffects where sideEffect. mayRelease {
1242
1240
// Since a class might have a deinitializer, hoisting begin/end_access pair could violate
0 commit comments