Skip to content

Commit dadc16b

Browse files
committed
[region-isolation] Add support for classify_bridge_object.
1 parent 872edea commit dadc16b

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

lib/SILOptimizer/Analysis/RegionAnalysis.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2102,6 +2102,7 @@ CONSTANT_TRANSLATION(DebugStepInst, Ignored)
21022102

21032103
// Instructions that only require that the region of the value be live:
21042104
CONSTANT_TRANSLATION(FixLifetimeInst, Require)
2105+
CONSTANT_TRANSLATION(ClassifyBridgeObjectInst, Require)
21052106

21062107
//===---
21072108
// Terminators
@@ -2147,7 +2148,6 @@ CONSTANT_TRANSLATION(BridgeObjectToWordInst, Unhandled)
21472148
CONSTANT_TRANSLATION(ObjCToThickMetatypeInst, Unhandled)
21482149
CONSTANT_TRANSLATION(ObjCMetatypeToObjectInst, Unhandled)
21492150
CONSTANT_TRANSLATION(ObjCExistentialMetatypeToObjectInst, Unhandled)
2150-
CONSTANT_TRANSLATION(ClassifyBridgeObjectInst, Unhandled)
21512151
CONSTANT_TRANSLATION(ValueToBridgeObjectInst, Unhandled)
21522152
CONSTANT_TRANSLATION(UnownedCopyValueInst, Unhandled)
21532153
CONSTANT_TRANSLATION(WeakCopyValueInst, Unhandled)

test/Concurrency/transfernonsendable_instruction_matching.sil

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -852,3 +852,19 @@ bb0:
852852
%9999 = tuple ()
853853
return %9999 : $()
854854
}
855+
856+
sil [ossa] @classify_bridge_object_test : $@convention(thin) @async () -> () {
857+
bb0:
858+
%constructFn = function_ref @constructNonSendableKlass : $@convention(thin) () -> @owned NonSendableKlass
859+
%value = apply %constructFn() : $@convention(thin) () -> @owned NonSendableKlass
860+
861+
%transferNonSendableKlass = function_ref @transferNonSendableKlass : $@convention(thin) @async (@guaranteed NonSendableKlass) -> ()
862+
apply [caller_isolation=nonisolated] [callee_isolation=global_actor] %transferNonSendableKlass(%value) : $@convention(thin) @async (@guaranteed NonSendableKlass) -> () // expected-warning {{passing argument of non-sendable type 'NonSendableKlass' from nonisolated context to global actor '<null>'-isolated context at this call site could yield a race with accesses later in this function}}
863+
864+
%value2 = unchecked_ref_cast %value : $NonSendableKlass to $Builtin.BridgeObject
865+
%1 = classify_bridge_object %value2 : $Builtin.BridgeObject // expected-note {{access here could race}}
866+
destroy_value %value2 : $Builtin.BridgeObject
867+
868+
%9999 = tuple ()
869+
return %9999 : $()
870+
}

0 commit comments

Comments
 (0)