Skip to content

Commit 6622a3c

Browse files
committed
[Distributed] remove unused code
1 parent 1dd4372 commit 6622a3c

File tree

5 files changed

+3
-176
lines changed

5 files changed

+3
-176
lines changed

include/swift/SILOptimizer/Utils/DistributedActor.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,6 @@ void emitDistributedActorSystemWitnessCall(
5151
llvm::Optional<std::pair<SILBasicBlock *, SILBasicBlock *>> tryTargets =
5252
llvm::None);
5353

54-
/// Emit a call to a witness of the passed 'proto' protocol.
55-
void emitDistributedWitnessCall(
56-
SILBuilder &B, SILLocation loc, DeclName methodName,
57-
SILValue base, ProtocolDecl *proto, SILType actorType,
58-
llvm::ArrayRef<SILValue> args,
59-
llvm::Optional<std::pair<SILBasicBlock *, SILBasicBlock *>> tryTargets =
60-
llvm::None);
61-
6254
/// Emits code that notifies the distributed actor's actorSystem that the
6355
/// actor is ready for execution.
6456
/// \param B the builder to use when emitting the code.

lib/AST/SubstitutionMap.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ SubstitutionMap::Storage::Storage(
4444
: genericSig(genericSig),
4545
numConformanceRequirements(genericSig->getNumConformanceRequirements())
4646
{
47+
assert(replacementTypes.size() == getNumReplacementTypes());
4748
assert(conformances.size() == numConformanceRequirements);
4849

4950
std::copy(replacementTypes.begin(), replacementTypes.end(),

lib/SILGen/SILGenDistributed.cpp

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ static void initializeProperty(SILGenFunction &SGF, SILLocation loc,
9292
/********************* COMMON CONFORMANCE SIL PATTERNS ************************/
9393
/******************************************************************************/
9494

95+
// FIXME(distributed): should be implemented by getting the SerializationRequirement
9596
static void getSerializationRequirements(
9697
SILGenFunction &SGF, ASTContext &ctx, NominalTypeDecl actorDecl,
9798
SmallVectorImpl<ProtocolDecl *> &requirementProtocolDecls) {
@@ -104,30 +105,15 @@ static void getSerializationRequirements(
104105
requirementProtocolDecls.push_back(decodableDecl);
105106
}
106107

107-
// FIXME: this isn't actually implemented
108+
// FIXME(distributed): this isn't actually implemented
108109
static void pushSerializationRequirementConformance(
109110
SILGenFunction &SGF, ASTContext &ctx,
110111
SILType type,
111112
SmallVectorImpl<Type> &subTypes,
112113
SmallVectorImpl<ProtocolConformanceRef> &subConformances) {
113114
auto &B = SGF.B;
114-
auto module = B.getModule().getSwiftModule();
115115

116-
// auto resultEncodableTypeConfRef =
117-
// module->lookupConformance(resultType.getASTType(),
118-
// encodableRequirementTy);
119-
// assert(!distributedActorConfRef.isInvalid() &&
120-
// "Missing conformance to `SerializationRequirement`");
121116
subTypes.push_back(type.getASTType());
122-
// subConformances.push_back(resultEncodableTypeConfRef);
123-
124-
// auto decodableRequirementTy =
125-
// ctx.getProtocol(KnownProtocolKind::Decodable);
126-
// auto resultDecodableTypeConfRef =
127-
// module->lookupConformance(resultType.getASTType(),
128-
// encodableRequirementTy);
129-
// subTypes.push_back(resultType.getASTType());
130-
// subConformances.push_back(resultDecodableTypeConfRef);
131117
}
132118

133119
/// Push `Type` and `ProtocolConformanceRef` for the `Error` protocol to

lib/SILOptimizer/Utils/DistributedActor.cpp

Lines changed: 0 additions & 151 deletions
Original file line numberDiff line numberDiff line change
@@ -210,157 +210,6 @@ void emitDistributedActorSystemWitnessCall(
210210
}
211211
}
212212

213-
void emitDistributedWitnessCall(
214-
SILBuilder &B, SILLocation loc, DeclName methodName,
215-
SILValue base, ProtocolDecl *proto, SILType actorType,
216-
llvm::ArrayRef<SILValue> args,
217-
llvm::Optional<std::pair<SILBasicBlock *, SILBasicBlock *>> tryTargets) {
218-
auto &F = B.getFunction();
219-
auto &M = B.getModule();
220-
auto &C = F.getASTContext();
221-
222-
// Dig out the conformance to the passed in protocol.
223-
auto astType = base->getType().getASTType();
224-
auto *module = M.getSwiftModule();
225-
ProtocolConformanceRef confRef;
226-
227-
// If the base is an existential open it.
228-
if (astType->isAnyExistentialType()) {
229-
OpenedArchetypeType *opened;
230-
astType = astType->openAnyExistentialType(opened)->getCanonicalType();
231-
base = B.createOpenExistentialAddr(
232-
loc, base, F.getLoweredType(astType),
233-
OpenedExistentialAccess::Immutable);
234-
}
235-
236-
if (astType->isTypeParameter() || astType->is<ArchetypeType>()) {
237-
confRef = ProtocolConformanceRef(proto);
238-
} else {
239-
confRef = module->lookupConformance(astType, proto);
240-
}
241-
242-
assert(!confRef.isInvalid() &&
243-
"Missing conformance to `DistributedActorSystem`");
244-
245-
// Dig out the method.
246-
auto method = cast<FuncDecl>(proto->getSingleRequirement(methodName));
247-
auto methodRef = SILDeclRef(method, SILDeclRef::Kind::Func);
248-
auto methodSILTy =
249-
M.Types.getConstantInfo(B.getTypeExpansionContext(), methodRef)
250-
.getSILType();
251-
252-
auto witnessMethod = B.createWitnessMethod(
253-
loc, astType, confRef, methodRef, methodSILTy);
254-
255-
// prepare conformance substitutions
256-
SubstitutionMap subs;
257-
{
258-
auto genericSig = method->getGenericSignature();
259-
SmallVector<Type, 2> subTypes;
260-
SmallVector<ProtocolConformanceRef, 2> subConformances;
261-
subTypes.push_back(astType);
262-
subConformances.push_back(confRef);
263-
if (actorType) {
264-
ProtocolDecl *actorProto = C.getProtocol(
265-
KnownProtocolKind::DistributedActor);
266-
assert(actorProto);
267-
268-
ProtocolConformanceRef conformance;
269-
auto distributedActorConfRef = module->lookupConformance(
270-
actorType.getASTType(), actorProto);
271-
assert(!distributedActorConfRef.isInvalid() &&
272-
"Missing conformance to `DistributedActor`");
273-
subTypes.push_back(actorType.getASTType());
274-
subConformances.push_back(distributedActorConfRef);
275-
}
276-
277-
subs = SubstitutionMap::get(genericSig, subTypes, subConformances);
278-
}
279-
280-
Optional<SILValue> temporaryActorIDBuffer;
281-
282-
// If the self parameter is indirect but the actorSystem is a value, put it
283-
// into a temporary allocation.
284-
auto methodSILFnTy = methodSILTy.castTo<SILFunctionType>();
285-
Optional<SILValue> temporaryInvocationBuffer;
286-
if (methodSILFnTy->getSelfParameter().isFormalIndirect() &&
287-
!base->getType().isAddress()) {
288-
auto buf = B.createAllocStack(loc, base->getType(), None);
289-
base = B.emitCopyValueOperation(loc, base);
290-
B.emitStoreValueOperation(
291-
loc, base, buf, StoreOwnershipQualifier::Init);
292-
temporaryInvocationBuffer = SILValue(buf);
293-
}
294-
295-
// === Call the method.
296-
// --- Push the arguments
297-
SmallVector<SILValue, 2> allArgs;
298-
auto params = methodSILFnTy->getParameters();
299-
for (size_t i = 0; i < args.size(); ++i) {
300-
auto arg = args[i];
301-
if (params[i].isFormalIndirect() &&
302-
!arg->getType().isAddress() &&
303-
!dyn_cast<AnyMetatypeType>(arg->getType().getASTType())) {
304-
auto buf = B.createAllocStack(loc, arg->getType(), None);
305-
auto argCopy = B.emitCopyValueOperation(loc, arg);
306-
B.emitStoreValueOperation(
307-
loc, argCopy, buf, StoreOwnershipQualifier::Init);
308-
temporaryActorIDBuffer = SILValue(buf);
309-
allArgs.push_back(*temporaryActorIDBuffer);
310-
} else {
311-
allArgs.push_back(arg);
312-
}
313-
}
314-
// Push the self argument
315-
auto selfArg = temporaryInvocationBuffer ? *temporaryInvocationBuffer : base;
316-
allArgs.push_back(selfArg);
317-
318-
SILInstruction *apply;
319-
if (tryTargets) {
320-
apply = B.createTryApply(
321-
loc, witnessMethod, subs, allArgs, tryTargets->first,
322-
tryTargets->second);
323-
} else {
324-
apply = B.createApply(loc, witnessMethod, subs, allArgs);
325-
}
326-
327-
// Local function to emit a cleanup after the call.
328-
auto emitCleanup = [&](llvm::function_ref<void(SILBuilder &builder)> fn) {
329-
if (tryTargets) {
330-
{
331-
SILBuilderWithScope normalBuilder(tryTargets->first, apply);
332-
fn(normalBuilder);
333-
}
334-
{
335-
SILBuilderWithScope errorBuilder(tryTargets->second, apply);
336-
fn(errorBuilder);
337-
}
338-
} else {
339-
fn(B);
340-
}
341-
};
342-
343-
// ==== If we had to create a buffers we need to clean them up
344-
// --- Cleanup id buffer
345-
if (temporaryActorIDBuffer) {
346-
emitCleanup([&](SILBuilder & builder) {
347-
auto value = builder.emitLoadValueOperation(
348-
loc, *temporaryActorIDBuffer, LoadOwnershipQualifier::Take);
349-
builder.emitDestroyValueOperation(loc, value);
350-
builder.createDeallocStack(loc, *temporaryActorIDBuffer);
351-
});
352-
}
353-
// --- Cleanup actorSystem buffer
354-
if (temporaryInvocationBuffer) {
355-
emitCleanup([&](SILBuilder & builder) {
356-
auto value = builder.emitLoadValueOperation(
357-
loc, *temporaryInvocationBuffer, LoadOwnershipQualifier::Take);
358-
builder.emitDestroyValueOperation(loc, value);
359-
builder.createDeallocStack(loc, *temporaryInvocationBuffer);
360-
});
361-
}
362-
}
363-
364213
void emitActorReadyCall(SILBuilder &B, SILLocation loc, SILValue actor,
365214
SILValue actorSystem) {
366215

test/Distributed/Runtime/distributed_actor_func_calls_remoteCall_take.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ distributed actor Greeter {
2323
}
2424
}
2525

26-
2726
// ==== Fake Transport ---------------------------------------------------------
2827
struct ActorAddress: Sendable, Hashable, Codable {
2928
let address: String

0 commit comments

Comments
 (0)