|
1 |
| -// RUN: %target-sil-opt -enable-objc-interop -enable-sil-verify-all %s -sil-combine | %FileCheck %s |
| 1 | +// RUN: %target-sil-opt -enable-objc-interop -enable-sil-verify-all %s -sil-combine -sil-print-generic-specialization-info | %FileCheck %s |
| 2 | +// RUN: %target-swift-frontend -O %s -emit-ir |
2 | 3 |
|
3 | 4 | // These tests exercise the same SILCombine optimization as
|
4 | 5 | // existential_type_propagation.sil, but cover additional corner
|
@@ -615,3 +616,91 @@ bb0(%0 : $*τ_0_0, %1 : $*τ_0_2, %2 : $*τ_0_1):
|
615 | 616 | dealloc_stack %5 : $*P1
|
616 | 617 | return %25 : $()
|
617 | 618 | }
|
| 619 | + |
| 620 | + |
| 621 | +public class MyObject { |
| 622 | + deinit |
| 623 | + init() |
| 624 | +} |
| 625 | + |
| 626 | +public protocol SubscriptionViewControllerDelegate { } |
| 627 | + |
| 628 | +public class SubscriptionViewController { |
| 629 | + deinit |
| 630 | + init() |
| 631 | +} |
| 632 | + |
| 633 | +public protocol ResourceKitProtocol : MyObject { } |
| 634 | + |
| 635 | +public protocol ResourceKitDelegate { |
| 636 | + func subscriptionViewController(for resourceKit: ResourceKitProtocol) |
| 637 | +} |
| 638 | + |
| 639 | +class ViewController : ResourceKitDelegate { |
| 640 | + func subscriptionViewController(for resourceKit: ResourceKitProtocol) |
| 641 | + deinit |
| 642 | + init() |
| 643 | +} |
| 644 | + |
| 645 | +class SubscriptionViewControllerBuilder { |
| 646 | + @_hasStorage final let delegate: SubscriptionViewControllerDelegate { get } |
| 647 | + init(delegate: SubscriptionViewControllerDelegate) |
| 648 | + deinit |
| 649 | +} |
| 650 | + |
| 651 | +extension MyObject : SubscriptionViewControllerDelegate { } |
| 652 | + |
| 653 | +// Make sure that we correctly update the substitution map of the apply. |
| 654 | +// To satisfy ``τ_0_0 : SubscriptionViewControllerDelegate`` the updated |
| 655 | +// substitution map of |
| 656 | +// apply %10<$@opened("E4D92D2A-8893-11EA-9C89-ACDE48001122") ResourceKitProtocol> |
| 657 | +// needs to contain the concrete conformance |
| 658 | +// ``(normal_conformance type=NSObject protocol=SubscriptionViewControllerDelegate)`` |
| 659 | +// not ``(abstract_conformance protocol=SubscriptionViewControllerDelegate)`` |
| 660 | + |
| 661 | +sil @callee2 : $@convention(thin) <τ_0_0 where τ_0_0 : SubscriptionViewControllerDelegate> (@in τ_0_0, @thick SubscriptionViewControllerBuilder.Type) -> @owned SubscriptionViewControllerBuilder |
| 662 | + |
| 663 | +// CHECK: sil @test_opend_archeype_concrete_conformance_substitution : $@convention(method) (@guaranteed ResourceKitProtocol, @guaranteed ViewController) -> () { |
| 664 | +// CHECK: bb0([[ARG:%.*]] : $ResourceKitProtocol, [[ARG2:%.*]] : $ViewController): |
| 665 | +// CHECK: [[T1:%.*]] = metatype $@thick SubscriptionViewControllerBuilder.Type |
| 666 | +// CHECK: [[T2:%.*]] = open_existential_ref [[ARG]] : $ResourceKitProtocol to $@opened("E4D92D2A-8893-11EA-9C89-ACDE48001122") ResourceKitProtocol |
| 667 | +// CHECK: [[T3:%.*]] = alloc_stack $SubscriptionViewControllerDelegate |
| 668 | +// CHECK: [[T4:%.*]] = init_existential_addr [[T3]] : $*SubscriptionViewControllerDelegate, $@opened("E4D92D2A-8893-11EA-9C89-ACDE48001122") ResourceKitProtocol |
| 669 | +// CHECK: store [[T2]] to [[T4]] : $*@opened("E4D92D2A-8893-11EA-9C89-ACDE48001122") ResourceKitProtocol |
| 670 | +// CHECK: [[T5:%.*]] = function_ref @callee2 : $@convention(thin) <τ_0_0 where τ_0_0 : SubscriptionViewControllerDelegate> (@in τ_0_0, @thick SubscriptionViewControllerBuilder.Type) -> @owned SubscriptionViewControllerBuilder |
| 671 | +// CHECK: [[T6:%.*]] = alloc_stack $@opened("E4D92D2A-8893-11EA-9C89-ACDE48001122") ResourceKitProtocol |
| 672 | +// CHECK: copy_addr [[T4]] to [initialization] [[T6]] : $*@opened("E4D92D2A-8893-11EA-9C89-ACDE48001122") ResourceKitProtocol |
| 673 | +// CHECK: Generic specialization information for call-site callee2 <ResourceKitProtocol> conformances <(inherited_conformance type=ResourceKitProtocol protocol=SubscriptionViewControllerDelegate |
| 674 | +// CHECK: (normal_conformance type=MyObject protocol=SubscriptionViewControllerDelegate))>: |
| 675 | +// CHECK: apply [[T5]]<@opened("E4D92D2A-8893-11EA-9C89-ACDE48001122") ResourceKitProtocol>([[T6]], [[T1]]) |
| 676 | + |
| 677 | +sil @test_opend_archeype_concrete_conformance_substitution : $@convention(method) (@guaranteed ResourceKitProtocol, @guaranteed ViewController) -> () { |
| 678 | +bb0(%0 : $ResourceKitProtocol, %1 : $ViewController): |
| 679 | + %4 = metatype $@thick SubscriptionViewControllerBuilder.Type |
| 680 | + %5 = open_existential_ref %0 : $ResourceKitProtocol to $@opened("E4D92D2A-8893-11EA-9C89-ACDE48001122") ResourceKitProtocol |
| 681 | + %6 = alloc_stack $SubscriptionViewControllerDelegate |
| 682 | + %7 = init_existential_addr %6 : $*SubscriptionViewControllerDelegate, $@opened("E4D92D2A-8893-11EA-9C89-ACDE48001122") ResourceKitProtocol |
| 683 | + strong_retain %5 : $@opened("E4D92D2A-8893-11EA-9C89-ACDE48001122") ResourceKitProtocol |
| 684 | + store %5 to %7 : $*@opened("E4D92D2A-8893-11EA-9C89-ACDE48001122") ResourceKitProtocol |
| 685 | + %10 = function_ref @callee2: $@convention(thin) <τ_0_0 where τ_0_0 : SubscriptionViewControllerDelegate> (@in τ_0_0, @thick SubscriptionViewControllerBuilder.Type) -> @owned SubscriptionViewControllerBuilder |
| 686 | + %11 = open_existential_addr mutable_access %6 : $*SubscriptionViewControllerDelegate to $*@opened("FAA82796-8893-11EA-9C89-ACDE48001122") SubscriptionViewControllerDelegate |
| 687 | + %12 = alloc_stack $@opened("FAA82796-8893-11EA-9C89-ACDE48001122") SubscriptionViewControllerDelegate |
| 688 | + copy_addr %11 to [initialization] %12 : $*@opened("FAA82796-8893-11EA-9C89-ACDE48001122") SubscriptionViewControllerDelegate |
| 689 | + %14 = apply %10<@opened("FAA82796-8893-11EA-9C89-ACDE48001122") SubscriptionViewControllerDelegate>(%12, %4) : $@convention(thin) <τ_0_0 where τ_0_0 : SubscriptionViewControllerDelegate> (@in τ_0_0, @thick SubscriptionViewControllerBuilder.Type) -> @owned SubscriptionViewControllerBuilder |
| 690 | + destroy_addr %6 : $*SubscriptionViewControllerDelegate |
| 691 | + dealloc_stack %12 : $*@opened("FAA82796-8893-11EA-9C89-ACDE48001122") SubscriptionViewControllerDelegate |
| 692 | + dealloc_stack %6 : $*SubscriptionViewControllerDelegate |
| 693 | + strong_release %14 : $SubscriptionViewControllerBuilder |
| 694 | + %19 = tuple () |
| 695 | + return %19 : $() |
| 696 | +} |
| 697 | + |
| 698 | +sil_vtable SubscriptionViewControllerBuilder {} |
| 699 | +sil_vtable SubscriptionViewController {} |
| 700 | +sil_vtable ViewController {} |
| 701 | +sil_vtable CCCC {} |
| 702 | +sil_vtable CC {} |
| 703 | +sil_vtable C {} |
| 704 | +sil_vtable C_PQ {} |
| 705 | +sil_vtable CDefaultStatic {} |
| 706 | +sil_vtable MyObject {} |
0 commit comments