Skip to content

[IRGen/Distributed] Adjust protocol requirement and witness table to handle distributed thunks #60184

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lib/IRGen/GenMeta.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -913,6 +913,10 @@ namespace {
if (entry.getFunction().isAutoDiffDerivativeFunction())
declRef = declRef.asAutoDiffDerivativeFunction(
entry.getFunction().getAutoDiffDerivativeFunctionIdentifier());
if (entry.getFunction().isDistributedThunk()) {
flags = flags.withIsAsync(true);
declRef = declRef.asDistributed();
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okey so this piece we did yesterday did matter... 👍

addDiscriminator(flags, schema, declRef);
}

Expand Down
12 changes: 7 additions & 5 deletions lib/IRGen/GenProto.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1352,6 +1352,8 @@ class AccessorConformanceInfo : public ConformanceInfo {
auto &entry = SILEntries.front();
SILEntries = SILEntries.slice(1);

bool isAsyncRequirement = requirement.hasAsync();

#ifndef NDEBUG
assert(entry.getKind() == SILWitnessTable::Method
&& "sil witness table does not match protocol");
Expand All @@ -1364,10 +1366,9 @@ class AccessorConformanceInfo : public ConformanceInfo {
#endif

SILFunction *Func = entry.getMethodWitness().Witness;
auto *afd = cast<AbstractFunctionDecl>(
entry.getMethodWitness().Requirement.getDecl());
llvm::Constant *witness = nullptr;
if (Func) {
assert(Func->isAsync() == isAsyncRequirement);
if (Func->isAsync()) {
witness = IGM.getAddrOfAsyncFunctionPointer(Func);
} else {
Expand All @@ -1376,7 +1377,7 @@ class AccessorConformanceInfo : public ConformanceInfo {
} else {
// The method is removed by dead method elimination.
// It should be never called. We add a pointer to an error function.
if (afd->hasAsync()) {
if (isAsyncRequirement) {
witness = llvm::ConstantExpr::getBitCast(
IGM.getDeletedAsyncMethodErrorAsyncFunctionPointer(),
IGM.FunctionPtrTy);
Expand All @@ -1388,8 +1389,9 @@ class AccessorConformanceInfo : public ConformanceInfo {
witness = llvm::ConstantExpr::getBitCast(witness, IGM.Int8PtrTy);

PointerAuthSchema schema =
afd->hasAsync() ? IGM.getOptions().PointerAuth.AsyncProtocolWitnesses
: IGM.getOptions().PointerAuth.ProtocolWitnesses;
isAsyncRequirement
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

aha that's what we were missing I see 👀

? IGM.getOptions().PointerAuth.AsyncProtocolWitnesses
: IGM.getOptions().PointerAuth.ProtocolWitnesses;
Table.addSignedPointer(witness, schema, requirement);
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@
// REQUIRES: concurrency
// REQUIRES: distributed

// FIXME: rdar://96520492 Test fails on specific config: Tools Opt+Assert, Stdlib Opt+DebInfo+Assert, iOS_arm64e
// UNSUPPORTED: CPU=arm64e

// rdar://76038845
// UNSUPPORTED: use_os_stdlib
// UNSUPPORTED: back_deployment_runtime
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@
// UNSUPPORTED: use_os_stdlib
// UNSUPPORTED: back_deployment_runtime

// FIXME: rdar://96520224 Test fails on specific config: Tools Opt+Assert, Stdlib Opt+DebInfo+Assert, iOS_arm64e
// UNSUPPORTED: CPU=arm64e

// FIXME(distributed): Distributed actors currently have some issues on windows, isRemote always returns false. rdar://82593574
// UNSUPPORTED: OS=windows-msvc

Expand Down