Skip to content

Commit dd156f3

Browse files
authored
Merge pull request #72366 from gottesmm/pr-12358c24eb38a655a2275f9b947625a9c72ab016
[region-isolation] Fix assert.
2 parents 7b1f41b + 9fe64cd commit dd156f3

File tree

2 files changed

+26
-3
lines changed

2 files changed

+26
-3
lines changed

lib/SILOptimizer/Analysis/RegionAnalysis.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2018,7 +2018,7 @@ class PartitionOpTranslator {
20182018
}
20192019

20202020
void translateSILLookThrough(SingleValueInstruction *svi) {
2021-
assert(svi->getNumOperands() == 1);
2021+
assert(svi->getNumRealOperands() == 1);
20222022
auto srcID = tryToTrackValue(svi->getOperand(0));
20232023
auto destID = tryToTrackValue(svi);
20242024
assert(((!destID || !srcID) || destID->getID() == srcID->getID()) &&
@@ -2261,7 +2261,7 @@ class PartitionOpTranslator {
22612261
return;
22622262

22632263
case TranslationSemantics::LookThrough:
2264-
assert(inst->getNumOperands() == 1);
2264+
assert(inst->getNumRealOperands() == 1);
22652265
assert((isStaticallyLookThroughInst(inst) ||
22662266
isLookThroughIfResultNonSendable(inst) ||
22672267
isLookThroughIfOperandNonSendable(inst) ||

test/Concurrency/transfernonsendable_instruction_matching.sil

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,12 @@ case none
7373
case some(T)
7474
}
7575

76+
open class ParentClass {
77+
}
78+
class ChildClass : ParentClass {}
79+
80+
sil @copyParentClass : $@convention(thin) (@guaranteed ParentClass) -> @owned ParentClass
81+
7682
/////////////////
7783
// MARK: Tests //
7884
/////////////////
@@ -1485,7 +1491,7 @@ bb0:
14851491
// Now transfer %addr and use it.
14861492
apply [caller_isolation=nonisolated] [callee_isolation=global_actor] %f<NonSendableKlass>(%addr) : $@convention(thin) @async <τ_0_0> (@in_guaranteed τ_0_0) -> () // expected-warning {{transferring value of non-Sendable type 'NonSendableKlass' from nonisolated context to global actor '<null>'-isolated context; later accesses could race}}
14871493
%f2 = function_ref @useIndirect : $@convention(thin) <τ_0_0> (@in_guaranteed τ_0_0) -> ()
1488-
apply %f2<NonSendableKlass>(%addr) : $@convention(thin) <τ_0_0> (@in_guaranteed τ_0_0) -> () // expected-note {{access here could race}}
1494+
apply %f2<NonSendableKlass>(%addr) : $@convention(thin) <τ_0_0> (@in_guaranteed τ_0_0) -> () // expected-note {{access here could race}}
14891495

14901496
dealloc_pack %pack2 : $*Pack{NonSendableKlass, repeat each T}
14911497
dealloc_pack %pack : $*Pack{NonSendableKlass, repeat each T}
@@ -1649,3 +1655,20 @@ bb0(%arg : $Builtin.Word):
16491655
%9999 = tuple ()
16501656
return %9999 : $()
16511657
}
1658+
1659+
sil hidden [ossa] @test_unconditional_checked_cast : $@convention(method) (@guaranteed ChildClass) -> @owned ChildClass {
1660+
bb0(%0 : @guaranteed $ChildClass):
1661+
debug_value %0 : $ChildClass, let, name "self", argno 1, implicit
1662+
%2 = copy_value %0 : $ChildClass
1663+
%3 = upcast %2 : $ChildClass to $ParentClass
1664+
%4 = function_ref @copyParentClass : $@convention(thin) (@guaranteed ParentClass) -> @owned ParentClass
1665+
%5 = apply %4(%3) : $@convention(thin) (@guaranteed ParentClass) -> @owned ParentClass
1666+
%6 = unchecked_ref_cast %5 : $ParentClass to $ChildClass
1667+
%7 = unconditional_checked_cast %6 : $ChildClass to @dynamic_self ChildClass
1668+
%8 = move_value [lexical] [var_decl] %7 : $ChildClass
1669+
debug_value %8 : $ChildClass, let, name "copy"
1670+
destroy_value %3 : $ParentClass
1671+
%11 = copy_value %8 : $ChildClass
1672+
destroy_value %8 : $ChildClass
1673+
return %11 : $ChildClass
1674+
}

0 commit comments

Comments
 (0)