@@ -1656,6 +1656,97 @@ bb0(%0 : $*X):
16561656 return %3 : $()
16571657}
16581658
1659+ // CHECK-LABEL: @test_non_escaping_applied
1660+ // CHECK: PAIR #0.
1661+ // CHECK-NEXT: %2 = partial_apply [on_stack] %1(%0) : $@convention(thin) (@in_guaranteed X) -> ()
1662+ // CHECK-NEXT: %0 = argument of bb0 : $*X
1663+ // CHECK-NEXT: r=1,w=0
1664+ // CHECK: PAIR #1.
1665+ // CHECK-NEXT: %3 = apply %2() : $@noescape @callee_owned () -> ()
1666+ // CHECK-NEXT: %0 = argument of bb0 : $*X
1667+ // CHECK-NEXT: r=0,w=0
1668+ sil [ossa] @test_non_escaping_applied : $@convention(thin) (@in X) -> () {
1669+ bb0(%0 : $*X):
1670+ %1 = function_ref @indirect_X : $@convention(thin) (@in_guaranteed X) -> ()
1671+ %2 = partial_apply [on_stack] %1(%0) : $@convention(thin) (@in_guaranteed X) -> ()
1672+ %3 = apply %2() : $@noescape @callee_owned () -> ()
1673+ destroy_addr %0
1674+ %6 = tuple ()
1675+ return %6 : $()
1676+ }
1677+
1678+ sil @closure : $@convention(thin) (@inout_aliasable Int) -> ()
1679+ sil @closure2 : $@convention(thin) (Int, @inout_aliasable Int) -> ()
1680+
1681+ // CHECK-LABEL: @closure_with_inout
1682+ // CHECK: PAIR #0.
1683+ // CHECK-NEXT: %2 = partial_apply [callee_guaranteed] [on_stack] %1(%0) : $@convention(thin) (@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: %3 = apply %2() : $@noescape @callee_guaranteed () -> ()
1688+ // CHECK-NEXT: %0 = argument of bb0 : $*Int
1689+ // CHECK-NEXT: r=1,w=1
1690+ sil @closure_with_inout : $@convention(thin) (@inout Int) -> () {
1691+ bb0(%0 : $*Int):
1692+ %1 = function_ref @closure : $@convention(thin) (@inout_aliasable Int) -> ()
1693+ %2 = partial_apply [callee_guaranteed] [on_stack] %1(%0) : $@convention(thin) (@inout_aliasable Int) -> ()
1694+ %3 = apply %2() : $@noescape @callee_guaranteed () -> ()
1695+ dealloc_stack %2
1696+ %r = tuple ()
1697+ return %r
1698+ }
1699+
1700+ // CHECK-LABEL: @two_closures_with_inout
1701+ // CHECK: PAIR #0.
1702+ // CHECK-NEXT: %3 = partial_apply [callee_guaranteed] [on_stack] %2(%0) : $@convention(thin) (Int, @inout_aliasable Int) -> ()
1703+ // CHECK-NEXT: %0 = argument of bb0 : $*Int
1704+ // CHECK-NEXT: r=0,w=0
1705+ // CHECK: PAIR #1.
1706+ // CHECK-NEXT: %4 = partial_apply [callee_guaranteed] [on_stack] %3(%1) : $@noescape @callee_guaranteed (Int) -> ()
1707+ // CHECK-NEXT: %0 = argument of bb0 : $*Int
1708+ // CHECK-NEXT: r=0,w=0
1709+ // CHECK: PAIR #2.
1710+ // CHECK-NEXT: %5 = apply %4() : $@noescape @callee_guaranteed () -> ()
1711+ // CHECK-NEXT: %0 = argument of bb0 : $*Int
1712+ // CHECK-NEXT: r=1,w=1
1713+ sil @two_closures_with_inout : $@convention(thin) (@inout Int, Int) -> () {
1714+ bb0(%0 : $*Int, %1 : $Int):
1715+ %2 = function_ref @closure2 : $@convention(thin) (Int, @inout_aliasable Int) -> ()
1716+ %3 = partial_apply [callee_guaranteed] [on_stack] %2(%0) : $@convention(thin) (Int, @inout_aliasable Int) -> ()
1717+ %4 = partial_apply [callee_guaranteed] [on_stack] %3(%1) : $@noescape @callee_guaranteed (Int) -> ()
1718+ %5 = apply %4() : $@noescape @callee_guaranteed () -> ()
1719+ dealloc_stack %4
1720+ dealloc_stack %3
1721+ %r = tuple ()
1722+ return %r
1723+ }
1724+
1725+ sil @call_closure : $@convention(thin) (@guaranteed @noescape @callee_guaranteed () -> ()) -> () {
1726+ [%0: read v**.c*.v**, write v**.c*.v**]
1727+ [global: read,write]
1728+ }
1729+
1730+ // CHECK-LABEL: @pass_closure_to_function
1731+ // CHECK: PAIR #0.
1732+ // CHECK-NEXT: %2 = partial_apply [callee_guaranteed] [on_stack] %1(%0) : $@convention(thin) (@inout_aliasable Int) -> ()
1733+ // CHECK-NEXT: %0 = argument of bb0 : $*Int
1734+ // CHECK-NEXT: r=0,w=0
1735+ // CHECK: PAIR #1.
1736+ // CHECK-NEXT: %4 = apply %3(%2) : $@convention(thin) (@guaranteed @noescape @callee_guaranteed () -> ()) -> ()
1737+ // CHECK-NEXT: %0 = argument of bb0 : $*Int
1738+ // CHECK-NEXT: r=1,w=1
1739+ sil @pass_closure_to_function : $@convention(thin) (@inout Int) -> () {
1740+ bb0(%0 : $*Int):
1741+ %4 = function_ref @closure : $@convention(thin) (@inout_aliasable Int) -> ()
1742+ %5 = partial_apply [callee_guaranteed] [on_stack] %4(%0) : $@convention(thin) (@inout_aliasable Int) -> ()
1743+ %6 = function_ref @call_closure : $@convention(thin) (@guaranteed @noescape @callee_guaranteed () -> ()) -> ()
1744+ %7 = apply %6(%5) : $@convention(thin) (@guaranteed @noescape @callee_guaranteed () -> ()) -> ()
1745+ dealloc_stack %5
1746+ %r = tuple ()
1747+ return %r
1748+ }
1749+
16591750// CHECK-LABEL: @test_is_unique
16601751// CHECK: PAIR #0.
16611752// CHECK-NEXT: %2 = is_unique %0 : $*X
0 commit comments