Skip to content

Commit 608493c

Browse files
committed
[region-isolation] Move computation of SILIsolationInfo for a SILFunctionArgument onto SILIsolationInfo::get(...).
1 parent c2dcdb9 commit 608493c

File tree

3 files changed

+27
-32
lines changed

3 files changed

+27
-32
lines changed

include/swift/SILOptimizer/Utils/PartitionUtils.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,9 @@ class SILIsolationInfo {
257257
/// Attempt to infer the isolation region info for \p inst.
258258
static SILIsolationInfo get(SILInstruction *inst);
259259

260+
/// Attempt to infer the isolation region info for \p arg.
261+
static SILIsolationInfo get(SILFunctionArgument *arg);
262+
260263
bool operator==(const SILIsolationInfo &other) const {
261264
if (getKind() != other.getKind())
262265
return false;

lib/SILOptimizer/Analysis/RegionAnalysis.cpp

Lines changed: 1 addition & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -3383,39 +3383,8 @@ TrackableValue RegionAnalysisValueMap::getTrackableValue(
33833383
if (auto *fArg =
33843384
dyn_cast<SILFunctionArgument>(iter.first->first.getValue())) {
33853385
if (!isTransferrableFunctionArgument(fArg)) {
3386-
auto *self =
3387-
iter.first->first.getValue()->getFunction()->maybeGetSelfArgument();
3388-
NominalTypeDecl *nomDecl = nullptr;
3389-
if (self &&
3390-
((nomDecl = self->getType().getNominalOrBoundGenericNominal()))) {
3391-
iter.first->getSecond().mergeIsolationRegionInfo(
3392-
SILIsolationInfo::getActorIsolated(nomDecl));
3393-
return {iter.first->first, iter.first->second};
3394-
}
3395-
3396-
// See if we can infer actor isolation from our fArg's value decl.
3397-
//
3398-
// This handles functions generated by SILGen with global actors, but
3399-
// doesn't handle SIL written global actors since function arguments
3400-
// parsed from SIL do not have associated var decls.
3401-
if (auto *decl = fArg->getDecl()) {
3402-
auto isolation =
3403-
swift::getActorIsolation(const_cast<ValueDecl *>(decl));
3404-
if (!bool(isolation)) {
3405-
if (auto *dc = decl->getDeclContext()) {
3406-
isolation = swift::getActorIsolationOfContext(dc);
3407-
}
3408-
}
3409-
3410-
if (isolation.isActorIsolated()) {
3411-
iter.first->getSecond().mergeIsolationRegionInfo(
3412-
SILIsolationInfo::getActorIsolated(isolation));
3413-
return {iter.first->first, iter.first->second};
3414-
}
3415-
}
3416-
34173386
iter.first->getSecond().mergeIsolationRegionInfo(
3418-
SILIsolationInfo::getTaskIsolated(fArg));
3387+
SILIsolationInfo::get(fArg));
34193388
return {iter.first->first, iter.first->second};
34203389
}
34213390
}

lib/SILOptimizer/Utils/PartitionUtils.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,3 +63,26 @@ SILIsolationInfo SILIsolationInfo::get(SILInstruction *inst) {
6363
// cannot cross an isolation domain.
6464
return SILIsolationInfo();
6565
}
66+
67+
SILIsolationInfo SILIsolationInfo::get(SILFunctionArgument *arg) {
68+
if (auto *self = arg->getFunction()->maybeGetSelfArgument()) {
69+
if (auto *nomDecl = self->getType().getNominalOrBoundGenericNominal()) {
70+
return SILIsolationInfo::getActorIsolated(nomDecl);
71+
}
72+
}
73+
74+
if (auto *decl = arg->getDecl()) {
75+
auto isolation = swift::getActorIsolation(const_cast<ValueDecl *>(decl));
76+
if (!bool(isolation)) {
77+
if (auto *dc = decl->getDeclContext()) {
78+
isolation = swift::getActorIsolationOfContext(dc);
79+
}
80+
}
81+
82+
if (isolation.isActorIsolated()) {
83+
return SILIsolationInfo::getActorIsolated(isolation);
84+
}
85+
}
86+
87+
return SILIsolationInfo::getTaskIsolated(arg);
88+
}

0 commit comments

Comments
 (0)