Skip to content

Commit ce32a8d

Browse files
committed
[region-isolation] Add support for store_unowned.
1 parent 531154c commit ce32a8d

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

lib/SILOptimizer/Analysis/RegionAnalysis.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2328,6 +2328,7 @@ CONSTANT_TRANSLATION(StoreWeakInst, Store)
23282328
CONSTANT_TRANSLATION(MarkUnresolvedMoveAddrInst, Store)
23292329
CONSTANT_TRANSLATION(UncheckedRefCastAddrInst, Store)
23302330
CONSTANT_TRANSLATION(UnconditionalCheckedCastAddrInst, Store)
2331+
CONSTANT_TRANSLATION(StoreUnownedInst, Store)
23312332

23322333
//===---
23332334
// Ignored
@@ -2455,7 +2456,6 @@ CONSTANT_TRANSLATION(AssignByWrapperInst, Unhandled)
24552456
CONSTANT_TRANSLATION(AssignOrInitInst, Unhandled)
24562457
CONSTANT_TRANSLATION(MarkFunctionEscapeInst, Unhandled)
24572458
CONSTANT_TRANSLATION(TestSpecificationInst, Unhandled)
2458-
CONSTANT_TRANSLATION(StoreUnownedInst, Unhandled)
24592459
CONSTANT_TRANSLATION(PackElementSetInst, Unhandled)
24602460

24612461
//===---

test/Concurrency/transfernonsendable_instruction_matching.sil

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1262,3 +1262,30 @@ bb0:
12621262
return %9999 : $()
12631263
}
12641264

1265+
sil [ossa] @store_unowned_test : $@async @convention(thin) () -> () {
1266+
bb0:
1267+
%a = alloc_stack $NonSendableKlass
1268+
%c = function_ref @initIndirect : $@convention(thin) <T> () -> @out T
1269+
apply %c<NonSendableKlass>(%a) : $@convention(thin) <T> () -> @out T
1270+
1271+
%aValue = load [copy] %a : $*NonSendableKlass
1272+
%f = function_ref @transferIndirect : $@convention(thin) @async <τ_0_0> (@in_guaranteed τ_0_0) -> ()
1273+
apply [caller_isolation=nonisolated] [callee_isolation=global_actor] %f<NonSendableKlass>(%a) : $@convention(thin) @async <τ_0_0> (@in_guaranteed τ_0_0) -> () // expected-warning {{transferring value of non-Sendable type 'NonSendableKlass' from nonisolated context to global actor '<null>'-isolated context}}
1274+
1275+
1276+
%b = alloc_stack $@sil_unowned NonSendableKlass
1277+
store_unowned %aValue to [init] %b : $*@sil_unowned NonSendableKlass // expected-note {{access here could race}}
1278+
destroy_value %aValue : $NonSendableKlass
1279+
1280+
apply [caller_isolation=nonisolated] [callee_isolation=global_actor] %f<@sil_unowned NonSendableKlass>(%b) : $@convention(thin) @async <τ_0_0> (@in_guaranteed τ_0_0) -> () // expected-warning {{transferring value of non-Sendable type 'NonSendableKlass' from nonisolated context to global actor '<null>'-isolated context}}
1281+
apply [caller_isolation=nonisolated] [callee_isolation=global_actor] %f<@sil_unowned NonSendableKlass>(%b) : $@convention(thin) @async <τ_0_0> (@in_guaranteed τ_0_0) -> () // expected-note {{access here could race}}
1282+
1283+
destroy_addr %b : $*@sil_unowned NonSendableKlass
1284+
destroy_addr %a : $*NonSendableKlass
1285+
dealloc_stack %b : $*@sil_unowned NonSendableKlass
1286+
dealloc_stack %a : $*NonSendableKlass
1287+
1288+
%9999 = tuple ()
1289+
return %9999 : $()
1290+
}
1291+

0 commit comments

Comments
 (0)