@@ -310,7 +310,7 @@ private func collectMovableInstructions(
310
310
311
311
movableInstructions. loadsAndStores. append ( loadInst)
312
312
case is UncheckedOwnershipConversionInst :
313
- break
313
+ break // TODO: Add support
314
314
case let storeInst as StoreInst :
315
315
switch storeInst. storeOwnership {
316
316
case . assign:
@@ -647,10 +647,24 @@ private extension MovableInstructions {
647
647
return false
648
648
}
649
649
650
- let dominatingBlocks = loop. getBlocksThatDominateAllExitingAndLatchBlocks ( context)
651
650
var changed = false
652
651
653
- for scopedInst in scopedInsts where dominatingBlocks. contains ( scopedInst. parentBlock) {
652
+ for scopedInst in scopedInsts {
653
+ if let storeBorrowInst = scopedInst as? StoreBorrowInst {
654
+ _ = storeBorrowInst. allocStack. hoist ( outOf: loop, context)
655
+
656
+ var sankFirst = false
657
+ for deallocStack in storeBorrowInst. allocStack. deallocations {
658
+ if sankFirst {
659
+ context. erase ( instruction: deallocStack)
660
+ } else {
661
+ sankFirst = deallocStack. sink ( outOf: loop, context)
662
+ }
663
+ }
664
+
665
+ context. notifyInvalidatedStackNesting ( )
666
+ }
667
+
654
668
guard scopedInst. hoist ( outOf: loop, context) else {
655
669
continue
656
670
}
@@ -821,8 +835,6 @@ private extension Instruction {
821
835
/// is not a terminator, allocation or deallocation and either a hoistable array semantics call or doesn't have memory effects.
822
836
func canBeHoisted( outOf loop: Loop , _ context: FunctionPassContext ) -> Bool {
823
837
switch self {
824
- case let allocStackInst as AllocStackInst :
825
- return allocStackInst. deallocations. allSatisfy ( { loop. contains ( block: $0. parentBlock) } )
826
838
case is TermInst , is Allocation , is Deallocation :
827
839
return false
828
840
case is ApplyInst :
@@ -862,19 +874,6 @@ private extension Instruction {
862
874
return true
863
875
} else {
864
876
move ( before: terminator, context)
865
-
866
- if let allocStack = self as? AllocStackInst {
867
- var sankFirst = false
868
- for deallocStack in allocStack. deallocations {
869
- if sankFirst {
870
- context. erase ( instruction: deallocStack)
871
- } else {
872
- sankFirst = deallocStack. sink ( outOf: loop, context)
873
- }
874
- }
875
-
876
- context. notifyInvalidatedStackNesting ( )
877
- }
878
877
}
879
878
}
880
879
0 commit comments