Skip to content

Commit 810e2cf

Browse files
committed
[Distributed] Fix type lowering for Builtin.initializeDistributedRemoteActor
1 parent 05645a1 commit 810e2cf

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

lib/IRGen/GenBuiltin.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ void irgen::emitBuiltinCall(IRGenFunction &IGF, const BuiltinInfo &Builtin,
390390

391391
if (Builtin.ID == BuiltinValueKind::InitializeDistributedRemoteActor) {
392392
auto actorMetatype = args.claimNext();
393-
emitDistributedActorInitializeRemote(IGF, actorMetatype, out);
393+
emitDistributedActorInitializeRemote(IGF, resultType, actorMetatype, out);
394394
return;
395395
}
396396

lib/IRGen/GenDistributed.cpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include "GenDistributed.h"
1818

1919
#include "BitPatternBuilder.h"
20+
#include "ClassTypeInfo.h"
2021
#include "ExtraInhabitants.h"
2122
#include "GenProto.h"
2223
#include "GenType.h"
@@ -32,7 +33,12 @@ using namespace swift;
3233
using namespace irgen;
3334

3435
llvm::Value *irgen::emitDistributedActorInitializeRemote(
35-
IRGenFunction &IGF, llvm::Value *actorMetatype, Explosion &out) {
36+
IRGenFunction &IGF, SILType selfType, llvm::Value *actorMetatype, Explosion &out) {
37+
auto &classTI = IGF.getTypeInfo(selfType).as<ClassTypeInfo>();
38+
auto &classLayout = classTI.getClassLayout(IGF.IGM, selfType,
39+
/*forBackwardDeployment=*/false);
40+
llvm::Type *destType = classLayout.getType()->getPointerTo();
41+
3642
auto fn = IGF.IGM.getDistributedActorInitializeRemoteFn();
3743
actorMetatype =
3844
IGF.Builder.CreateBitCast(actorMetatype, IGF.IGM.TypeMetadataPtrTy);
@@ -41,9 +47,11 @@ llvm::Value *irgen::emitDistributedActorInitializeRemote(
4147
call->setCallingConv(IGF.IGM.SwiftCC);
4248
call->setDoesNotThrow();
4349

44-
out.add(call);
50+
auto result = IGF.Builder.CreateBitCast(call, destType);
51+
52+
out.add(result);
4553

46-
return call;
54+
return result;
4755
}
4856

4957
void irgen::emitDistributedActorDestroy(IRGenFunction &IGF,

lib/IRGen/GenDistributed.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ class IRGenFunction;
4343
/// Emit the '_distributedActorRemoteInitialize' call.
4444
llvm::Value *emitDistributedActorInitializeRemote(
4545
IRGenFunction &IGF,
46+
SILType selfType,
4647
llvm::Value *actorMetatype,
4748
Explosion &out);
4849

0 commit comments

Comments
 (0)