Skip to content

Commit 3cacb1f

Browse files
committed
[region-isolation] Add support for mark_function_escape.
1 parent e3274b3 commit 3cacb1f

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
@@ -2371,6 +2371,7 @@ CONSTANT_TRANSLATION(FixLifetimeInst, Require)
23712371
CONSTANT_TRANSLATION(ClassifyBridgeObjectInst, Require)
23722372
CONSTANT_TRANSLATION(BridgeObjectToWordInst, Require)
23732373
CONSTANT_TRANSLATION(IsUniqueInst, Require)
2374+
CONSTANT_TRANSLATION(MarkFunctionEscapeInst, Require)
23742375

23752376
//===---
23762377
// Terminators
@@ -2446,7 +2447,6 @@ CONSTANT_TRANSLATION(EndUnpairedAccessInst, Unhandled)
24462447
CONSTANT_TRANSLATION(AssignInst, Unhandled)
24472448
CONSTANT_TRANSLATION(AssignByWrapperInst, Unhandled)
24482449
CONSTANT_TRANSLATION(AssignOrInitInst, Unhandled)
2449-
CONSTANT_TRANSLATION(MarkFunctionEscapeInst, Unhandled)
24502450

24512451
//===---
24522452
// Packs

test/Concurrency/transfernonsendable_instruction_matching.sil

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1297,3 +1297,22 @@ bb0:
12971297
return %9999 : $()
12981298
}
12991299

1300+
sil [ossa] @mark_function_escape_test : $@convention(thin) @async () -> () {
1301+
bb0:
1302+
%constructFn = function_ref @constructNonSendableKlass : $@convention(thin) () -> @owned NonSendableKlass
1303+
%value = apply %constructFn() : $@convention(thin) () -> @owned NonSendableKlass
1304+
%a = alloc_stack $NonSendableKlass
1305+
%valueCopy = copy_value %value : $NonSendableKlass
1306+
store %valueCopy to [init] %a : $*NonSendableKlass
1307+
1308+
%transferNonSendableKlass = function_ref @transferNonSendableKlass : $@convention(thin) @async (@guaranteed NonSendableKlass) -> ()
1309+
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; later accesses could race}}
1310+
1311+
destroy_value %value : $NonSendableKlass
1312+
mark_function_escape %a : $*NonSendableKlass // expected-note {{access here could race}}
1313+
destroy_addr %a : $*NonSendableKlass
1314+
dealloc_stack %a : $*NonSendableKlass
1315+
1316+
%9999 = tuple ()
1317+
return %9999 : $()
1318+
}

0 commit comments

Comments
 (0)