Skip to content

Commit 34dcb8d

Browse files
committed
[region-isolation] Add support for load_unowned.
1 parent 62c6ed2 commit 34dcb8d

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

lib/SILOptimizer/Analysis/RegionAnalysis.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2262,6 +2262,7 @@ CONSTANT_TRANSLATION(ClassMethodInst, Assign)
22622262
CONSTANT_TRANSLATION(ObjCMethodInst, Assign)
22632263
CONSTANT_TRANSLATION(SuperMethodInst, Assign)
22642264
CONSTANT_TRANSLATION(ObjCSuperMethodInst, Assign)
2265+
CONSTANT_TRANSLATION(LoadUnownedInst, Assign)
22652266

22662267
// These instructions are in between look through and a true assign. We should
22672268
// probably eventually treat them as look through but we haven't done the work
@@ -2462,7 +2463,6 @@ CONSTANT_TRANSLATION(ObjCExistentialMetatypeToObjectInst, Unhandled)
24622463
CONSTANT_TRANSLATION(WeakCopyValueInst, Unhandled)
24632464
CONSTANT_TRANSLATION(StrongCopyWeakValueInst, Unhandled)
24642465
CONSTANT_TRANSLATION(StrongCopyUnmanagedValueInst, Unhandled)
2465-
CONSTANT_TRANSLATION(LoadUnownedInst, Unhandled)
24662466
CONSTANT_TRANSLATION(ValueMetatypeInst, Unhandled)
24672467
CONSTANT_TRANSLATION(ExistentialMetatypeInst, Unhandled)
24682468
CONSTANT_TRANSLATION(InitExistentialValueInst, Unhandled)

test/Concurrency/transfernonsendable_instruction_matching.sil

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1587,3 +1587,21 @@ bb0:
15871587
%9999 = tuple ()
15881588
return %9999 : $()
15891589
}
1590+
1591+
sil [ossa] @load_unowned_test : $@async @convention(thin) () -> () {
1592+
bb0:
1593+
%constructFn = function_ref @constructNonSendableKlass : $@convention(thin) () -> @owned NonSendableKlass
1594+
%value = apply %constructFn() : $@convention(thin) () -> @owned NonSendableKlass
1595+
%a = alloc_stack $@sil_unowned NonSendableKlass
1596+
store_unowned %value to [init] %a : $*@sil_unowned NonSendableKlass
1597+
1598+
%transferNonSendableKlass = function_ref @transferNonSendableKlass : $@convention(thin) @async (@guaranteed NonSendableKlass) -> ()
1599+
apply [caller_isolation=nonisolated] [callee_isolation=global_actor] %transferNonSendableKlass(%value) : $@convention(thin) @async (@guaranteed NonSendableKlass) -> () // expected-warning {{transferring value of non-Sendable type 'NonSendableKlass' from nonisolated context to global actor '<null>'-isolated context}}
1600+
1601+
%b = load_unowned [take] %a : $*@sil_unowned NonSendableKlass // expected-note {{access here could race}}
1602+
destroy_value %b : $NonSendableKlass
1603+
destroy_value %value : $NonSendableKlass
1604+
dealloc_stack %a : $*@sil_unowned NonSendableKlass
1605+
%9999 = tuple ()
1606+
return %9999 : $()
1607+
}

0 commit comments

Comments
 (0)