@@ -576,6 +576,32 @@ static bool isTransferrableFunctionArgument(SILFunctionArgument *arg) {
576576 return arg->isTransferring ();
577577}
578578
579+ // ===----------------------------------------------------------------------===//
580+ // MARK: ValueIsolationRegionInfo
581+ // ===----------------------------------------------------------------------===//
582+
583+ void ValueIsolationRegionInfo::printForDiagnostics (
584+ llvm::raw_ostream &os) const {
585+ switch (Kind (*this )) {
586+ case Unknown:
587+ llvm::report_fatal_error (" Printing unknown for diagnostics?!" );
588+ return ;
589+ case Disconnected:
590+ os << " disconnected" ;
591+ return ;
592+ case Actor:
593+ if (hasActorIsolation () && getActorIsolation ()) {
594+ getActorIsolation ()->printForDiagnostics (os);
595+ } else {
596+ os << " actor-isolated" ;
597+ }
598+ return ;
599+ case Task:
600+ os << " task-isolated" ;
601+ return ;
602+ }
603+ }
604+
579605// ===----------------------------------------------------------------------===//
580606// MARK: TrackableValue
581607// ===----------------------------------------------------------------------===//
@@ -3093,6 +3119,17 @@ void RegionAnalysisFunctionInfo::runDataflow() {
30933119// MARK: Value Map
30943120// ===----------------------------------------------------------------------===//
30953121
3122+ SILInstruction *RegionAnalysisValueMap::maybeGetActorIntroducingInst (
3123+ Element trackableValueID) const {
3124+ if (auto value = getValueForId (trackableValueID)) {
3125+ auto rep = value->getRepresentative ();
3126+ if (rep.hasRegionIntroducingInst ())
3127+ return rep.getActorRegionIntroducingInst ();
3128+ }
3129+
3130+ return nullptr ;
3131+ }
3132+
30963133std::optional<TrackableValue>
30973134RegionAnalysisValueMap::getValueForId (TrackableValueID id) const {
30983135 auto iter = stateIndexToEquivalenceClass.find (id);
@@ -3281,18 +3318,40 @@ TrackableValue RegionAnalysisValueMap::getTrackableValue(
32813318 }
32823319
32833320 // See if we have a non-transferring argument from a function. In such a case,
3284- // mark the value as task isolated.
3321+ // mark the value as actor isolated if self is actor isolated and task
3322+ // isolated otherwise.
32853323 if (auto *fArg =
32863324 dyn_cast<SILFunctionArgument>(iter.first ->first .getValue ())) {
32873325 if (!isTransferrableFunctionArgument (fArg )) {
3288- iter.first ->getSecond ().mergeIsolationRegionInfo (
3289- ValueIsolationRegionInfo::getTaskIsolated (fArg ));
3326+ auto *self =
3327+ iter.first ->first .getValue ()->getFunction ()->maybeGetSelfArgument ();
3328+ NominalTypeDecl *nomDecl = nullptr ;
3329+ if (self &&
3330+ ((nomDecl = self->getType ().getNominalOrBoundGenericNominal ()))) {
3331+ iter.first ->getSecond ().mergeIsolationRegionInfo (
3332+ ValueIsolationRegionInfo::getActorIsolated (nomDecl));
3333+ } else {
3334+ iter.first ->getSecond ().mergeIsolationRegionInfo (
3335+ ValueIsolationRegionInfo::getTaskIsolated (fArg ));
3336+ }
32903337 }
32913338 }
32923339
32933340 return {iter.first ->first , iter.first ->second };
32943341}
32953342
3343+ std::optional<TrackableValue>
3344+ RegionAnalysisValueMap::getTrackableValueForActorIntroducingInst (
3345+ SILInstruction *inst) const {
3346+ auto *self = const_cast <RegionAnalysisValueMap *>(this );
3347+ auto iter = self->equivalenceClassValuesToState .find (inst);
3348+ if (iter == self->equivalenceClassValuesToState .end ())
3349+ return {};
3350+
3351+ // Otherwise, we need to compute our flags.
3352+ return {{iter->first , iter->second }};
3353+ }
3354+
32963355std::optional<TrackableValue>
32973356RegionAnalysisValueMap::tryToTrackValue (SILValue value) const {
32983357 auto state = getTrackableValue (value);
0 commit comments