Skip to content

Commit 1bb65d8

Browse files
authored
Merge pull request #85165 from gottesmm/rdar153207557
[sil] Change SILIsolationInfo inference for classmethods to use SILDeclRef instead of using the AST directly.
2 parents 552b665 + 91444dd commit 1bb65d8

File tree

5 files changed

+848
-216
lines changed

5 files changed

+848
-216
lines changed

include/swift/SIL/SILArgument.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,12 @@ class SILFunctionArgument : public SILArgument {
429429
/// Returns true if this SILFunctionArgument is an 'inout sending' parameter.
430430
bool isInOutSending() const;
431431

432+
bool isIsolated() const {
433+
return !isIndirectResult() && !isIndirectErrorResult() &&
434+
getKnownParameterInfo().getOptions().contains(
435+
SILParameterInfo::Isolated);
436+
}
437+
432438
Lifetime getLifetime() const {
433439
return getType()
434440
.getLifetime(*getFunction())

include/swift/SILOptimizer/Utils/SILIsolationInfo.h

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,16 @@ class ActorInstance {
5353
/// function)... so we just use an artificial ActorInstance to represent
5454
/// self in this case.
5555
CapturedActorSelf = 0x2,
56+
57+
/// An actor instance in an async allocating init where we are going to
58+
/// allocate the actual actor internally. This is considered to be isolated
59+
/// to the actor instance.
60+
ActorAsyncAllocatingInit = 0x3,
5661
};
5762

58-
/// Set to (SILValue(), $KIND) if we have an ActorAccessorInit|CapturedSelf.
59-
/// Is null if we have (SILValue(), Kind::Value).
63+
/// Set to (SILValue(), $KIND) if we have an
64+
/// ActorAccessorInit|CapturedSelf|ActorAsyncAllocatingInit. Is null if we
65+
/// have (SILValue(), Kind::Value).
6066
llvm::PointerIntPair<SILValue, 2> value;
6167

6268
ActorInstance(SILValue value, Kind kind)
@@ -94,6 +100,12 @@ class ActorInstance {
94100
return ActorInstance(SILValue(), Kind::CapturedActorSelf);
95101
}
96102

103+
/// See Kind::ActorAsyncAllocatingInit for explanation on what a
104+
/// ActorAsyncAllocatingInit is.
105+
static ActorInstance getForActorAsyncAllocatingInit() {
106+
return ActorInstance(SILValue(), Kind::ActorAsyncAllocatingInit);
107+
}
108+
97109
explicit operator bool() const { return bool(value.getOpaqueValue()); }
98110

99111
Kind getKind() const { return Kind(value.getInt()); }
@@ -117,6 +129,10 @@ class ActorInstance {
117129
return getKind() == Kind::CapturedActorSelf;
118130
}
119131

132+
bool isActorAsyncAllocatingInit() const {
133+
return getKind() == Kind::ActorAsyncAllocatingInit;
134+
}
135+
120136
bool operator==(const ActorInstance &other) const {
121137
// If both are null, return true.
122138
if (!bool(*this) && !bool(other))
@@ -132,6 +148,7 @@ class ActorInstance {
132148
return getValue() == other.getValue();
133149
case Kind::ActorAccessorInit:
134150
case Kind::CapturedActorSelf:
151+
case Kind::ActorAsyncAllocatingInit:
135152
return true;
136153
}
137154
}

0 commit comments

Comments
 (0)