@@ -581,18 +581,21 @@ entry(%instance_c: @owned $C, %instance_d: @owned $D):
581581 return %instance_c : $C
582582}
583583
584- // Don't hoist over store to an address which itself is (earlier) stored into a
585- // field of the object being borrowed.
586- // TODO: Eventually, we should be able to hoist over such a store.
587- // CHECK-LABEL: sil [ossa] @hoist_over_load : $@convention(thin) () -> () {
588- // CHECK: [[D:%[^,]+]] = alloc_ref $PointerWrapper
589- // CHECK: [[LIFETIME:%[^,]+]] = begin_borrow [[D]] : $PointerWrapper
590- // CHECK: [[ADDR:%[^,]+]] = alloc_stack $PointedTo
591- // CHECK: [[C:%[^,]+]] = alloc_ref $PointedTo
592- // CHECK: store [[C]] to [init] [[ADDR]] : $*PointedTo
593- // CHECK-NEXT: end_borrow [[LIFETIME]] : $PointerWrapper
594- // CHECK-LABEL: } // end sil function 'hoist_over_load'
595- sil [ossa] @hoist_over_load : $@convention(thin) () -> () {
584+ // Hoist over store to unrelated stack address. Do not hoist over store to
585+ // field of lifetime.
586+ //
587+ // CHECK-LABEL: sil [ossa] @hoist_over_store : $@convention(thin) () -> () {
588+ // CHECK: [[D:%[^,]+]] = alloc_ref $PointerWrapper
589+ // CHECK: [[LIFETIME:%[^,]+]] = begin_borrow [[D]] : $PointerWrapper
590+ // CHECK: [[ADDR:%[^,]+]] = alloc_stack $PointedTo
591+ // CHECK: [[PTR:%[^,]+]] = address_to_pointer [[ADDR]]
592+ // CHECK: [[FIELD:%[^,]+]] = ref_element_addr [[LIFETIME]]
593+ // CHECK: store [[PTR]] to [trivial] [[FIELD]]
594+ // CHECK: end_borrow [[LIFETIME]] : $PointerWrapper
595+ // CHECK: [[C:%[^,]+]] = alloc_ref $PointedTo
596+ // CHECK: store [[C]] to [init] [[ADDR]] : $*PointedTo
597+ // CHECK-LABEL: } // end sil function 'hoist_over_store'
598+ sil [ossa] @hoist_over_store : $@convention(thin) () -> () {
596599bb0:
597600 %d = alloc_ref $PointerWrapper
598601 %lifetime = begin_borrow %d : $PointerWrapper
0 commit comments