@@ -415,6 +415,12 @@ SILIsolationInfo SILIsolationInfo::get(SILInstruction *inst) {
415415 return SILIsolationInfo::getGlobalActorIsolated (SILValue (), selfASTType);
416416 }
417417
418+ if (auto *fArg = dyn_cast<SILFunctionArgument>(actualIsolatedValue)) {
419+ if (auto info =
420+ SILIsolationInfo::getActorInstanceIsolated (fArg , fArg ))
421+ return info;
422+ }
423+
418424 // TODO: We really should be doing this based off of an Operand. Then
419425 // we would get the SILValue() for the first element. Today this can
420426 // only mess up isolation history.
@@ -449,7 +455,21 @@ SILIsolationInfo SILIsolationInfo::get(SILInstruction *inst) {
449455 }
450456 }
451457
458+ // Ok, we found an actor instance. Look for our actual isolated value.
452459 if (actorInstance) {
460+ if (auto actualIsolatedValue =
461+ ActorInstance::getForValue (actorInstance)) {
462+ // See if we have a function parameter. In that case, we want to see
463+ // if we have a function argument. In such a case, we need to use
464+ // the right parameter and the var decl.
465+ if (auto *fArg = dyn_cast<SILFunctionArgument>(
466+ actualIsolatedValue.getValue ())) {
467+ if (auto info =
468+ SILIsolationInfo::getActorInstanceIsolated (pai, fArg ))
469+ return info;
470+ }
471+ }
472+
453473 return SILIsolationInfo::getActorInstanceIsolated (
454474 pai, actorInstance, actorIsolation.getActor ());
455475 }
@@ -480,6 +500,14 @@ SILIsolationInfo SILIsolationInfo::get(SILInstruction *inst) {
480500 if (auto *rei = dyn_cast<RefElementAddrInst>(inst)) {
481501 auto varIsolation = swift::getActorIsolation (rei->getField ());
482502
503+ if (auto instance = ActorInstance::getForValue (rei->getOperand ())) {
504+ if (auto *fArg = llvm::dyn_cast_or_null<SILFunctionArgument>(
505+ instance.maybeGetValue ())) {
506+ if (auto info = SILIsolationInfo::getActorInstanceIsolated (rei, fArg ))
507+ return info.withUnsafeNonIsolated (varIsolation.isNonisolatedUnsafe ());
508+ }
509+ }
510+
483511 auto *nomDecl =
484512 rei->getOperand ()->getType ().getNominalOrBoundGenericNominal ();
485513
@@ -868,11 +896,11 @@ SILIsolationInfo SILIsolationInfo::get(SILArgument *arg) {
868896
869897 // Before we do anything further, see if we have an isolated parameter. This
870898 // handles isolated self and specifically marked isolated.
871- if (auto *isolatedArg = fArg ->getFunction ()->maybeGetIsolatedArgument ()) {
899+ if (auto *isolatedArg = llvm::cast_or_null<SILFunctionArgument>(
900+ fArg ->getFunction ()->maybeGetIsolatedArgument ())) {
872901 auto astType = isolatedArg->getType ().getASTType ();
873902 if (auto *nomDecl = astType->lookThroughAllOptionalTypes ()->getAnyActor ()) {
874- return SILIsolationInfo::getActorInstanceIsolated (fArg , isolatedArg,
875- nomDecl);
903+ return SILIsolationInfo::getActorInstanceIsolated (fArg , isolatedArg);
876904 }
877905 }
878906
@@ -1017,10 +1045,10 @@ void SILIsolationInfo::print(llvm::raw_ostream &os) const {
10171045 }
10181046}
10191047
1020- bool SILIsolationInfo::hasSameIsolation (ActorIsolation actorIsolation ) const {
1048+ bool SILIsolationInfo::hasSameIsolation (ActorIsolation other ) const {
10211049 if (getKind () != Kind::Actor)
10221050 return false ;
1023- return getActorIsolation () == actorIsolation ;
1051+ return getActorIsolation () == other ;
10241052}
10251053
10261054bool SILIsolationInfo::hasSameIsolation (const SILIsolationInfo &other) const {
@@ -1362,6 +1390,25 @@ SILDynamicMergedIsolationInfo::merge(SILIsolationInfo other) const {
13621390 return {other};
13631391}
13641392
1393+ void ActorInstance::print (llvm::raw_ostream &os) const {
1394+ os << " Actor Instance. Kind: " ;
1395+ switch (getKind ()) {
1396+ case Kind::Value:
1397+ os << " Value." ;
1398+ break ;
1399+ case Kind::ActorAccessorInit:
1400+ os << " ActorAccessorInit." ;
1401+ break ;
1402+ case Kind::CapturedActorSelf:
1403+ os << " CapturedActorSelf." ;
1404+ break ;
1405+ }
1406+
1407+ if (auto value = maybeGetValue ()) {
1408+ os << " Value: " << value;
1409+ };
1410+ }
1411+
13651412// ===----------------------------------------------------------------------===//
13661413// MARK: Tests
13671414// ===----------------------------------------------------------------------===//
0 commit comments