|
657 | 657 | return %9999 : $()
|
658 | 658 | }
|
659 | 659 |
|
660 |
| -//// |
661 |
| - |
662 | 660 | sil [ossa] @unchecked_bitwise_cast_test_nonsendable_to_nonsendable : $@convention(thin) @async () -> () {
|
663 | 661 | bb0:
|
664 | 662 | %constructFn = function_ref @constructNonSendableKlass : $@convention(thin) () -> @owned NonSendableKlass
|
@@ -730,6 +728,90 @@ bb0:
|
730 | 728 |
|
731 | 729 | %word = unchecked_bitwise_cast %value : $SendableKlass to $Builtin.Word
|
732 | 730 |
|
| 731 | + destroy_value %value : $SendableKlass |
| 732 | + %9999 = tuple () |
| 733 | + return %9999 : $() |
| 734 | +} |
| 735 | + |
| 736 | +sil [ossa] @unchecked_value_cast_test_nonsendable_to_nonsendable : $@convention(thin) @async () -> () { |
| 737 | +bb0: |
| 738 | + %constructFn = function_ref @constructNonSendableKlass : $@convention(thin) () -> @owned NonSendableKlass |
| 739 | + %value = apply %constructFn() : $@convention(thin) () -> @owned NonSendableKlass |
| 740 | + %valueB = begin_borrow %value : $NonSendableKlass |
| 741 | + |
| 742 | + %rawPointer = unchecked_value_cast %valueB : $NonSendableKlass to $Builtin.RawPointer |
| 743 | + |
| 744 | + %transferRawPointer = function_ref @transferRawPointer : $@convention(thin) @async (Builtin.RawPointer) -> () |
| 745 | + apply [caller_isolation=nonisolated] [callee_isolation=global_actor] %transferRawPointer(%rawPointer) : $@convention(thin) @async (Builtin.RawPointer) -> () |
| 746 | + // expected-warning @-1 {{passing argument of non-sendable type 'Builtin.RawPointer' from nonisolated context to global actor '<null>'-isolated context at this call site could yield a race with accesses later in this function}} |
| 747 | + |
| 748 | + fix_lifetime %value : $NonSendableKlass |
| 749 | + // expected-note @-1 {{access here could race}} |
| 750 | + |
| 751 | + end_borrow %valueB : $NonSendableKlass |
| 752 | + destroy_value %value : $NonSendableKlass |
| 753 | + %9999 = tuple () |
| 754 | + return %9999 : $() |
| 755 | +} |
| 756 | + |
| 757 | +sil [ossa] @unchecked_value_cast_test_sendable_to_nonsendable : $@convention(thin) @async () -> () { |
| 758 | +bb0: |
| 759 | + %constructFn = function_ref @constructSendableKlass : $@convention(thin) () -> @owned SendableKlass |
| 760 | + %value = apply %constructFn() : $@convention(thin) () -> @owned SendableKlass |
| 761 | + |
| 762 | + %valueB = begin_borrow %value : $SendableKlass |
| 763 | + %rawPointer = unchecked_value_cast %valueB : $SendableKlass to $Builtin.RawPointer |
| 764 | + |
| 765 | + %transferRawPointer = function_ref @transferRawPointer : $@convention(thin) @async (Builtin.RawPointer) -> () |
| 766 | + apply [caller_isolation=nonisolated] [callee_isolation=global_actor] %transferRawPointer(%rawPointer) : $@convention(thin) @async (Builtin.RawPointer) -> () |
| 767 | + // expected-warning @-1 {{passing argument of non-sendable type 'Builtin.RawPointer' from nonisolated context to global actor '<null>'-isolated context at this call site could yield a race with accesses later in this function}} |
| 768 | + |
| 769 | + fix_lifetime %value : $SendableKlass |
| 770 | + |
| 771 | + apply [caller_isolation=nonisolated] [callee_isolation=global_actor] %transferRawPointer(%rawPointer) : $@convention(thin) @async (Builtin.RawPointer) -> () |
| 772 | + // expected-warning @-1 {{passing argument of non-sendable type 'Builtin.RawPointer' from nonisolated context to global actor '<null>'-isolated context at this call site could yield a race with accesses later in this function}} |
| 773 | + // expected-note @-2 {{access here could race}} |
| 774 | + |
| 775 | + fix_lifetime %rawPointer : $Builtin.RawPointer |
| 776 | + // expected-note @-1 {{access here could race}} |
| 777 | + |
| 778 | + end_borrow %valueB : $SendableKlass |
| 779 | + destroy_value %value : $SendableKlass |
| 780 | + %9999 = tuple () |
| 781 | + return %9999 : $() |
| 782 | +} |
| 783 | + |
| 784 | +sil [ossa] @unchecked_value_cast_test_nonsendable_to_sendable : $@convention(thin) @async () -> () { |
| 785 | +bb0: |
| 786 | + %constructFn = function_ref @constructNonSendableKlass : $@convention(thin) () -> @owned NonSendableKlass |
| 787 | + %value = apply %constructFn() : $@convention(thin) () -> @owned NonSendableKlass |
| 788 | + |
| 789 | + %transferNonSendableKlass = function_ref @transferNonSendableKlass : $@convention(thin) @async (@guaranteed NonSendableKlass) -> () |
| 790 | + apply [caller_isolation=nonisolated] [callee_isolation=global_actor] %transferNonSendableKlass(%value) : $@convention(thin) @async (@guaranteed NonSendableKlass) -> () |
| 791 | + // expected-warning @-1 {{passing argument of non-sendable type 'NonSendableKlass' from nonisolated context to global actor '<null>'-isolated context at this call site could yield a race with accesses later in this function}} |
| 792 | + |
| 793 | + %valueB = begin_borrow %value : $NonSendableKlass |
| 794 | + %word = unchecked_value_cast %valueB : $NonSendableKlass to $Builtin.Word |
| 795 | + // expected-note @-1 {{access here could race}} |
| 796 | + end_borrow %valueB : $NonSendableKlass |
| 797 | + |
| 798 | + destroy_value %value : $NonSendableKlass |
| 799 | + %9999 = tuple () |
| 800 | + return %9999 : $() |
| 801 | +} |
| 802 | + |
| 803 | +sil [ossa] @unchecked_value_cast_test_sendable_to_sendable : $@convention(thin) @async () -> () { |
| 804 | +bb0: |
| 805 | + %constructFn = function_ref @constructSendableKlass : $@convention(thin) () -> @owned SendableKlass |
| 806 | + %value = apply %constructFn() : $@convention(thin) () -> @owned SendableKlass |
| 807 | + |
| 808 | + %transferSendableKlass = function_ref @transferSendableKlass : $@convention(thin) @async (@guaranteed SendableKlass) -> () |
| 809 | + apply [caller_isolation=nonisolated] [callee_isolation=global_actor] %transferSendableKlass(%value) : $@convention(thin) @async (@guaranteed SendableKlass) -> () |
| 810 | + |
| 811 | + %valueB = begin_borrow %value : $SendableKlass |
| 812 | + %word = unchecked_value_cast %valueB : $SendableKlass to $Builtin.Word |
| 813 | + end_borrow %valueB : $SendableKlass |
| 814 | + |
733 | 815 | destroy_value %value : $SendableKlass
|
734 | 816 | %9999 = tuple ()
|
735 | 817 | return %9999 : $()
|
|
0 commit comments