Skip to content

Commit 38dd567

Browse files
committed
[region-isolation] Add support for bridge_object_to_word.
1 parent d10346b commit 38dd567

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
@@ -2105,6 +2105,7 @@ CONSTANT_TRANSLATION(DebugStepInst, Ignored)
21052105
// Instructions that only require that the region of the value be live:
21062106
CONSTANT_TRANSLATION(FixLifetimeInst, Require)
21072107
CONSTANT_TRANSLATION(ClassifyBridgeObjectInst, Require)
2108+
CONSTANT_TRANSLATION(BridgeObjectToWordInst, Require)
21082109

21092110
//===---
21102111
// Terminators
@@ -2146,7 +2147,6 @@ CONSTANT_TRANSLATION(DeallocExistentialBoxInst, Ignored)
21462147
// Unhandled Instructions
21472148
//
21482149

2149-
CONSTANT_TRANSLATION(BridgeObjectToWordInst, Unhandled)
21502150
CONSTANT_TRANSLATION(ObjCToThickMetatypeInst, Unhandled)
21512151
CONSTANT_TRANSLATION(ObjCMetatypeToObjectInst, Unhandled)
21522152
CONSTANT_TRANSLATION(ObjCExistentialMetatypeToObjectInst, Unhandled)

test/Concurrency/transfernonsendable_instruction_matching.sil

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -868,3 +868,19 @@ bb0:
868868
%9999 = tuple ()
869869
return %9999 : $()
870870
}
871+
872+
sil [ossa] @bridge_object_to_word_test : $@convention(thin) @async () -> () {
873+
bb0:
874+
%constructFn = function_ref @constructNonSendableKlass : $@convention(thin) () -> @owned NonSendableKlass
875+
%value = apply %constructFn() : $@convention(thin) () -> @owned NonSendableKlass
876+
877+
%transferNonSendableKlass = function_ref @transferNonSendableKlass : $@convention(thin) @async (@guaranteed NonSendableKlass) -> ()
878+
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}}
879+
880+
%value2 = unchecked_ref_cast %value : $NonSendableKlass to $Builtin.BridgeObject
881+
%1 = bridge_object_to_word %value2 : $Builtin.BridgeObject to $Builtin.Word // expected-note {{access here could race}}
882+
destroy_value %value2 : $Builtin.BridgeObject
883+
884+
%9999 = tuple ()
885+
return %9999 : $()
886+
}

0 commit comments

Comments
 (0)