@@ -1788,3 +1788,58 @@ bb6(%14 : $FakeBool):
1788
1788
return %14 : $FakeBool
1789
1789
}
1790
1790
1791
+ struct Err: Error {
1792
+ var i: Int
1793
+ }
1794
+
1795
+ sil @callee1 : $@convention(thin) (Int) -> @out Int
1796
+ sil @callee2 : $@convention(thin) (Int) -> (@out Int, @error_indirect Err)
1797
+
1798
+ // CHECK-LABEL: sil [ossa] @try_apply_to_apply_with_indirect_error1 :
1799
+ // CHECK: [[OUT:%.*]] = alloc_stack $Int
1800
+ // CHECK: apply {{%[0-9]+}}([[OUT]], %0)
1801
+ // CHECK: } // end sil function 'try_apply_to_apply_with_indirect_error1'
1802
+ sil [ossa] @try_apply_to_apply_with_indirect_error1 : $@convention(method) (Int) -> () {
1803
+ bb0(%0 : $Int):
1804
+ %1 = function_ref @callee1 : $@convention(thin) (Int) -> @out Int
1805
+ %2 = thin_to_thick_function %1 : $@convention(thin) (Int) -> @out Int to $@noescape @callee_guaranteed (Int) -> @out Int
1806
+ %3 = convert_function %2 : $@noescape @callee_guaranteed (Int) -> @out Int to $@noescape @callee_guaranteed (Int) -> (@out Int, @error_indirect Err), forwarding: @owned
1807
+ %4 = alloc_stack $Int
1808
+ %5 = alloc_stack $Err
1809
+ try_apply %3(%4, %5, %0) : $@noescape @callee_guaranteed (Int) -> (@out Int, @error_indirect Err), normal bb10, error bb11
1810
+
1811
+ bb10(%7 : $()):
1812
+ dealloc_stack %5 : $*Err
1813
+ dealloc_stack %4 : $*Int
1814
+ destroy_value %3 : $@noescape @callee_guaranteed (Int) -> (@out Int, @error_indirect Err)
1815
+ %r = tuple ()
1816
+ return %r : $()
1817
+
1818
+ bb11:
1819
+ dealloc_stack %5 : $*Err
1820
+ dealloc_stack %4 : $*Int
1821
+ destroy_value %3 : $@noescape @callee_guaranteed (Int) -> (@out Int, @error_indirect Err)
1822
+ unreachable
1823
+ }
1824
+
1825
+ // CHECK-LABEL: sil [ossa] @try_apply_to_apply_with_indirect_error2 :
1826
+ // CHECK: [[OUT:%.*]] = alloc_stack $Int
1827
+ // CHECK: [[ERR:%.*]] = alloc_stack $Err
1828
+ // CHECK: apply [nothrow] {{%[0-9]+}}([[OUT]], [[ERR]], %0)
1829
+ // CHECK: } // end sil function 'try_apply_to_apply_with_indirect_error2'
1830
+ sil [ossa] @try_apply_to_apply_with_indirect_error2 : $@convention(method) (Int) -> () {
1831
+ bb0(%0 : $Int):
1832
+ %1 = function_ref @callee2 : $@convention(thin) (Int) -> (@out Int, @error_indirect Err)
1833
+ %4 = alloc_stack $Int
1834
+ %5 = alloc_stack $Err
1835
+ try_apply %1(%4, %5, %0) : $@convention(thin) (Int) -> (@out Int, @error_indirect Err), normal bb10, error bb11
1836
+
1837
+ bb10(%7 : $()):
1838
+ dealloc_stack %5 : $*Err
1839
+ dealloc_stack %4 : $*Int
1840
+ %r = tuple ()
1841
+ return %r : $()
1842
+
1843
+ bb11:
1844
+ unreachable
1845
+ }
0 commit comments