@@ -415,6 +415,12 @@ SILIsolationInfo SILIsolationInfo::get(SILInstruction *inst) {
415
415
return SILIsolationInfo::getGlobalActorIsolated (SILValue (), selfASTType);
416
416
}
417
417
418
+ if (auto *fArg = dyn_cast<SILFunctionArgument>(actualIsolatedValue)) {
419
+ if (auto info =
420
+ SILIsolationInfo::getActorInstanceIsolated (fArg , fArg ))
421
+ return info;
422
+ }
423
+
418
424
// TODO: We really should be doing this based off of an Operand. Then
419
425
// we would get the SILValue() for the first element. Today this can
420
426
// only mess up isolation history.
@@ -449,7 +455,21 @@ SILIsolationInfo SILIsolationInfo::get(SILInstruction *inst) {
449
455
}
450
456
}
451
457
458
+ // Ok, we found an actor instance. Look for our actual isolated value.
452
459
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
+
453
473
return SILIsolationInfo::getActorInstanceIsolated (
454
474
pai, actorInstance, actorIsolation.getActor ());
455
475
}
@@ -480,6 +500,14 @@ SILIsolationInfo SILIsolationInfo::get(SILInstruction *inst) {
480
500
if (auto *rei = dyn_cast<RefElementAddrInst>(inst)) {
481
501
auto varIsolation = swift::getActorIsolation (rei->getField ());
482
502
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
+
483
511
auto *nomDecl =
484
512
rei->getOperand ()->getType ().getNominalOrBoundGenericNominal ();
485
513
@@ -868,11 +896,11 @@ SILIsolationInfo SILIsolationInfo::get(SILArgument *arg) {
868
896
869
897
// Before we do anything further, see if we have an isolated parameter. This
870
898
// 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 ())) {
872
901
auto astType = isolatedArg->getType ().getASTType ();
873
902
if (auto *nomDecl = astType->lookThroughAllOptionalTypes ()->getAnyActor ()) {
874
- return SILIsolationInfo::getActorInstanceIsolated (fArg , isolatedArg,
875
- nomDecl);
903
+ return SILIsolationInfo::getActorInstanceIsolated (fArg , isolatedArg);
876
904
}
877
905
}
878
906
@@ -1017,10 +1045,10 @@ void SILIsolationInfo::print(llvm::raw_ostream &os) const {
1017
1045
}
1018
1046
}
1019
1047
1020
- bool SILIsolationInfo::hasSameIsolation (ActorIsolation actorIsolation ) const {
1048
+ bool SILIsolationInfo::hasSameIsolation (ActorIsolation other ) const {
1021
1049
if (getKind () != Kind::Actor)
1022
1050
return false ;
1023
- return getActorIsolation () == actorIsolation ;
1051
+ return getActorIsolation () == other ;
1024
1052
}
1025
1053
1026
1054
bool SILIsolationInfo::hasSameIsolation (const SILIsolationInfo &other) const {
@@ -1362,6 +1390,25 @@ SILDynamicMergedIsolationInfo::merge(SILIsolationInfo other) const {
1362
1390
return {other};
1363
1391
}
1364
1392
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
+
1365
1412
// ===----------------------------------------------------------------------===//
1366
1413
// MARK: Tests
1367
1414
// ===----------------------------------------------------------------------===//
0 commit comments