Skip to content

Commit c0e9178

Browse files
committed
[SILOptimizer] Open existential actors for hop_to_executor as part of the
LowerHopToActor pass instead of during SILGen.
1 parent f15ef1a commit c0e9178

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

lib/SILGen/SILGenProlog.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1507,15 +1507,6 @@ SILValue SILGenFunction::emitLoadActorExecutor(SILLocation loc,
15071507
else
15081508
actorV = actor.borrow(*this, loc).getValue();
15091509

1510-
// Open an existential actor type.
1511-
CanType actorType = actor.getType().getASTType();
1512-
if (actorType->isExistentialType()) {
1513-
actorType = OpenedArchetypeType::get(
1514-
actorType, F.getGenericSignature())->getCanonicalType();
1515-
SILType loweredActorType = getLoweredType(actorType);
1516-
actorV = B.createOpenExistentialRef(loc, actorV, loweredActorType);
1517-
}
1518-
15191510
// For now, we just want to emit a hop_to_executor directly to the
15201511
// actor; LowerHopToActor will add the emission logic necessary later.
15211512
return actorV;

lib/SILOptimizer/Mandatory/LowerHopToActor.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,16 @@ SILValue LowerHopToActor::emitGetExecutor(SILBuilderWithScope &B,
204204
assert(req && "Concurrency library broken");
205205
SILDeclRef fn(req, SILDeclRef::Kind::Func);
206206

207+
// FIXME: Handle optional
208+
209+
// Open an existential actor type.
210+
if (actorType->isExistentialType()) {
211+
actorType = OpenedArchetypeType::get(
212+
actorType, F->getGenericSignature())->getCanonicalType();
213+
SILType loweredActorType = F->getLoweredType(actorType);
214+
actor = B.createOpenExistentialRef(loc, actor, loweredActorType);
215+
}
216+
207217
auto actorConf = module->lookupConformance(actorType, actorProtocol);
208218
assert(actorConf &&
209219
"hop_to_executor with actor that doesn't conform to Actor or DistributedActor");

test/SILGen/isolated_parameters.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ public func testClosureWithIsolatedParam() {
3131
public func testIsolatedExistential(_ a: isolated Actor) async {
3232
// CHECK: [[ACTOR_COPY:%.*]] = copy_value [[ACTOR]] : $any Actor
3333
// CHECK: [[ACTOR_BORROW:%.*]] = begin_borrow [[ACTOR_COPY]] : $any Actor
34-
// CHECK: [[ACTOR_OPENED:%.*]] = open_existential_ref [[ACTOR_BORROW]] : $any Actor to $@opened("{{.*}}", any Actor) Self
35-
// CHECK: hop_to_executor [[ACTOR_OPENED]] : $@opened("{{.*}}", any Actor) Self
34+
// CHECK: hop_to_executor [[ACTOR_BORROW]] : $any Actor
3635
// CHECK: return
3736
}

0 commit comments

Comments
 (0)