Skip to content

Commit 5aec06f

Browse files
committed
[region-isolation] Add support for is_unique.
1 parent 855b9ff commit 5aec06f

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

lib/SILOptimizer/Analysis/RegionAnalysis.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2108,6 +2108,7 @@ CONSTANT_TRANSLATION(DebugStepInst, Ignored)
21082108
CONSTANT_TRANSLATION(FixLifetimeInst, Require)
21092109
CONSTANT_TRANSLATION(ClassifyBridgeObjectInst, Require)
21102110
CONSTANT_TRANSLATION(BridgeObjectToWordInst, Require)
2111+
CONSTANT_TRANSLATION(IsUniqueInst, Require)
21112112

21122113
//===---
21132114
// Terminators
@@ -2156,7 +2157,6 @@ CONSTANT_TRANSLATION(ValueToBridgeObjectInst, Unhandled)
21562157
CONSTANT_TRANSLATION(WeakCopyValueInst, Unhandled)
21572158
CONSTANT_TRANSLATION(StrongCopyWeakValueInst, Unhandled)
21582159
CONSTANT_TRANSLATION(StrongCopyUnmanagedValueInst, Unhandled)
2159-
CONSTANT_TRANSLATION(IsUniqueInst, Unhandled)
21602160
CONSTANT_TRANSLATION(LoadUnownedInst, Unhandled)
21612161
CONSTANT_TRANSLATION(ValueMetatypeInst, Unhandled)
21622162
CONSTANT_TRANSLATION(ExistentialMetatypeInst, Unhandled)

test/Concurrency/transfernonsendable_instruction_matching.sil

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -896,3 +896,22 @@ bb0(%0 : @owned $NonSendableMoveOnlyStruct):
896896
return %9999 : $()
897897
}
898898

899+
sil [ossa] @is_unique_test : $@convention(thin) @async () -> () {
900+
bb0:
901+
%constructFn = function_ref @constructNonSendableKlass : $@convention(thin) () -> @owned NonSendableKlass
902+
%value = apply %constructFn() : $@convention(thin) () -> @owned NonSendableKlass
903+
%a = alloc_stack $NonSendableKlass
904+
%valueCopy = copy_value %value : $NonSendableKlass
905+
store %valueCopy to [init] %a : $*NonSendableKlass
906+
907+
%transferNonSendableKlass = function_ref @transferNonSendableKlass : $@convention(thin) @async (@guaranteed NonSendableKlass) -> ()
908+
apply [caller_isolation=nonisolated] [callee_isolation=global_actor] %transferNonSendableKlass(%value) : $@convention(thin) @async (@guaranteed NonSendableKlass) -> () // expected-warning {{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}}
909+
910+
destroy_value %value : $NonSendableKlass
911+
%1 = is_unique %a : $*NonSendableKlass // expected-note {{access here could race}}
912+
destroy_addr %a : $*NonSendableKlass
913+
dealloc_stack %a : $*NonSendableKlass
914+
915+
%9999 = tuple ()
916+
return %9999 : $()
917+
}

0 commit comments

Comments
 (0)