@@ -1206,27 +1206,25 @@ private extension ScopedInstruction {
12061206 case is BeginApplyInst :
12071207 return true // Has already been checked with other full applies.
12081208 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
12141215 }
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
12221220 }
12231221 }
1224-
1225- fallthrough
1226- case is BeginAccessInst :
1222+ return true
1223+
1224+ case let beginAccess as BeginAccessInst :
12271225 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 {
12301228 continue
12311229 }
12321230
@@ -1236,7 +1234,7 @@ private extension ScopedInstruction {
12361234 }
12371235 }
12381236
1239- switch operands . first! . value . accessPath. base {
1237+ switch beginAccess . address . accessPath. base {
12401238 case . class, . global:
12411239 for sideEffect in analyzedInstructions. loopSideEffects where sideEffect. mayRelease {
12421240 // Since a class might have a deinitializer, hoisting begin/end_access pair could violate
0 commit comments