@@ -1648,8 +1648,8 @@ entry:
1648
1648
// CHECK: {{bb[0-9]+}}({{%[^,]+}} : $*Klass, [[OPAQUE_OUT:%[^,]+]] : $*T):
1649
1649
// CHECK: ([[ADDR_1:%[^,]+]], [[ADDR_2:%[^,]+]], {{%[^,]+}}) = begin_apply
1650
1650
// CHECK: [[INSTANCE_1:%[^,]+]] = load [take] [[ADDR_1]]
1651
- // CHECK: begin_borrow [[INSTANCE_1]]
1652
1651
// CHECK: copy_addr [take] [[ADDR_2]] to [init] [[OPAQUE_OUT]]
1652
+ // CHECK: begin_borrow [[INSTANCE_1]]
1653
1653
// CHECK-LABEL: } // end sil function 'testBeginApplyCYield1LoadableNontrivialOwned1OpaqueOwned'
1654
1654
sil [ossa] @testBeginApplyCYield1LoadableNontrivialOwned1OpaqueOwned : $@convention(thin) <T> () -> (@out Klass, @out T) {
1655
1655
entry:
@@ -1710,6 +1710,123 @@ entry:
1710
1710
return %retval : $T
1711
1711
}
1712
1712
1713
+ // Verify that a copy_value of a @in_guaranteed yield generates storage.
1714
+ // CHECK-LABEL: sil [ossa] @testBeginApplyGCopyConsumeInGuaranteedValue : {{.*}} {
1715
+ // CHECK: bb0:
1716
+ // CHECK: [[COPY_STORAGE:%[^,]+]] = alloc_stack $T
1717
+ // CHECK: ([[YIELD_STORAGE:%[^,]+]], [[TOKEN:%[^,]+]]) = begin_apply
1718
+ // CHECK: copy_addr [[YIELD_STORAGE]] to [init] [[COPY_STORAGE]]
1719
+ // CHECK: end_apply [[TOKEN]]
1720
+ // CHECK: apply undef<T>([[COPY_STORAGE]])
1721
+ // CHECK: dealloc_stack [[COPY_STORAGE]]
1722
+ // CHECK-LABEL: } // end sil function 'testBeginApplyGCopyConsumeInGuaranteedValue'
1723
+ sil [ossa] @testBeginApplyGCopyConsumeInGuaranteedValue : $@convention(thin) <T> () -> () {
1724
+ entry:
1725
+ (%yield, %token) = begin_apply undef<T>() : $@yield_once @convention(thin) <τ_0_0> () -> @yields @in_guaranteed τ_0_0
1726
+ %copy = copy_value %yield : $T
1727
+ end_apply %token
1728
+ apply undef<T>(%copy) : $@convention(thin) <T> (@in T) -> ()
1729
+ %retval = tuple ()
1730
+ return %retval : $()
1731
+ }
1732
+
1733
+ // Verify that a copy_value that is a "copy-store" whose source is an
1734
+ // @in_guaranteed storage generates storage.
1735
+ // CHECK-LABEL: sil [ossa] @testBeginApplyH1CopyStoreInGuaranteedValue : {{.*}} {
1736
+ // CHECK: [[COPY_STORAGE:%[^,]+]] = alloc_stack $T
1737
+ // CHECK: ([[YIELD_STORAGE:%[^,]+]], [[TOKEN:%[^,]+]]) = begin_apply
1738
+ // CHECK: copy_addr [[YIELD_STORAGE]] to [init] [[COPY_STORAGE]]
1739
+ // CHECK: end_apply [[TOKEN]]
1740
+ // CHECK: [[PTR:%[^,]+]] = apply undef
1741
+ // CHECK: [[ADDR:%[^,]+]] = pointer_to_address [[PTR:%[^,]+]]
1742
+ // CHECK: copy_addr [take] [[COPY_STORAGE]] to [[ADDR]]
1743
+ // CHECK-LABEL: } // end sil function 'testBeginApplyH1CopyStoreInGuaranteedValue'
1744
+ sil [ossa] @testBeginApplyH1CopyStoreInGuaranteedValue : $@convention(thin) <T> () -> () {
1745
+ entry:
1746
+ (%yield, %token) = begin_apply undef<T>() : $@yield_once @convention(thin) <τ_0_0> () -> @yields @in_guaranteed τ_0_0
1747
+ %copy = copy_value %yield : $T
1748
+ end_apply %token
1749
+ %ptr = apply undef<T>() : $@convention(method) <τ_0_0> () -> Builtin.RawPointer
1750
+ %addr = pointer_to_address %ptr : $Builtin.RawPointer to [strict] $*T
1751
+ store %copy to [assign] %addr : $*T
1752
+ %retval = tuple ()
1753
+ return %retval : $()
1754
+ }
1755
+
1756
+ // sil [ossa] @testBeginApplyIConsumeInValue : {{.*}} {
1757
+ // bb0:
1758
+ // [[IN_STORAGE:%[^,]+]] = alloc_stack $T
1759
+ // ([[YIELD_STORAGE:%[^,]+]], [[TOKEN:%[^,]+]]) = begin_apply undef<T>()
1760
+ // copy_addr [take] [[YIELD_STORAGE]] to [init] [[IN_STORAGE]]
1761
+ // end_apply [[TOKEN]]
1762
+ // apply undef<T>([[IN_STORAGE]])
1763
+ // } // end sil function 'testBeginApplyIConsumeInValue'
1764
+ sil [ossa] @testBeginApplyIConsumeInValue : $@convention(thin) <T> () -> () {
1765
+ entry:
1766
+ (%yield, %token) = begin_apply undef<T>() : $@yield_once @convention(thin) <τ_0_0> () -> @yields @in τ_0_0
1767
+ end_apply %token
1768
+ apply undef<T>(%yield) : $@convention(thin) <T> (@in T) -> ()
1769
+ %retval = tuple ()
1770
+ return %retval : $()
1771
+ }
1772
+
1773
+ // sil [ossa] @testBeginApplyJStoreInValue : {{.*}} {
1774
+ // [[IN_STORAGE:%[^,]+]] = alloc_stack $T
1775
+ // ([[YIELD_STORAGE:%[^,]+]], [[TOKEN:%[^,]+]]) = begin_apply
1776
+ // copy_addr [take] [[YIELD_STORAGE]] to [init] [[IN_STORAGE]]
1777
+ // end_apply [[TOKEN]]
1778
+ // [[PTR:%[^,]+]] = apply
1779
+ // [[ADDR:%[^,]+]] = pointer_to_address [[PTR:%[^,]+]]
1780
+ // copy_addr [take] [[IN_STORAGE]] to [[ADDR]]
1781
+ // } // end sil function 'testBeginApplyJStoreInValue'
1782
+ sil [ossa] @testBeginApplyJStoreInValue : $@convention(thin) <T> () -> () {
1783
+ entry:
1784
+ (%yield, %token) = begin_apply undef<T>() : $@yield_once @convention(thin) <τ_0_0> () -> @yields @in τ_0_0
1785
+ end_apply %token
1786
+ %ptr = apply undef<T>() : $@convention(method) <τ_0_0> () -> Builtin.RawPointer
1787
+ %addr = pointer_to_address %ptr : $Builtin.RawPointer to [strict] $*T
1788
+ store %yield to [assign] %addr : $*T
1789
+ %retval = tuple ()
1790
+ return %retval : $()
1791
+ }
1792
+
1793
+ // sil [ossa] @testBeginApplyKConsumeInConstantValue : {{.*}} {
1794
+ // bb0:
1795
+ // [[IN_CONSTANT_STORAGE:%[^,]+]] = alloc_stack $T
1796
+ // ([[YIELD_STORAGE:%[^,]+]], [[TOKEN:%[^,]+]]) = begin_apply undef<T>()
1797
+ // copy_addr [take] [[YIELD_STORAGE]] to [init] [[IN_CONSTANT_STORAGE]]
1798
+ // end_apply [[TOKEN]]
1799
+ // apply undef<T>([[IN_CONSTANT_STORAGE]])
1800
+ // } // end sil function 'testBeginApplyKConsumeInConstantValue'
1801
+ sil [ossa] @testBeginApplyKConsumeInConstantValue : $@convention(thin) <T> () -> () {
1802
+ entry:
1803
+ (%yield, %token) = begin_apply undef<T>() : $@yield_once @convention(thin) <τ_0_0> () -> @yields @in_constant τ_0_0
1804
+ end_apply %token
1805
+ apply undef<T>(%yield) : $@convention(thin) <T> (@in_constant T) -> ()
1806
+ %retval = tuple ()
1807
+ return %retval : $()
1808
+ }
1809
+
1810
+ // sil [ossa] @testBeginApplyLStoreInConstantValue : {{.*}} {
1811
+ // [[IN_CONSTANT_STORAGE:%[^,]+]] = alloc_stack $T
1812
+ // ([[YIELD_STORAGE:%[^,]+]], [[TOKEN:%[^,]+]]) = begin_apply
1813
+ // copy_addr [take] [[YIELD_STORAGE]] to [init] [[IN_CONSTANT_STORAGE]]
1814
+ // end_apply [[TOKEN]]
1815
+ // [[PTR:%[^,]+]] = apply
1816
+ // [[ADDR:%[^,]+]] = pointer_to_address [[PTR:%[^,]+]]
1817
+ // copy_addr [take] [[IN_CONSTANT_STORAGE]] to [[ADDR]]
1818
+ // } // end sil function 'testBeginApplyLStoreInConstantValue'
1819
+ sil [ossa] @testBeginApplyLStoreInConstantValue : $@convention(thin) <T> () -> () {
1820
+ entry:
1821
+ (%yield, %token) = begin_apply undef<T>() : $@yield_once @convention(thin) <τ_0_0> () -> @yields @in_constant τ_0_0
1822
+ end_apply %token
1823
+ %ptr = apply undef<T>() : $@convention(method) <τ_0_0> () -> Builtin.RawPointer
1824
+ %addr = pointer_to_address %ptr : $Builtin.RawPointer to [strict] $*T
1825
+ store %yield to [assign] %addr : $*T
1826
+ %retval = tuple ()
1827
+ return %retval : $()
1828
+ }
1829
+
1713
1830
// CHECK-LABEL: sil hidden [ossa] @testOpaqueYield :
1714
1831
// CHECK: bb0(%0 : @guaranteed $TestGeneric<T>):
1715
1832
// CHECK: [[REF:%.*]] = ref_element_addr %0 : $TestGeneric<T>, #TestGeneric.borrowedGeneric
0 commit comments