Skip to content

Commit 855b9ff

Browse files
committed
[region-isolation] Add support for drop_deinit.
1 parent 38dd567 commit 855b9ff

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

lib/SILOptimizer/Analysis/RegionAnalysis.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ static bool isStaticallyLookThroughInst(SILInstruction *inst) {
193193
case SILInstructionKind::CopyableToMoveOnlyWrapperValueInst:
194194
case SILInstructionKind::DestructureStructInst:
195195
case SILInstructionKind::DestructureTupleInst:
196+
case SILInstructionKind::DropDeinitInst:
196197
case SILInstructionKind::EndCOWMutationInst:
197198
case SILInstructionKind::EndInitLetRefInst:
198199
case SILInstructionKind::ExplicitCopyValueInst:
@@ -2058,6 +2059,7 @@ CONSTANT_TRANSLATION(ProjectBlockStorageInst, LookThrough)
20582059
CONSTANT_TRANSLATION(RefToUnownedInst, LookThrough)
20592060
CONSTANT_TRANSLATION(UnownedToRefInst, LookThrough)
20602061
CONSTANT_TRANSLATION(UnownedCopyValueInst, LookThrough)
2062+
CONSTANT_TRANSLATION(DropDeinitInst, LookThrough)
20612063

20622064
//===---
20632065
// Store
@@ -2154,7 +2156,6 @@ CONSTANT_TRANSLATION(ValueToBridgeObjectInst, Unhandled)
21542156
CONSTANT_TRANSLATION(WeakCopyValueInst, Unhandled)
21552157
CONSTANT_TRANSLATION(StrongCopyWeakValueInst, Unhandled)
21562158
CONSTANT_TRANSLATION(StrongCopyUnmanagedValueInst, Unhandled)
2157-
CONSTANT_TRANSLATION(DropDeinitInst, Unhandled)
21582159
CONSTANT_TRANSLATION(IsUniqueInst, Unhandled)
21592160
CONSTANT_TRANSLATION(LoadUnownedInst, Unhandled)
21602161
CONSTANT_TRANSLATION(ValueMetatypeInst, Unhandled)

test/Concurrency/transfernonsendable_instruction_matching.sil

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ final class SendableKlass : Sendable {}
2121
@_moveOnly
2222
struct NonSendableMoveOnlyStruct {
2323
var ns: NonSendableKlass
24+
25+
deinit
2426
}
2527

2628
struct NonSendableStruct {
@@ -41,6 +43,7 @@ sil @transferIndirect : $@convention(thin) @async <τ_0_0> (@in_guaranteed τ_0_
4143
sil @useIndirect : $@convention(thin) <τ_0_0> (@in_guaranteed τ_0_0) -> ()
4244

4345
sil @constructMoveOnlyStruct : $@convention(thin) () -> @owned NonSendableMoveOnlyStruct
46+
sil @transferMoveOnlyStruct : $@convention(thin) @async (@guaranteed NonSendableMoveOnlyStruct) -> ()
4447

4548
enum FakeOptional<T> {
4649
case none
@@ -884,3 +887,12 @@ bb0:
884887
%9999 = tuple ()
885888
return %9999 : $()
886889
}
890+
891+
sil [ossa] @drop_deinit_test : $@convention(thin) @async (@owned NonSendableMoveOnlyStruct) -> () {
892+
bb0(%0 : @owned $NonSendableMoveOnlyStruct):
893+
%1 = drop_deinit %0 : $NonSendableMoveOnlyStruct
894+
destroy_value %1 : $NonSendableMoveOnlyStruct
895+
%9999 = tuple ()
896+
return %9999 : $()
897+
}
898+

0 commit comments

Comments
 (0)