Skip to content

Commit 861d967

Browse files
committed
[region-isolation] Add support for value_to_bridge_object.
1 parent 9b9102b commit 861d967

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

lib/SILOptimizer/Analysis/RegionAnalysis.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,7 @@ static bool isStaticallyLookThroughInst(SILInstruction *inst) {
220220
case SILInstructionKind::UnownedCopyValueInst:
221221
case SILInstructionKind::UnownedToRefInst:
222222
case SILInstructionKind::UpcastInst:
223+
case SILInstructionKind::ValueToBridgeObjectInst:
223224
return true;
224225
}
225226
}
@@ -2091,6 +2092,7 @@ CONSTANT_TRANSLATION(RefToUnownedInst, LookThrough)
20912092
CONSTANT_TRANSLATION(UnownedToRefInst, LookThrough)
20922093
CONSTANT_TRANSLATION(UnownedCopyValueInst, LookThrough)
20932094
CONSTANT_TRANSLATION(DropDeinitInst, LookThrough)
2095+
CONSTANT_TRANSLATION(ValueToBridgeObjectInst, LookThrough)
20942096

20952097
//===---
20962098
// Store
@@ -2185,7 +2187,6 @@ CONSTANT_TRANSLATION(DeallocExistentialBoxInst, Ignored)
21852187
CONSTANT_TRANSLATION(ObjCToThickMetatypeInst, Unhandled)
21862188
CONSTANT_TRANSLATION(ObjCMetatypeToObjectInst, Unhandled)
21872189
CONSTANT_TRANSLATION(ObjCExistentialMetatypeToObjectInst, Unhandled)
2188-
CONSTANT_TRANSLATION(ValueToBridgeObjectInst, Unhandled)
21892190
CONSTANT_TRANSLATION(WeakCopyValueInst, Unhandled)
21902191
CONSTANT_TRANSLATION(StrongCopyWeakValueInst, Unhandled)
21912192
CONSTANT_TRANSLATION(StrongCopyUnmanagedValueInst, Unhandled)

test/Concurrency/transfernonsendable_instruction_matching.sil

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -989,4 +989,22 @@ bb0:
989989

990990
%9999 = tuple ()
991991
return %9999 : $()
992-
}
992+
}
993+
994+
sil [ossa] @value_to_bridge_object_test : $@convention(thin) @async () -> () {
995+
bb0:
996+
%0 = function_ref @constructNonSendableKlass : $@convention(thin) () -> @owned NonSendableKlass
997+
%1 = apply %0() : $@convention(thin) () -> @owned NonSendableKlass
998+
999+
1000+
%f = function_ref @transferNonSendableKlass : $@convention(thin) @async (@guaranteed NonSendableKlass) -> ()
1001+
apply [caller_isolation=nonisolated] [callee_isolation=global_actor] %f(%1) : $@convention(thin) @async (@guaranteed NonSendableKlass) -> ()
1002+
1003+
%2 = value_to_bridge_object %1 : $NonSendableKlass
1004+
%3 = copy_value %2 : $Builtin.BridgeObject
1005+
destroy_value %3 : $Builtin.BridgeObject
1006+
destroy_value %1 : $NonSendableKlass
1007+
1008+
%9999 = tuple ()
1009+
return %9999 : $()
1010+
}

0 commit comments

Comments
 (0)