@@ -1656,6 +1656,78 @@ bb0(%0 : $*X):
1656
1656
return %3 : $()
1657
1657
}
1658
1658
1659
+ sil @closure : $@convention(thin) (@inout_aliasable Int) -> ()
1660
+ sil @closure2 : $@convention(thin) (Int, @inout_aliasable Int) -> ()
1661
+
1662
+ // CHECK-LABEL: @closure_with_inout
1663
+ // CHECK: PAIR #0.
1664
+ // CHECK-NEXT: %2 = partial_apply [callee_guaranteed] [on_stack] %1(%0) : $@convention(thin) (@inout_aliasable Int) -> ()
1665
+ // CHECK-NEXT: %0 = argument of bb0 : $*Int
1666
+ // CHECK-NEXT: r=0,w=0
1667
+ // CHECK: PAIR #1.
1668
+ // CHECK-NEXT: %3 = apply %2() : $@noescape @callee_guaranteed () -> ()
1669
+ // CHECK-NEXT: %0 = argument of bb0 : $*Int
1670
+ // CHECK-NEXT: r=1,w=1
1671
+ sil @closure_with_inout : $@convention(thin) (@inout Int) -> () {
1672
+ bb0(%0 : $*Int):
1673
+ %1 = function_ref @closure : $@convention(thin) (@inout_aliasable Int) -> ()
1674
+ %2 = partial_apply [callee_guaranteed] [on_stack] %1(%0) : $@convention(thin) (@inout_aliasable Int) -> ()
1675
+ %3 = apply %2() : $@noescape @callee_guaranteed () -> ()
1676
+ dealloc_stack %2 : $@noescape @callee_guaranteed () -> ()
1677
+ %r = tuple ()
1678
+ return %r : $()
1679
+ }
1680
+
1681
+ // CHECK-LABEL: @two_closures_with_inout
1682
+ // CHECK: PAIR #0.
1683
+ // CHECK-NEXT: %3 = partial_apply [callee_guaranteed] [on_stack] %2(%0) : $@convention(thin) (Int, @inout_aliasable Int) -> ()
1684
+ // CHECK-NEXT: %0 = argument of bb0 : $*Int
1685
+ // CHECK-NEXT: r=0,w=0
1686
+ // CHECK: PAIR #1.
1687
+ // CHECK-NEXT: %4 = partial_apply [callee_guaranteed] [on_stack] %3(%1) : $@noescape @callee_guaranteed (Int) -> ()
1688
+ // CHECK-NEXT: %0 = argument of bb0 : $*Int
1689
+ // CHECK-NEXT: r=0,w=0
1690
+ // CHECK: PAIR #2.
1691
+ // CHECK-NEXT: %5 = apply %4() : $@noescape @callee_guaranteed () -> ()
1692
+ // CHECK-NEXT: %0 = argument of bb0 : $*Int
1693
+ // CHECK-NEXT: r=1,w=1
1694
+ sil @two_closures_with_inout : $@convention(thin) (@inout Int, Int) -> () {
1695
+ bb0(%0 : $*Int, %1 : $Int):
1696
+ %2 = function_ref @closure2 : $@convention(thin) (Int, @inout_aliasable Int) -> ()
1697
+ %3 = partial_apply [callee_guaranteed] [on_stack] %2(%0) : $@convention(thin) (Int, @inout_aliasable Int) -> ()
1698
+ %4 = partial_apply [callee_guaranteed] [on_stack] %3(%1) : $@noescape @callee_guaranteed (Int) -> ()
1699
+ %5 = apply %4() : $@noescape @callee_guaranteed () -> ()
1700
+ dealloc_stack %4 : $@noescape @callee_guaranteed () -> ()
1701
+ dealloc_stack %3 : $@noescape @callee_guaranteed (Int) -> ()
1702
+ %r = tuple ()
1703
+ return %r : $()
1704
+ }
1705
+
1706
+ sil @call_closure : $@convention(thin) (@guaranteed @noescape @callee_guaranteed () -> ()) -> () {
1707
+ [%0: read v**.c*.v**, write v**.c*.v**]
1708
+ [global: read,write]
1709
+ }
1710
+
1711
+ // CHECK-LABEL: @pass_closure_to_function
1712
+ // CHECK: PAIR #0.
1713
+ // CHECK-NEXT: %2 = partial_apply [callee_guaranteed] [on_stack] %1(%0) : $@convention(thin) (@inout_aliasable Int) -> ()
1714
+ // CHECK-NEXT: %0 = argument of bb0 : $*Int
1715
+ // CHECK-NEXT: r=0,w=0
1716
+ // CHECK: PAIR #1.
1717
+ // CHECK-NEXT: %4 = apply %3(%2) : $@convention(thin) (@guaranteed @noescape @callee_guaranteed () -> ()) -> ()
1718
+ // CHECK-NEXT: %0 = argument of bb0 : $*Int
1719
+ // CHECK-NEXT: r=1,w=1
1720
+ sil @pass_closure_to_function : $@convention(thin) (@inout Int) -> () {
1721
+ bb0(%0 : $*Int):
1722
+ %4 = function_ref @closure : $@convention(thin) (@inout_aliasable Int) -> ()
1723
+ %5 = partial_apply [callee_guaranteed] [on_stack] %4(%0) : $@convention(thin) (@inout_aliasable Int) -> ()
1724
+ %6 = function_ref @call_closure : $@convention(thin) (@guaranteed @noescape @callee_guaranteed () -> ()) -> ()
1725
+ %7 = apply %6(%5) : $@convention(thin) (@guaranteed @noescape @callee_guaranteed () -> ()) -> ()
1726
+ dealloc_stack %5 : $@noescape @callee_guaranteed () -> ()
1727
+ %r = tuple ()
1728
+ return %r : $()
1729
+ }
1730
+
1659
1731
// CHECK-LABEL: @test_is_unique
1660
1732
// CHECK: PAIR #0.
1661
1733
// CHECK-NEXT: %2 = is_unique %0 : $*X
0 commit comments