Skip to content

Commit 9b9102b

Browse files
committed
[region-isolation] Add support for autorelease_value.
1 parent d514c6e commit 9b9102b

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

lib/SILOptimizer/Analysis/RegionAnalysis.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2115,6 +2115,7 @@ CONSTANT_TRANSLATION(MarkUnresolvedMoveAddrInst, Store)
21152115
// value is within or because even though they are technically a use we would
21162116
// rather emit an error on a better instruction.
21172117
CONSTANT_TRANSLATION(AllocGlobalInst, Ignored)
2118+
CONSTANT_TRANSLATION(AutoreleaseValueInst, Ignored)
21182119
CONSTANT_TRANSLATION(DeallocBoxInst, Ignored)
21192120
CONSTANT_TRANSLATION(DeallocStackInst, Ignored)
21202121
CONSTANT_TRANSLATION(DebugValueInst, Ignored)
@@ -2224,7 +2225,6 @@ CONSTANT_TRANSLATION(DeallocPartialRefInst, Unhandled)
22242225
CONSTANT_TRANSLATION(UnmanagedRetainValueInst, Unhandled)
22252226
CONSTANT_TRANSLATION(UnmanagedReleaseValueInst, Unhandled)
22262227
CONSTANT_TRANSLATION(UnmanagedAutoreleaseValueInst, Unhandled)
2227-
CONSTANT_TRANSLATION(AutoreleaseValueInst, Unhandled)
22282228
CONSTANT_TRANSLATION(BeginUnpairedAccessInst, Unhandled)
22292229
CONSTANT_TRANSLATION(EndUnpairedAccessInst, Unhandled)
22302230
CONSTANT_TRANSLATION(AssignInst, Unhandled)

test/Concurrency/transfernonsendable_instruction_matching.sil

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -965,6 +965,28 @@ bb0:
965965
dealloc_stack %a : $*(NonSendableKlass, NonSendableKlass)
966966
destroy_value %1 : $NonSendableKlass
967967

968+
%9999 = tuple ()
969+
return %9999 : $()
970+
}
971+
972+
sil [ossa] @autorelease_value_test : $@convention(thin) @async () -> () {
973+
bb0:
974+
%0 = function_ref @constructNonSendableKlass : $@convention(thin) () -> @owned NonSendableKlass
975+
%1 = apply %0() : $@convention(thin) () -> @owned NonSendableKlass
976+
977+
%a = alloc_stack $(NonSendableKlass, NonSendableKlass)
978+
%1_copy = copy_value %1 : $NonSendableKlass
979+
%1_copy_copy = copy_value %1 : $NonSendableKlass
980+
%tup = tuple (%1_copy : $NonSendableKlass, %1_copy_copy : $NonSendableKlass)
981+
store %tup to [init] %a : $*(NonSendableKlass, NonSendableKlass)
982+
983+
%f = function_ref @transferNonSendableKlass : $@convention(thin) @async (@guaranteed NonSendableKlass) -> ()
984+
apply [caller_isolation=nonisolated] [callee_isolation=global_actor] %f(%1) : $@convention(thin) @async (@guaranteed NonSendableKlass) -> ()
985+
986+
destroy_addr %a : $*(NonSendableKlass, NonSendableKlass)
987+
dealloc_stack %a : $*(NonSendableKlass, NonSendableKlass)
988+
autorelease_value %1 : $NonSendableKlass
989+
968990
%9999 = tuple ()
969991
return %9999 : $()
970992
}

0 commit comments

Comments
 (0)